Class: Nsq::Message
Instance Attribute Summary collapse
-
#attempts ⇒ Object
readonly
Returns the value of attribute attempts.
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Attributes inherited from Frame
Instance Method Summary collapse
- #finish ⇒ Object
-
#initialize(data, connection) ⇒ Message
constructor
A new instance of Message.
- #requeue(timeout = 0) ⇒ Object
- #timestamp ⇒ Object
- #touch ⇒ Object
Methods included from AttributeLogger
Constructor Details
#initialize(data, connection) ⇒ Message
Returns a new instance of Message.
10 11 12 13 14 |
# File 'lib/nsq/frames/message.rb', line 10 def initialize(data, connection) super @timestamp_in_nanoseconds, @attempts, @id, @body = @data.unpack('Q>S>a16a*') @body.force_encoding('UTF-8') end |
Instance Attribute Details
#attempts ⇒ Object (readonly)
Returns the value of attribute attempts.
6 7 8 |
# File 'lib/nsq/frames/message.rb', line 6 def attempts @attempts end |
#body ⇒ Object (readonly)
Returns the value of attribute body.
8 9 10 |
# File 'lib/nsq/frames/message.rb', line 8 def body @body end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/nsq/frames/message.rb', line 7 def id @id end |
Instance Method Details
#finish ⇒ Object
16 17 18 |
# File 'lib/nsq/frames/message.rb', line 16 def finish connection.fin(id) end |
#requeue(timeout = 0) ⇒ Object
20 21 22 |
# File 'lib/nsq/frames/message.rb', line 20 def requeue(timeout = 0) connection.req(id, timeout) end |
#timestamp ⇒ Object
28 29 30 |
# File 'lib/nsq/frames/message.rb', line 28 def Time.at(@timestamp_in_nanoseconds / 1_000_000_000.0) end |
#touch ⇒ Object
24 25 26 |
# File 'lib/nsq/frames/message.rb', line 24 def touch connection.touch(id) end |