Class: NSQ::Message

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection, id, timestamp_high, timestamp_low, attempts, body) ⇒ Message

Returns a new instance of Message.



5
6
7
8
9
10
11
12
# File 'lib/nsq/message.rb', line 5

def initialize(connection, id, timestamp_high, timestamp_low, attempts, body)
  @connection     = connection
  @id             = id
  @timestamp_high = timestamp_high
  @timestamp_low  = timestamp_low
  @attempts       = attempts
  @body           = body
end

Instance Attribute Details

#attemptsObject (readonly)

Returns the value of attribute attempts.



3
4
5
# File 'lib/nsq/message.rb', line 3

def attempts
  @attempts
end

#bodyObject (readonly)

Returns the value of attribute body.



3
4
5
# File 'lib/nsq/message.rb', line 3

def body
  @body
end

#connectionObject (readonly)

Returns the value of attribute connection.



3
4
5
# File 'lib/nsq/message.rb', line 3

def connection
  @connection
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/nsq/message.rb', line 3

def id
  @id
end

Instance Method Details

#timestampObject



14
15
16
17
18
# File 'lib/nsq/message.rb', line 14

def timestamp
  # TODO: Not really a nanosecond timestamp
  #Time.at((@timestamp_high * 2**32 + @timestamp_low) / 1000000000.0)
  Time.at(@timestamp_low)
end

#to_sObject



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

def to_s
  "#{connection} id=#{id} timestamp=#{timestamp} attempts=#{attempts} body=#{body}"
end