Class: NNQ::SURVEYOR0

Inherits:
Socket
  • Object
show all
Defined in:
lib/nnq/surveyor_respondent.rb

Overview

SURVEYOR (nng surveyor0): broadcast side of the survey pattern. Sends a survey to all connected respondents, then collects replies within a timed window (‘options.survey_time`, default 1s).

Only one outstanding survey at a time — sending a new survey abandons the previous one. Respondents are not obliged to reply.

Instance Attribute Summary

Attributes inherited from Socket

#options

Instance Method Summary collapse

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

#receiveString

Receives the next reply. Raises TimedOut when the survey window expires.

Returns:

  • (String)

    reply body



27
28
29
# File 'lib/nnq/surveyor_respondent.rb', line 27

def receive
  Reactor.run { @engine.routing.receive }
end

#send_survey(body) ⇒ Object

Broadcasts body as a survey to all connected respondents.



17
18
19
20
# File 'lib/nnq/surveyor_respondent.rb', line 17

def send_survey(body)
  body = frozen_binary(body)
  Reactor.run { @engine.routing.send_survey(body) }
end