class Nsq::Message

Attributes

attempts[R]
body[R]
id[R]

Public Class Methods

new(data, connection) click to toggle source
Calls superclass method Nsq::Frame::new
# File lib/nsq/frames/message.rb, line 10
def initialize(data, connection)
  super
  ts_1, ts_2, @attempts, @id, @body = @data.unpack('NNs>a16a*')
  @timestamp_in_nanoseconds = (ts_1 * (2**32)) + ts_2
  @body.force_encoding('UTF-8')
end

Public Instance Methods

finish() click to toggle source
# File lib/nsq/frames/message.rb, line 17
def finish
  connection.fin(id)
end
requeue(timeout = 0) click to toggle source
# File lib/nsq/frames/message.rb, line 21
def requeue(timeout = 0)
  connection.req(id, timeout)
end
timestamp() click to toggle source
# File lib/nsq/frames/message.rb, line 29
def timestamp
  Time.at(@timestamp_in_nanoseconds / 1_000_000_000.0)
end
touch() click to toggle source
# File lib/nsq/frames/message.rb, line 25
def touch
  connection.touch(id)
end