Class: SpotBuild::SqsEvent
- Inherits:
-
Object
- Object
- SpotBuild::SqsEvent
- Defined in:
- lib/spot_build/sqs_event.rb
Instance Method Summary collapse
-
#initialize(url:, timeout:, region: ENV['AWS_REGION']) ⇒ SqsEvent
constructor
A new instance of SqsEvent.
- #shutdown_if_required(&block) ⇒ Object
Constructor Details
#initialize(url:, timeout:, region: ENV['AWS_REGION']) ⇒ SqsEvent
Returns a new instance of SqsEvent.
6 7 8 9 |
# File 'lib/spot_build/sqs_event.rb', line 6 def initialize(url:, timeout:, region: ENV['AWS_REGION']) @queue = Aws::SQS::Queue.new(url: url, region: region) @timeout = timeout end |
Instance Method Details
#shutdown_if_required(&block) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/spot_build/sqs_event.rb', line 11 def shutdown_if_required(&block) # Any message to this queue is treated as a "I should shutdown" = @queue.( attribute_names: ["All"], max_number_of_messages: 1, visibility_timeout: (@timeout - 5), ).first return false if .nil? yield .delete true end |