MongoRegistrationProvider 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 MongoDB as the storage. In addition, it leverages MongoDB's TTL collections. The reaper for mongo runs every 60 seconds. It is possible for dead processes to appear in the status list for up to that magical 60 second threshold. The name of the collection used to store all statuses is determined by the configuration property: "registry.key".
Constructor
MongoRegistrationProvider
()
Methods
flush
-
cb
Purges all statuses from storage.
Parameters:
-
cb
FunctionA 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
FunctionA callback that provides two parameters: cb(Error, Array)
init
-
cb
This function should only be called once at startup. It is responsible for setting up the collection and ensuring that the TTL index is configured correctly based on the the executing processes configuration. NOTE: The collection only supports one TTL value. The last process to startup and configure the index will win. Please be careful to ensure that all PB processes/nodes have the same registry.update_interval value.
Parameters:
-
cb
FunctionA callback that takes two parameters. cb(Error, [RESULT])
set
-
id
-
status
-
cb
Updates the status of a single node.
Parameters:
-
id
StringThe unique identifier for the process/node
-
status
ObjectThe status information
-
cb
FunctionA 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
StringThe unique identifier for the node/process
-
cb
FunctionA callback that takes two parameters: cb(Error, [RESULT])