Module: OMQ::QoS::CommandExt
- Defined in:
- lib/omq/qos/zmtp/command_ext.rb
Overview
Prepended onto Protocol::ZMTP::Codec::Command to add ACK/NACK/CLR/COMP data extraction methods.
Instance Method Summary collapse
-
#ack_data ⇒ Array(String, String)
Extracts algorithm prefix and hash bytes from an ACK command's data.
-
#clr_data ⇒ Array(String, String)
Same layout as ACK.
-
#comp_data ⇒ Array(String, String)
Same layout as ACK — COMP carries only the digest.
-
#nack_data ⇒ Array(String, String, Integer, String)
Extracts algorithm, hash bytes, NACK code, and error message from a NACK command's data.
Instance Method Details
#ack_data ⇒ Array(String, String)
Extracts algorithm prefix and hash bytes from an ACK command's data.
63 64 65 66 67 |
# File 'lib/omq/qos/zmtp/command_ext.rb', line 63 def ack_data algo = @data.byteslice(0, 1) hash_size = Protocol::ZMTP::Codec::Command::ACK_HASH_SIZES.fetch(algo, 8) [algo, @data.byteslice(1, hash_size)] end |
#clr_data ⇒ Array(String, String)
Same layout as ACK.
73 74 75 |
# File 'lib/omq/qos/zmtp/command_ext.rb', line 73 def clr_data ack_data end |
#comp_data ⇒ Array(String, String)
Same layout as ACK — COMP carries only the digest.
81 82 83 |
# File 'lib/omq/qos/zmtp/command_ext.rb', line 81 def comp_data ack_data end |
#nack_data ⇒ Array(String, String, Integer, String)
Extracts algorithm, hash bytes, NACK code, and error message from a NACK command's data. See OMQ::QoS::CommandClassExt#nack for the wire layout.
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/omq/qos/zmtp/command_ext.rb', line 92 def nack_data algo = @data.byteslice(0, 1) hash_size = Protocol::ZMTP::Codec::Command::ACK_HASH_SIZES.fetch(algo, 8) hash = @data.byteslice(1, hash_size) off = 1 + hash_size header = @data.byteslice(off, 3) if header && header.bytesize == 3 code, msg_len = header.unpack("Cn") = @data.byteslice(off + 3, msg_len) || "".b else code, = 0, "".b end [algo, hash, code, ] end |