Class: NNQ::SURVEYOR0
Overview
SURVEYOR (nng surveyor0): broadcast side of the survey pattern. Cooked mode enforces a timed survey window and matches replies by survey id; raw mode fans out with a caller-supplied header and delivers replies as ‘[pipe, header, body]` with no timer.
Instance Attribute Summary
Attributes inherited from Socket
Instance Method Summary collapse
-
#receive ⇒ Object
Cooked: receives the next reply within the survey window, raises TimedOut on window expiry.
-
#send(body, header:) ⇒ Object
Raw: broadcasts
bodywithheaderto all connected respondents via per-conn send pumps (header is threaded through the protocol-sp header kwarg — no concat). -
#send_survey(body) ⇒ Object
Cooked: broadcasts
bodyas a survey to all connected respondents.
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: receives the next reply within the survey window, raises TimedOut on window expiry. Raw: returns ‘[pipe, header, body]` and blocks indefinitely (no survey window).
37 38 39 |
# File 'lib/nnq/surveyor_respondent.rb', line 37 def receive Reactor.run { @engine.routing.receive } end |
#send(body, header:) ⇒ Object
Raw: broadcasts body with header to all connected respondents via per-conn send pumps (header is threaded through the protocol-sp header kwarg — no concat). Raises in cooked mode.
27 28 29 30 31 |
# File 'lib/nnq/surveyor_respondent.rb', line 27 def send(body, header:) raise Error, "SURVEYOR#send not available in cooked mode" unless raw? body = frozen_binary(body) Reactor.run { @engine.routing.send(body, header: header) } end |
#send_survey(body) ⇒ Object
Cooked: broadcasts body as a survey to all connected respondents.
17 18 19 20 21 |
# File 'lib/nnq/surveyor_respondent.rb', line 17 def send_survey(body) raise Error, "SURVEYOR#send_survey not available in raw mode" if raw? body = frozen_binary(body) Reactor.run { @engine.routing.send_survey(body) } end |