lib/lambda_punch/worker.rb in lambda_punch-0.0.5 vs lib/lambda_punch/worker.rb in lambda_punch-0.0.6
- old
+ new
@@ -24,21 +24,29 @@
#
def call(event_payload)
new(event_payload).call
end
- # The `@queue` object is the local process' reference to the application `LambdaPunch::Queue`
- # instance which does all the work in the applciation's scope.
+ # A safe and resilient way to call the remote queue.
#
- def queue
- @queue
+ def call_queue
+ queue.call
rescue DRb::DRbConnError
+ logger.error "Worker#call_queue => DRb::DRbConnError"
new_drb_queue
+ queue.call
end
private
+ # The `@queue` object is the local process' reference to the application `LambdaPunch::Queue`
+ # instance which does all the work in the applciation's scope.
+ #
+ def queue
+ @queue
+ end
+
def new_drb_queue
@queue = DRbObject.new_with_uri(Server.uri)
end
end
@@ -56,13 +64,13 @@
# also ensures any clean up is done. For example, closing file notifications.
#
def call
Timeout.timeout(timeout) { @notifier.process }
rescue Timeout::Error
- logger.debug "Worker#call => Function timeout reached."
+ logger.error "Worker#call => Function timeout reached."
ensure
@notifier.close
- self.class.queue.call
+ self.class.call_queue
end
private
# The Notifier's watch handler would set this instance variable to `true`. We also return `true`