Class: NNQ::RESPONDENT0
Overview
RESPONDENT (nng respondent0): reply side of the survey pattern. Cooked mode strictly alternates #receive / #send_reply; raw mode exposes the backtrace as an opaque header and the originating surveyor pipe as a live Connection.
Instance Attribute Summary
Attributes inherited from Socket
Instance Method Summary collapse
-
#receive ⇒ Object
Cooked: blocks until the next survey arrives.
-
#send(body, to:, header:) ⇒ Object
Raw: writes
bodywithheaderback toto. -
#send_reply(body) ⇒ Object
Cooked: routes
bodyback to the surveyor that sent the most recent survey.
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
Cooked: blocks until the next survey arrives. Raw: returns ‘[pipe, header, body]`.
64 65 66 |
# File 'lib/nnq/surveyor_respondent.rb', line 64 def receive Reactor.run { @engine.routing.receive } end |
#send(body, to:, header:) ⇒ Object
Raw: writes body with header back to to. Raises in cooked mode.
79 80 81 82 83 |
# File 'lib/nnq/surveyor_respondent.rb', line 79 def send(body, to:, header:) raise Error, "RESPONDENT#send not available in cooked mode" unless raw? body = frozen_binary(body) Reactor.run { @engine.routing.send(body, to: to, header: header) } end |
#send_reply(body) ⇒ Object
Cooked: routes body back to the surveyor that sent the most recent survey. Raises in raw mode.
71 72 73 74 75 |
# File 'lib/nnq/surveyor_respondent.rb', line 71 def send_reply(body) raise Error, "RESPONDENT#send_reply not available in raw mode" if raw? body = frozen_binary(body) Reactor.run { @engine.routing.send_reply(body) } end |