ServerRegistration Class
Service that provides the ability for the process/node to register itself so that other nodes in the system can find it. In addition, it helps with the health monitoring of the system.
Constructor
ServerRegistration
()
Item Index
Methods
- addItem static
- doRegistration static
- flush static
- generateKey static
- generateServerKey static
- getClusterStatus
- getInstance static
- getIp static
- init static
- logUpdateResult static
- shutdown static
Properties
- INSTANCE static
- ITEM_CALLBACKS
Methods
addItem
-
name
-
The
Registers a function to be called on every status update. The function should take one parameter: a callback function that accepts two parameters, the first being an error if it occurred and the second being the current value for the information requested.
Parameters:
-
name
StringThe name and/or description of the information being gathered
-
The
Functionfunction to be called to gather the data.
Returns:
TRUE if the function is successfully registered, FALSE if not.
doRegistration
-
[cb] A callback that provides two parameters: cb(Error, [RESULT]
Performs the request for information and persists it through the storage provider.
Parameters:
-
[cb] A callback that provides two parameters: cb(Error, [RESULT]
Function optional)
flush
-
cb
Removes all entries from the server registry
Parameters:
-
cb
FunctionA callback that provides two parameters: cb(Error, [RESULT])
generateKey
()
String
static
Generates the unique key for the PB process/node.
Returns:
The unique identifier
generateServerKey
()
String
static
Retrieves a unique key for the server but not for the process
Returns:
server key
getClusterStatus
-
cb
Retrieves the most recent status from the entire cluster.
Parameters:
-
cb
FunctionA callback that provides two parameters: cb(Error, Array)
getInstance
-
[provider]
Retrieves the singleton instance of the service registry
Parameters:
-
[provider]
RegistrationProvider optional
Returns:
getIp
()
String
static
Retrieves the first IP address found for the node.
Returns:
The first IP address found for the node
init
-
cb
Should only be called once at startup. The function verifies that the registry is enabled and initializes the correct storage provider.
Parameters:
-
cb
FunctionA callback that provides two parameters: cb(Error, [RESULT])
logUpdateResult
-
key
-
update
-
err
-
result
Parameters:
-
key
String -
update
Object -
err
Error -
result
Boolean
shutdown
-
cb
Called during shutdown. The function is responsible for clearing any scheduled updates and shutting down the storage provider.
Parameters:
-
cb
FunctionA callback that provides two parameters: cb(Error, [RESULT])
Properties
ITEM_CALLBACKS
Object
private
The default set of functions that gather the default set of information.