Class: NNQ::Routing::RespondentRaw
- Inherits:
-
Object
- Object
- NNQ::Routing::RespondentRaw
show all
- Includes:
- Backtrace
- Defined in:
- lib/nnq/routing/respondent_raw.rb
Overview
Raw RESPONDENT: mirror of RepRaw for the survey pattern. No survey-window state, no pending slot — the app receives ‘[pipe, header, body]` tuples and chooses whether (and when) to reply via `send(body, to:, header:)`.
Constant Summary
Constants included
from Backtrace
Backtrace::MAX_HOPS
Instance Method Summary
collapse
Methods included from Backtrace
#parse_backtrace, too_many_hops?
Constructor Details
Returns a new instance of RespondentRaw.
17
18
19
20
|
# File 'lib/nnq/routing/respondent_raw.rb', line 17
def initialize(engine)
@engine = engine
@recv_queue = Async::LimitedQueue.new(engine.options.recv_hwm)
end
|
Instance Method Details
#close ⇒ Object
43
44
45
|
# File 'lib/nnq/routing/respondent_raw.rb', line 43
def close
@recv_queue.enqueue(nil)
end
|
#close_read ⇒ Object
48
49
50
|
# File 'lib/nnq/routing/respondent_raw.rb', line 48
def close_read
@recv_queue.enqueue(nil)
end
|
#enqueue(wire_bytes, conn) ⇒ Object
36
37
38
39
40
|
# File 'lib/nnq/routing/respondent_raw.rb', line 36
def enqueue(wire_bytes, conn)
, payload = parse_backtrace(wire_bytes)
return unless
@recv_queue.enqueue([conn, , payload])
end
|
#receive ⇒ Object
23
24
25
|
# File 'lib/nnq/routing/respondent_raw.rb', line 23
def receive
@recv_queue.dequeue
end
|
#send(body, to:, header:) ⇒ Object
28
29
30
31
32
33
|
# File 'lib/nnq/routing/respondent_raw.rb', line 28
def send(body, to:, header:)
return if to.closed?
return if Backtrace.too_many_hops?()
to.send_message(body, header: )
rescue ClosedError
end
|