Class: Wurk::Fetcher::Reliable::UnitOfWork

Inherits:
Struct
  • Object
show all
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

Instance Method Summary collapse

Instance Attribute Details

#configObject

Returns the value of attribute config

Returns:

  • (Object)

    the current value of config



34
35
36
# File 'lib/wurk/fetcher/reliable.rb', line 34

def config
  @config
end

#jobObject

Returns the value of attribute job

Returns:

  • (Object)

    the current value of job



34
35
36
# File 'lib/wurk/fetcher/reliable.rb', line 34

def job
  @job
end

#queueObject

Returns the value of attribute queue

Returns:

  • (Object)

    the current value of queue



34
35
36
# File 'lib/wurk/fetcher/reliable.rb', line 34

def queue
  @queue
end

Instance Method Details

#acknowledgeObject



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_nameObject



41
42
43
# File 'lib/wurk/fetcher/reliable.rb', line 41

def queue_name
  queue.delete_prefix(Keys::QUEUE_PREFIX)
end

#requeueObject



45
46
47
# File 'lib/wurk/fetcher/reliable.rb', line 45

def requeue
  config.redis { |conn| conn.call('RPUSH', queue, job) }
end