Class: Wurk::Fetcher::Reliable::UnitOfWork
- Inherits:
-
Struct
- Object
- Struct
- Wurk::Fetcher::Reliable::UnitOfWork
- Defined in:
- lib/wurk/fetcher/reliable.rb
Overview
Carries the public queue key, the raw (still-JSON) job payload, and the capsule we use to reach Redis. ACK removes from the private list; requeue pushes back to the public queue head so the job is next pulled. LREM count=1 is idempotent for our payloads since each job’s JSON contains a unique ‘jid`.
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#job ⇒ Object
Returns the value of attribute job.
-
#queue ⇒ Object
Returns the value of attribute queue.
Instance Method Summary collapse
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config
37 38 39 |
# File 'lib/wurk/fetcher/reliable.rb', line 37 def config @config end |
#job ⇒ Object
Returns the value of attribute job
37 38 39 |
# File 'lib/wurk/fetcher/reliable.rb', line 37 def job @job end |
#queue ⇒ Object
Returns the value of attribute queue
37 38 39 |
# File 'lib/wurk/fetcher/reliable.rb', line 37 def queue @queue end |
Instance Method Details
#acknowledge ⇒ Object
38 39 40 41 42 |
# File 'lib/wurk/fetcher/reliable.rb', line 38 def acknowledge config.redis do |conn| conn.call('LREM', Reliable.private_queue_name(queue), 1, job) end end |
#queue_name ⇒ Object
44 45 46 |
# File 'lib/wurk/fetcher/reliable.rb', line 44 def queue_name queue.delete_prefix(Keys::QUEUE_PREFIX) end |
#requeue ⇒ Object
48 49 50 |
# File 'lib/wurk/fetcher/reliable.rb', line 48 def requeue config.redis { |conn| conn.call('RPUSH', queue, job) } end |