Class: NNQ::REQ0
Overview
REQ (nng req0): client side of request/reply. Cooked mode keeps a single in-flight request and matches replies by id; raw mode bypasses the state machine entirely and delivers replies as ‘[pipe, header, body]` tuples so the app can correlate verbatim.
Instance Attribute Summary
Attributes inherited from Socket
Instance Method Summary collapse
-
#receive ⇒ Object
Raw: blocks until the next reply arrives, returns ‘[pipe, header, body]`.
-
#send(body, header:) ⇒ Object
Raw: round-robins
bodyto the next connected peer withheader(typically ‘[id | 0x80000000].pack(“N”)`) written verbatim between the SP length prefix and the body. -
#send_request(body) ⇒ Object
Cooked: sends
bodyas a request, blocks until the matching reply arrives.
Methods inherited from Socket
#all_peers_gone, bind, #bind, #close, #close_read, connect, #connect, #connection_count, #frozen_binary, #initialize, #last_endpoint, #monitor, #peer_connected, #raw?, #reconnect_enabled, #reconnect_enabled=
Constructor Details
This class inherits a constructor from NNQ::Socket
Instance Method Details
#receive ⇒ Object
Raw: blocks until the next reply arrives, returns ‘[pipe, header, body]`. Raises in cooked mode.
39 40 41 42 |
# File 'lib/nnq/req_rep.rb', line 39 def receive raise Error, "REQ#receive not available in cooked mode" unless raw? Reactor.run { @engine.routing.receive } end |
#send(body, header:) ⇒ Object
Raw: round-robins body to the next connected peer with header (typically ‘[id | 0x80000000].pack(“N”)`) written verbatim between the SP length prefix and the body. Raises in cooked mode.
30 31 32 33 34 |
# File 'lib/nnq/req_rep.rb', line 30 def send(body, header:) raise Error, "REQ#send not available in cooked mode" unless raw? body = frozen_binary(body) Reactor.run { @engine.routing.send(body, header: header) } end |