Class: OMQ::PEER
- Inherits:
-
Socket
- Object
- Socket
- OMQ::PEER
- Includes:
- Readable, SingleFrame, Writable
- Defined in:
- lib/omq/peer.rb
Overview
Bidirectional multi-peer socket with routing IDs (ZeroMQ RFC 51).
Each connected peer is assigned a 4-byte routing ID. Supports directed sends via #send_to and fair-queued receives.
Instance Method Summary collapse
-
#initialize(endpoints = nil, linger: Float::INFINITY, backend: nil) ⇒ PEER
constructor
Creates a new PEER socket.
-
#send_to(routing_id, message) ⇒ self
Sends a message to a specific peer by routing ID.
Constructor Details
#initialize(endpoints = nil, linger: Float::INFINITY, backend: nil) ⇒ PEER
Creates a new PEER socket.
18 19 20 21 22 |
# File 'lib/omq/peer.rb', line 18 def initialize(endpoints = nil, linger: Float::INFINITY, backend: nil) init_engine(:PEER, backend: backend) @options.linger = linger attach_endpoints(endpoints, default: :connect) end |
Instance Method Details
#send_to(routing_id, message) ⇒ self
Sends a message to a specific peer by routing ID.
31 32 33 34 35 |
# File 'lib/omq/peer.rb', line 31 def send_to(routing_id, ) parts = [routing_id.b.freeze, .b.freeze] Reactor.run(timeout: @options.write_timeout) { @engine.enqueue_send(parts) } self end |