API Docs for: 0.8.0
Show:

RedisCommandBroker Class

Brokers messages using Redis as the medium. The implementation follows a publish/subscribe model that allows for listening for changes based on a a specified channel.

Constructor

RedisCommandBroker

()

Methods

init

(
  • cb
)

Initializes the broker by creating the connections to Redis and registering for the message event.

Parameters:

  • cb Function

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

onCommandReceived

(
  • channel
  • commandStr
)

Called when a member of the cluster has published a command. The function inspects that it has a handler for the channel then delegates the command back to the handler.

Parameters:

  • channel String

    The channel the message was pushed to

  • commandStr String

    The message that was published

publish

(
  • channel
  • command
  • cb
)

Sends a message to the specified channel

Parameters:

  • channel String

    The channel to send the message to

  • command Object

    The command to send to the cluster

  • cb Function

    A callback that takes two parameters: cb(Error, 1 on success/FALSE on failure)

shutdown

(
  • cb
)

Shuts down the broker by closing the open connections to Redis.

Parameters:

  • cb Function

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

subscribe

(
  • channel
  • onCommandReceived
  • cb
)

Registers a handler for messages on the specified channel.

Parameters:

  • channel String

    The channel to listen for messages on

  • onCommandReceived Function

    A handler function that takes two arguments: onCommandReceived(channel, message) where channel is a string and message is an object.

  • cb Function

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

Properties

publishClient

Client

Client used to publish commands to the cluster

publishClient

Client

Client used to subscribe to commands to the cluster

SUBSCRIBERS

Object private static

The hash of handlers for each channel subscribed to