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
()
Item Index
Methods
Properties
Methods
init
-
cb
Initializes the broker by creating the connections to Redis and registering for the message event.
Parameters:
-
cbFunctionA 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:
-
channelStringThe channel the message was pushed to
-
commandStrStringThe message that was published
publish
-
channel -
command -
cb
Sends a message to the specified channel
Parameters:
-
channelStringThe channel to send the message to
-
commandObjectThe command to send to the cluster
-
cbFunctionA 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:
-
cbFunctionA callback that provides two parameters: cb(Error, Boolean)
subscribe
-
channel -
onCommandReceived -
cb
Registers a handler for messages on the specified channel.
Parameters:
-
channelStringThe channel to listen for messages on
-
onCommandReceivedFunctionA handler function that takes two arguments: onCommandReceived(channel, message) where channel is a string and message is an object.
-
cbFunctionA 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
