Class: Wurk::Middleware::InterruptHandler
- Inherits:
-
Object
- Object
- Wurk::Middleware::InterruptHandler
- Includes:
- ServerMiddleware
- Defined in:
- lib/wurk/middleware/interrupt_handler.rb
Overview
Server middleware. Catches Wurk::Job::Interrupted raised by an
IterableJob mid-iteration (or any cooperatively-cancelled job),
re-pushes the job to the head of its queue so it resumes from the
persisted cursor, and raises Wurk::JobRetry::Skip so the retry
layer treats this as a clean exit rather than an error.
The re-push uses LPUSH (head of queue) so the same job is the next
one to be fetched after restart. The job JSON is unchanged: cursor
state lives in the it-<jid> HASH (see IterableJob persistence),
not in the payload.
Auto-registered at the top of the server chain when this file is required. Top-of-chain is important: a downstream middleware must not swallow the Interrupted before we see it.
Spec: docs/target/sidekiq-free.md ยง10.3.
Instance Attribute Summary collapse
-
#config ⇒ Object
included
from ServerMiddleware
Returns the value of attribute config.
Instance Method Summary collapse
- #call(_job_instance, job, queue) ⇒ Object
- #logger ⇒ Object included from ServerMiddleware
- #redis ⇒ Object included from ServerMiddleware
- #redis_pool ⇒ Object included from ServerMiddleware
Instance Attribute Details
#config ⇒ Object Originally defined in module ServerMiddleware
Returns the value of attribute config.
Instance Method Details
#call(_job_instance, job, queue) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/wurk/middleware/interrupt_handler.rb', line 28 def call(_job_instance, job, queue) yield rescue Wurk::Job::Interrupted repush(job, queue) raise Wurk::JobRetry::Skip end |