class Lambdakiq::Record
Attributes
data[R]
Public Class Methods
new(data)
click to toggle source
# File lib/lambdakiq/record.rb, line 6 def initialize(data) @data = data end
Public Instance Methods
attributes()
click to toggle source
# File lib/lambdakiq/record.rb, line 26 def attributes data['attributes'] end
body()
click to toggle source
# File lib/lambdakiq/record.rb, line 10 def body data['body'] end
fifo_delay_seconds()
click to toggle source
# File lib/lambdakiq/record.rb, line 34 def fifo_delay_seconds data.dig('messageAttributes', 'delay_seconds', 'stringValue').try(:to_i) end
fifo_delay_seconds?()
click to toggle source
# File lib/lambdakiq/record.rb, line 38 def fifo_delay_seconds? fifo_delay_seconds && (sent_at + fifo_delay_seconds).future? end
fifo_delay_visibility_timeout()
click to toggle source
# File lib/lambdakiq/record.rb, line 30 def fifo_delay_visibility_timeout fifo_delay_seconds - (Time.current - sent_at).to_i end
message_id()
click to toggle source
# File lib/lambdakiq/record.rb, line 14 def message_id data['messageId'] end
next_visibility_timeout()
click to toggle source
# File lib/lambdakiq/record.rb, line 53 def next_visibility_timeout @next_visibility_timeout ||= Backoff.backoff(receive_count) end
queue_name()
click to toggle source
# File lib/lambdakiq/record.rb, line 22 def queue_name @queue_name ||= data['eventSourceARN'].split(':').last end
receipt_handle()
click to toggle source
# File lib/lambdakiq/record.rb, line 18 def receipt_handle data['receiptHandle'] end
receive_count()
click to toggle source
# File lib/lambdakiq/record.rb, line 49 def receive_count @receive_count ||= attributes['ApproximateReceiveCount'].to_i end
sent_at()
click to toggle source
# File lib/lambdakiq/record.rb, line 42 def sent_at @sent_at ||= begin ts = attributes['SentTimestamp'].to_i / 1000 Time.zone ? Time.zone.at(ts) : Time.at(ts) end end