Class: Nsq::Message

Inherits:
Frame
  • Object
show all
Defined in:
lib/nsq/frames/message.rb

Instance Attribute Summary collapse

Attributes inherited from Frame

#connection, #data

Instance Method Summary collapse

Methods included from AttributeLogger

included

Constructor Details

#initialize(data, connection) ⇒ Message

Returns a new instance of Message.



11
12
13
14
15
# File 'lib/nsq/frames/message.rb', line 11

def initialize(data, connection)
  super
  @timestamp, @attempts, @id, @body = @data.unpack('Q>s>a16a*')
  @body.force_encoding('UTF-8')
end

Instance Attribute Details

#attemptsObject (readonly)

Returns the value of attribute attempts.



7
8
9
# File 'lib/nsq/frames/message.rb', line 7

def attempts
  @attempts
end

#bodyObject (readonly)

Returns the value of attribute body.



9
10
11
# File 'lib/nsq/frames/message.rb', line 9

def body
  @body
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/nsq/frames/message.rb', line 8

def id
  @id
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



6
7
8
# File 'lib/nsq/frames/message.rb', line 6

def timestamp
  @timestamp
end

Instance Method Details

#finishObject



17
18
19
# File 'lib/nsq/frames/message.rb', line 17

def finish
  connection.fin(id)
end

#requeue(timeout = 0) ⇒ Object



21
22
23
# File 'lib/nsq/frames/message.rb', line 21

def requeue(timeout = 0)
  connection.req(id, timeout)
end

#touchObject



25
26
27
# File 'lib/nsq/frames/message.rb', line 25

def touch
  connection.touch(id)
end