Class: DispatchRider::QueueServices::AwsSqs::SqsReceivedMessage
- Inherits:
-
ReceivedMessage
- Object
- SimpleDelegator
- ReceivedMessage
- DispatchRider::QueueServices::AwsSqs::SqsReceivedMessage
- Defined in:
- lib/dispatch-rider/queue_services/aws_sqs/sqs_received_message.rb
Instance Attribute Summary collapse
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
-
#total_timeout ⇒ Object
readonly
Returns the value of attribute total_timeout.
Attributes inherited from ReceivedMessage
Instance Method Summary collapse
-
#extend_timeout(timeout) ⇒ Object
NOTE: Setting the visibility timeout resets the timeout to NOW and makes it visibility timeout this time Essentially resetting the timer on this message.
-
#initialize(message, raw_item, queue) ⇒ SqsReceivedMessage
constructor
A new instance of SqsReceivedMessage.
- #queue_name ⇒ Object
- #receive_count ⇒ Object
-
#return_to_queue ⇒ Object
We effectively return the item to the queue by setting the visibility timeout to zero.
- #sent_at ⇒ Object
Methods inherited from ReceivedMessage
Constructor Details
#initialize(message, raw_item, queue) ⇒ SqsReceivedMessage
Returns a new instance of SqsReceivedMessage.
7 8 9 10 11 12 |
# File 'lib/dispatch-rider/queue_services/aws_sqs/sqs_received_message.rb', line 7 def initialize(, raw_item, queue) @queue = queue @total_timeout = queue.visibility_timeout @start_time = Time.now super(, raw_item) end |
Instance Attribute Details
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
5 6 7 |
# File 'lib/dispatch-rider/queue_services/aws_sqs/sqs_received_message.rb', line 5 def start_time @start_time end |
#total_timeout ⇒ Object (readonly)
Returns the value of attribute total_timeout.
5 6 7 |
# File 'lib/dispatch-rider/queue_services/aws_sqs/sqs_received_message.rb', line 5 def total_timeout @total_timeout end |
Instance Method Details
#extend_timeout(timeout) ⇒ Object
NOTE: Setting the visibility timeout resets the timeout to NOW and makes it visibility timeout this time Essentially resetting the timer on this message
16 17 18 19 20 21 |
# File 'lib/dispatch-rider/queue_services/aws_sqs/sqs_received_message.rb', line 16 def extend_timeout(timeout) item.visibility_timeout = timeout if timeout > 0 @total_timeout = timeout + (Time.now - start_time).to_i end end |
#queue_name ⇒ Object
40 41 42 |
# File 'lib/dispatch-rider/queue_services/aws_sqs/sqs_received_message.rb', line 40 def queue_name @queue.arn.split(':').last end |
#receive_count ⇒ Object
32 33 34 |
# File 'lib/dispatch-rider/queue_services/aws_sqs/sqs_received_message.rb', line 32 def receive_count @item.approximate_receive_count end |
#return_to_queue ⇒ Object
We effectively return the item to the queue by setting the visibility timeout to zero. The item should become immediately visible. The next receiver will reset the visibility to something appropriate
28 29 30 |
# File 'lib/dispatch-rider/queue_services/aws_sqs/sqs_received_message.rb', line 28 def return_to_queue extend_timeout(0) end |
#sent_at ⇒ Object
36 37 38 |
# File 'lib/dispatch-rider/queue_services/aws_sqs/sqs_received_message.rb', line 36 def sent_at @item. end |