Class: MarchHare::Headers
- Inherits:
-
Object
- Object
- MarchHare::Headers
- Defined in:
- lib/march_hare/metadata.rb
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
-
#consumer_tag ⇒ Object
readonly
Returns the value of attribute consumer_tag.
-
#envelope ⇒ Object
readonly
Returns the value of attribute envelope.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
Instance Method Summary collapse
- #ack(options = {}) ⇒ Object
- #delivery_tag ⇒ Object
- #headers ⇒ Object
-
#initialize(channel, consumer_tag, envelope, properties) ⇒ Headers
constructor
A new instance of Headers.
- #persistent? ⇒ Boolean
- #redelivered? ⇒ Boolean
- #redelivery? ⇒ Boolean
- #reject(options = {}) ⇒ Object
Constructor Details
#initialize(channel, consumer_tag, envelope, properties) ⇒ Headers
Returns a new instance of Headers.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/march_hare/metadata.rb', line 5 def initialize(channel, consumer_tag, envelope, properties) @channel = channel @consumer_tag = consumer_tag @envelope = envelope @properties = properties # Prime the delivery tag when the instance is created. If #delivery_tag is first # called after a recovery, then it'll fail to mismatch and will allow an invalid # ack/nack, which will cause the channel to unexpectedly close @delivery_tag = delivery_tag end |
Instance Attribute Details
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
3 4 5 |
# File 'lib/march_hare/metadata.rb', line 3 def channel @channel end |
#consumer_tag ⇒ Object (readonly)
Returns the value of attribute consumer_tag.
3 4 5 |
# File 'lib/march_hare/metadata.rb', line 3 def consumer_tag @consumer_tag end |
#envelope ⇒ Object (readonly)
Returns the value of attribute envelope.
3 4 5 |
# File 'lib/march_hare/metadata.rb', line 3 def envelope @envelope end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
3 4 5 |
# File 'lib/march_hare/metadata.rb', line 3 def properties @properties end |
Instance Method Details
#ack(options = {}) ⇒ Object
17 18 19 |
# File 'lib/march_hare/metadata.rb', line 17 def ack(={}) @channel.basic_ack(delivery_tag, .fetch(:multiple, false)) end |
#delivery_tag ⇒ Object
37 38 39 |
# File 'lib/march_hare/metadata.rb', line 37 def delivery_tag @delivery_tag ||= VersionedDeliveryTag.new(@envelope.delivery_tag, @channel.recoveries_counter.get) end |
#headers ⇒ Object
62 63 64 |
# File 'lib/march_hare/metadata.rb', line 62 def headers deep_normalize_headers(@properties.headers) end |
#persistent? ⇒ Boolean
66 67 68 |
# File 'lib/march_hare/metadata.rb', line 66 def persistent? delivery_mode == 2 end |
#redelivered? ⇒ Boolean
70 71 72 |
# File 'lib/march_hare/metadata.rb', line 70 def redelivered? redeliver end |
#redelivery? ⇒ Boolean
74 75 76 |
# File 'lib/march_hare/metadata.rb', line 74 def redelivery? redeliver end |
#reject(options = {}) ⇒ Object
21 22 23 |
# File 'lib/march_hare/metadata.rb', line 21 def reject(={}) @channel.basic_reject(delivery_tag, .fetch(:requeue, false)) end |