Module: OMQ::QoS::CommandClassExt
- Defined in:
- lib/omq/qos/zmtp/command_ext.rb
Overview
Prepended onto Protocol::ZMTP::Codec::Command's singleton class to add ACK/NACK/CLR/COMP command builders.
Instance Method Summary collapse
-
#ack(hash_bytes, algorithm: "x") ⇒ Object
Builds an ACK command.
-
#clr(hash_bytes, algorithm: "x") ⇒ Object
Builds a CLR ("clear") command.
-
#comp(hash_bytes, algorithm: "x") ⇒ Object
Builds a COMP ("complete") command.
-
#nack(hash_bytes, code: 0, message: "", algorithm: "x") ⇒ Object
Builds a NACK command.
Instance Method Details
#ack(hash_bytes, algorithm: "x") ⇒ Object
Builds an ACK command.
13 14 15 |
# File 'lib/omq/qos/zmtp/command_ext.rb', line 13 def ack(hash_bytes, algorithm: "x") new("ACK", "#{algorithm}#{hash_bytes}".b) end |
#clr(hash_bytes, algorithm: "x") ⇒ Object
Builds a CLR ("clear") command. Sent by the sender after receiving an ACK (QoS 2) or COMP (QoS 3) so the receiver may evict the digest from its dedup set immediately instead of waiting for TTL expiry.
40 41 42 |
# File 'lib/omq/qos/zmtp/command_ext.rb', line 40 def clr(hash_bytes, algorithm: "x") new("CLR", "#{algorithm}#{hash_bytes}".b) end |
#comp(hash_bytes, algorithm: "x") ⇒ Object
Builds a COMP ("complete") command. Sent by the QoS 3 receiver after its application handler returns successfully.
50 51 52 |
# File 'lib/omq/qos/zmtp/command_ext.rb', line 50 def comp(hash_bytes, algorithm: "x") new("COMP", "#{algorithm}#{hash_bytes}".b) end |
#nack(hash_bytes, code: 0, message: "", algorithm: "x") ⇒ Object
Builds a NACK command. The on-wire error_info payload is
[1 byte code] [2 bytes big-endian message length] [message]
per the omq-qos RFC §NACK command.
26 27 28 29 30 |
# File 'lib/omq/qos/zmtp/command_ext.rb', line 26 def nack(hash_bytes, code: 0, message: "", algorithm: "x") msg_bytes = .b error_info = [code, msg_bytes.bytesize].pack("Cn") + msg_bytes new("NACK", "#{algorithm}#{hash_bytes}#{error_info}".b) end |