Module: OMQ::QoS::ReadableExt
- Defined in:
- lib/omq/qos/socket_ext.rb
Overview
Prepended onto Readable so that at QoS 3 #receive accepts
(and requires) a block. The block runs the application handler;
its return value becomes a COMP command; a raised StandardError
becomes a NACK with the mapped error code.
At QoS 0/1/2 #receive is unchanged.
Instance Method Summary collapse
Instance Method Details
#each(&block) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/omq/qos/socket_ext.rb', line 73 def each(&block) qos = @options.qos return super unless qos && qos.level >= 3 raise ArgumentError, "QoS 3 requires a block to #each" unless block loop do receive(&block) rescue IO::TimeoutError return end end |
#receive(&block) ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/omq/qos/socket_ext.rb', line 62 def receive(&block) qos = @options.qos return super() if qos.nil? || qos.level < 3 raise ArgumentError, "QoS 3 requires a block to #receive — the block's return or raise signals COMP/NACK" unless block env = super() QoS.process_qos3_envelope(env, qos, &block) end |