API Docs for: 0.8.0
Show:

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

()

Item Index

Methods

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)

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 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
)
static

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])