Class: Envoi::Restore::SQSMessageHandler
- Inherits:
-
Object
- Object
- Envoi::Restore::SQSMessageHandler
- Defined in:
- lib/envoi/restore/agent.rb
Instance Attribute Summary collapse
-
#event_handler ⇒ Object
Returns the value of attribute event_handler.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#message ⇒ Object
Returns the value of attribute message.
-
#queue_handler ⇒ Object
Returns the value of attribute queue_handler.
-
#worker_thread ⇒ Object
Returns the value of attribute worker_thread.
Instance Method Summary collapse
- #change_message_visibility_timeout(visibility_timeout) ⇒ Object
- #delete_message ⇒ Object
-
#initialize(args = {}) ⇒ SQSMessageHandler
constructor
A new instance of SQSMessageHandler.
- #process ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ SQSMessageHandler
Returns a new instance of SQSMessageHandler.
18 19 20 21 22 23 |
# File 'lib/envoi/restore/agent.rb', line 18 def initialize(args = {}) @logger = args[:logger] @queue_handler = args[:queue_handler] @message = args[:message] @event_handler = args[:event_handler] end |
Instance Attribute Details
#event_handler ⇒ Object
Returns the value of attribute event_handler.
15 16 17 |
# File 'lib/envoi/restore/agent.rb', line 15 def event_handler @event_handler end |
#logger ⇒ Object
Returns the value of attribute logger.
14 15 16 |
# File 'lib/envoi/restore/agent.rb', line 14 def logger @logger end |
#message ⇒ Object
Returns the value of attribute message.
15 16 17 |
# File 'lib/envoi/restore/agent.rb', line 15 def @message end |
#queue_handler ⇒ Object
Returns the value of attribute queue_handler.
15 16 17 |
# File 'lib/envoi/restore/agent.rb', line 15 def queue_handler @queue_handler end |
#worker_thread ⇒ Object
Returns the value of attribute worker_thread.
16 17 18 |
# File 'lib/envoi/restore/agent.rb', line 16 def worker_thread @worker_thread end |
Instance Method Details
#change_message_visibility_timeout(visibility_timeout) ⇒ Object
46 47 48 49 |
# File 'lib/envoi/restore/agent.rb', line 46 def (visibility_timeout) logger.debug { "Updating Visibility Timeout for Message #{.}..."} queue_handler.poller.(, visibility_timeout) end |
#delete_message ⇒ Object
51 52 53 54 |
# File 'lib/envoi/restore/agent.rb', line 51 def logger.debug { "Deleting Message #{.}..."} queue_handler.poller.() end |
#process ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/envoi/restore/agent.rb', line 25 def process msg_body_parsed = JSON.parse(.body) event = msg_body_parsed result = nil worker_thread = Thread.new(event, @event_handler, result) do result = @event_handler.process_event(event) end visibility_timeout = 5 new_visibility_timeout = 60 while worker_thread.alive? (new_visibility_timeout) sleep visibility_timeout end if result && result[:success] end end |