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:
-
cb
FunctionA 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
StringThe channel the message was pushed to
-
commandStr
StringThe message that was published
publish
-
channel
-
command
-
cb
Sends a message to the specified channel
Parameters:
-
channel
StringThe channel to send the message to
-
command
ObjectThe command to send to the cluster
-
cb
FunctionA 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
FunctionA callback that provides two parameters: cb(Error, Boolean)
subscribe
-
channel
-
onCommandReceived
-
cb
Registers a handler for messages on the specified channel.
Parameters:
-
channel
StringThe channel to listen for messages on
-
onCommandReceived
FunctionA handler function that takes two arguments: onCommandReceived(channel, message) where channel is a string and message is an object.
-
cb
FunctionA 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