API Docs for: 0.8.0
Show:

RedisRegistrationProvider Class

Implements the necessary functions in order to be able to create and manage a service registry for PB processes in the cluster. This provider uses Redis as the storage. In addition, it leverages Redis's expiry functionality to expire entries automatically if they have not been touched. In order to retrieve all nodes/processes in the cluster the provider must execute Redis's "keys" function which is an expensive operation. To lessen the impact on production systems the provider creates and manages its own Redis client and switches to DB 2 in order to minimize the number of keys that need to be scanned since the rest of the PB system leverages DB 0.

Constructor

RedisRegistrationProvider

()

Item Index

Methods

Properties

Methods

flush

(
  • cb
)

Purges all statuses from storage.

Parameters:

  • cb Function

    A callback that provides two parameters: cb(Error, [RESULT])

get

(
  • cb
)

Retrieves the entire cluster status as an array of status objects. The '_id' property uniquely identifies each process/node.

Parameters:

  • cb Function

    A callback that provides two parameters: cb(Error, Array)

getKey

(
  • id
)
String static

Creates the cache key used to store the status update

Parameters:

  • id String

    The unique identifier for the node/process

Returns:

String:

The cache key to be used for storing the update

getPattern

() String static

Creates the glob pattern to be used to find service registry keys

Returns:

String:

The glob patern to be used to find all status updates

init

(
  • cb
)

This function should only be called once at startup. It is responsible for creating the Redis client that connects to the service registry. It also ensures the proper Redis DB is selected.

Parameters:

  • cb Function

    A callback that takes two parameters. cb(Error, [RESULT])

set

(
  • id
  • status
  • cb
)

Updates the status of a single node.

Parameters:

  • id String

    The unique identifier for the process/node

  • status Object

    The status information

  • cb Function

    A callback that provides two parameters: cb(Error, [RESULT])

shutdown

(
  • id
  • cb
)

Should be called during shutdown. It is responsible for removing the process/node from the registry.

Parameters:

  • id String

    The unique identifier for the node/process

  • cb Function

    A callback that takes two parameters: cb(Error, [RESULT])

Properties

CLIENT

Integer private static

The Redis client used to connect to the service registry

REGISTRY_DB

Integer private static

The Redis DB used for storage

SEP

String private static

The character used to separate the registry key prefix from the unique value that identifies the process/node.