API Docs for: 0.0.1
Show:

Hub Class

Extends EventEmitter
Defined in: core/hub.js:10
Module: core

The Hub abstracts low level ZeroMQ communication.

Features:

  • 1-1, 1-N req / rep
  • message acknowledgements
  • retries
  • keepalives

It three ZMQ sockets: router, pub and sub.

Constructor

Hub

(
  • options
)

Defined in core/hub.js:10

Parameters:

  • options Object
    • [id] String optional

      Uniquely identifies the hub on the network.

    • router String

      Router socket endpoint. Supports all the ZeroMQ socket endpoints.

    • [pub] String optional

      Pub socket endpoint.

Methods

_sendPub

(
  • buffer
)
private

Defined in core/hub.js:494

Send a buffer on the pub socket.

Parameters:

  • buffer Buffer

_sendRouter

(
  • frames
)
private

Defined in core/hub.js:472

Send an array of buffers on the router socket.

The first frame must be the socket of the other hub.

Parameters:

  • frames Array

    Array of Buffers.

ack

(
  • msg
)

Defined in core/hub.js:338

Acknowledge the receival of a message by sending an _ack message.

Parameters:

bind

()

Defined in core/hub.js:146

Bind the router and pub sockets. The hub can now send/receive messages.

handshake

(
  • hub
  • callback
)

Defined in core/hub.js:263

Connect the hub to another hub.

Parameters:

  • hub Hub

    The hub to connect to.

  • callback Function

    Called after completing the handshake.

onHandshake

(
  • msg
)

Defined in core/hub.js:309

Called when the hub receives a _handshake message.

Parameters:

op

(
  • options
)
RetryOperation static

Defined in core/hub.js:562

Parameters:

  • options Object

    Same options as retry.operation(options)

Returns:

RetryOperation:

reply

(
  • msg
  • [data]
  • [callback]
)

Defined in core/hub.js:359

Reply to a message. Pass in a callback if you're expecting a reply.

Parameters:

  • msg Object

    The message you are replying to.

  • [data] Object optional

    Optional data to send

  • [callback] Function optional

routerSocketId

(
  • id
)
Buffer static

Defined in core/hub.js:551

Parameters:

Returns:

Buffer:

sendById

(
  • id
  • message
  • [callback]
)

Defined in core/hub.js:408

Send a message to the hub identified by id.

Parameters:

  • id String
  • message Message
  • [callback] Function optional

    If you are expecting a reply, this will be called with (err, reply).

Properties

_machine

Stately private

Defined in core/hub.js:100

The hub's state machine.

_opCache

Object private static

Defined in core/hub.js:576

Caches operations returned by Hub.op().

ackAll

Boolean

Defined in core/hub.js:71

Whether all messages that this node sends should be acked.

Default: true

ackOnly

Object

Defined in core/hub.js:80

Messages types which the node should ack. Overrides ackAll.

Default: {}

messageFactory

MessageFactory

Defined in core/hub.js:89

The hub's message factory. Used to create all messages sent.

routerSocketId

Buffer

Defined in core/hub.js:62

The id of the hub's router socket. Other nodes use this to send messages us messages from their router sockets.

Default: null