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
34 35 36 |
# File 'lib/wurk/fetcher/reliable.rb', line 34 def config @config end |
#job ⇒ Object
Returns the value of attribute job
34 35 36 |
# File 'lib/wurk/fetcher/reliable.rb', line 34 def job @job end |
#queue ⇒ Object
Returns the value of attribute queue
34 35 36 |
# File 'lib/wurk/fetcher/reliable.rb', line 34 def queue @queue end |
Instance Method Details
#acknowledge ⇒ Object
35 36 37 38 39 |
# File 'lib/wurk/fetcher/reliable.rb', line 35 def acknowledge config.redis do |conn| conn.call('LREM', Reliable.private_queue_name(queue), 1, job) end end |
#queue_name ⇒ Object
41 42 43 |
# File 'lib/wurk/fetcher/reliable.rb', line 41 def queue_name queue.delete_prefix(Keys::QUEUE_PREFIX) end |
#requeue ⇒ Object
45 46 47 |
# File 'lib/wurk/fetcher/reliable.rb', line 45 def requeue config.redis { |conn| conn.call('RPUSH', queue, job) } end |