Zyre::
Node class
Superclass | rb_cObject |
Extended With |
|
A node in a Zyre
cluster.
Refs: - github.com/zeromq/zyre#readme
Public Instance Methods
Set an alternative endpoint
value when using GOSSIP ONLY. This is useful if you’re advertising an endpoint behind a NAT.
Note: this is part of the ZRE 43 Draft API, and may be changed or removed at any time.
Set the TCP port bound by the ROUTER peer-to-peer socket (beacon mode). Defaults to * (the port is randomly assigned by the system). This call overrides this, to bypass some firewall issues when ports are random. Has no effect after start
.
Note: this is part of the ZRE 43 Draft API, and may be changed or removed at any time.
Yield each incoming event to the block. If no block is given, returns an enumerator instead.
Return the endpoint being used by the Node
if there is one.
By default, Zyre
binds to an ephemeral TCP port and broadcasts the local host name using UDP beaconing. When you call this method, Zyre
will use gossip discovery instead of UDP beaconing. You MUST set up the gossip service separately using gossip_bind
and gossip_connect
. Note that the endpoint MUST be valid for both bind and connect operations. You can use inproc://
, ipc://
, or tcp://
transports (for tcp://
, use an IP address that is meaningful to remote as well as local nodes). Returns true
if the bind was successful.
Set the peer evasiveness timeout in milliseconds. Default is 5000. This can be tuned in order to deal with expected network conditions and the response time expected by the application. This is tied to the beacon interval and rate of messages received.
Set the peer expiration timeout, in milliseconds. Default is 30000. This can be tuned in order to deal with expected network conditions and the response time expected by the application. This is tied to the beacon interval and rate of messages received.
Set-up gossip discovery of other nodes. At least one node in the cluster must bind to a well-known gossip endpoint, so other nodes can connect to it. Note that gossip endpoints are completely distinct from Zyre
node endpoints, and should not overlap (they can use the same transport).
Set-up gossip discovery of other nodes. A node may connect to multiple other nodes, for redundancy paths. For details of the gossip network design, see the CZMQ zgossip class.
Connect to the gossip discovery endpoint with CURVE enabled. The public_key
is the Z85-armored public key of the connecting node’s cert/
Note: this is part of the ZRE 43 Draft API, and may be changed or removed at any time.
Unpublish a GOSSIP node from local list, useful in removing nodes from list when they EXIT.
Note: this is part of the ZRE 43 Draft API, and may be changed or removed at any time.
Set headers from the given hash
. Convenience wrapper for set_header
. Symbol keys will have _
characters converted to -
and will be capitalized when converted into Strings. E.g.,
headers = { content_type: ‘application/json’ }
will call:
.set_header( ‘Content-type’, ‘application/json’ )
Return a string describing the node suitable for debugging.
Set network interface for UDP beacons. If you do not set this, CZMQ will choose an interface for you. On boxes with several interfaces you should specify which one you want to use, or strange things can happen.
Set UDP beacon discovery interval in milliseconds. Default is instant beacon exploration followed by pinging every 1000 msecs.
Join a named group; after joining a group you can send messages to the group and all Zyre
nodes in that group will receive them.
Leave a group.
Return the node name.
Set the public name of this node overriding the default. The name is provided during discovery and come in each ENTER message.
Return an Array of the names of the receiving node’s current groups.
Return the endpoint of a connected peer
. Returns nil if peer does not exist.
Return an Array of the names of groups known through connected peers.
Return the value of a header of a conected peer. Returns nil if peer or key doesn’t exist.
Return an Array of current peer UUIDs.
Return an Array of the current peers in the specified group
.
Set UDP beacon discovery port. Defaults to 5670. This call overrides the default so that you can create independent clusters on the same network, for e.g. development vs. production. Has no effect after start
.
Print zyre node information to stdout.
Receive the next event from the network as a Zyre::Event
.
Explicitly connect to a peer with the given node_uuid
via the specified router_endpoint
, using the given public_key
to authenticate.
Note: this is part of the ZRE 43 Draft API, and may be changed or removed at any time.
This options enables a peer to actively contest for leadership in the given group
. If this option is not set the peer will still participate in elections but never gets elected. This ensures that a consent for a leader is reached within a group even though not every peer is contesting for leadership.
Note: this is part of the ZRE 43 Draft API, and may be changed or removed at any time.
Set node header; these are provided to other nodes during discovery and come in each ENTER
message.
Send message
to a named group
.
Start node, after setting header values. When you start a node it begins discovery and connection. Returns true
if the node was started successfully.
Stop node; this signals to other peers that this node will go away. This is polite; however you can also just destroy the node without stopping it.
Return the node’s UUID as a String.
Set verbose mode; this tells the node to log all traffic as well as all major events.
Wait for an event of a given event_type
(e.g., :JOIN) and matching any optional criteria
, returning the event if a matching one was seen. If a timeout
is given and the event hasn’t been seen after the timeout
seconds have elapsed, return nil
. If a block is given, call the block for each (non-matching) event that arrives in the interim. Note that the execution time of the block is counted in the timeout.
Send a message
to a single peer
specified as a UUID string.
Specify the ZAP domain (for use with CURVE authentication). See Authentication.
Note: this is part of the ZRE 43 Draft API, and may be changed or removed at any time.
Apply a zcert
to a Zyre
node. See Zyre::Cert#apply
and Authentication.
Note: this is part of the ZRE 43 Draft API, and may be changed or removed at any time.
Protected Instance Methods
Create an Enumerator that yields each event as it comes in. If there is no event to read, block until there is one.
Wait for an event of the given event_class
and criteria
, returning it when it arrives. Blocks indefinitely until it arrives or interrupted.
Wait for an event of the given event_class
and criteria
, returning it if it arrives before timeout
seconds elapses. If the timeout elapses first, return nil
.