Module: OMQ::QoS::ConnectionExt
- Defined in:
- lib/omq/qos/connection_ext.rb
Overview
Prepended onto Protocol::ZMTP::Connection so that command frames received during a normal Connection#receive_message loop are dispatched to a per-connection QoS handler. Without this, ACK commands sent by the peer would be silently dropped by the recv pump (which skips command frames).
Instance Attribute Summary collapse
-
#qos_on_command ⇒ Object
Returns the value of attribute qos_on_command.
Instance Method Summary collapse
-
#receive_message(&block) ⇒ Object
Re-reads
@qos_on_commandon each command frame rather than capturing it once at call-start.
Instance Attribute Details
#qos_on_command ⇒ Object
Returns the value of attribute qos_on_command.
12 13 14 |
# File 'lib/omq/qos/connection_ext.rb', line 12 def qos_on_command @qos_on_command end |
Instance Method Details
#receive_message(&block) ⇒ Object
Re-reads @qos_on_command on each command frame rather than
capturing it once at call-start. The PUSH reaper fires
receive_message immediately after handshake — before the
routing layer has wired up the QoS handler — so a one-time
capture would pin the handler to nil for the lifetime of the
connection.
21 22 23 24 25 26 27 28 29 |
# File 'lib/omq/qos/connection_ext.rb', line 21 def (&block) super() do |frame| if (handler = @qos_on_command) cmd = Protocol::ZMTP::Codec::Command.from_body(frame.body) handler.call(cmd) end block&.call(frame) end end |