Class: Wurk::Unique::ServerMiddleware
- Inherits:
-
Object
- Object
- Wurk::Unique::ServerMiddleware
- Includes:
- Middleware::ServerMiddleware
- Defined in:
- lib/wurk/unique.rb
Overview
Server middleware โ release lock per unique_until strategy.
:start โ DEL before perform. Lock-after-this-point not held; a
duplicate can be re-enqueued while the first runs.
:success โ DEL only on successful return. Retries keep the lock.
Spec ยง3.7: a raise during perform leaves the lock so
the retry can proceed; the TTL bounds the worst case.
Instance Attribute Summary
Attributes included from Middleware::ServerMiddleware
Instance Method Summary collapse
Methods included from Middleware::ServerMiddleware
Instance Method Details
#call(_worker, job, _queue) ⇒ Object
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 |
# File 'lib/wurk/unique.rb', line 332 def call(_worker, job, _queue) return yield unless Wurk::Unique.enabled? && Wurk::Unique.coerce_ttl(job['unique_for']) mode = unique_until(job) key = Wurk::Unique.lock_key_for(job) if mode == :start release(key, job['jid']) yield else result = yield release(key, job['jid']) result end end |