Class: Shoryuken::Middleware::Server::AutoExtendVisibility
- Inherits:
-
Object
- Object
- Shoryuken::Middleware::Server::AutoExtendVisibility
- Includes:
- Util
- Defined in:
- lib/shoryuken/middleware/server/auto_extend_visibility.rb
Overview
Middleware that automatically extends message visibility timeout during processing. Prevents messages from becoming visible to other consumers while still being processed.
Defined Under Namespace
Classes: MessageVisibilityExtender
Constant Summary collapse
- EXTEND_UPFRONT_SECONDS =
Number of seconds before timeout to extend visibility
5
Instance Method Summary collapse
-
#call(worker, queue, sqs_msg, body) { ... } ⇒ void
Processes a message with automatic visibility timeout extension.
Methods included from Util
#elapsed, #fire_event, #logger, #unparse_queues, #worker_name
Instance Method Details
#call(worker, queue, sqs_msg, body) { ... } ⇒ void
This method returns an undefined value.
Processes a message with automatic visibility timeout extension
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/shoryuken/middleware/server/auto_extend_visibility.rb', line 22 def call(worker, queue, sqs_msg, body) return yield unless worker.class.auto_visibility_timeout? if sqs_msg.is_a?(Array) logger.warn { "Auto extend visibility isn't supported for batch workers" } return yield end timer = auto_visibility_timer(worker, queue, sqs_msg, body) yield ensure timer.kill if timer end |