Class: Reliable::Worker
- Inherits:
-
Object
- Object
- Reliable::Worker
- Extended by:
- Forwardable
- Defined in:
- lib/reliable/worker.rb
Instance Method Summary collapse
-
#initialize(queue, &block) ⇒ Worker
constructor
A new instance of Worker.
- #logger ⇒ Object
- #next ⇒ Object
- #notify(e, other = {}) ⇒ Object
- #processing ⇒ Object
Constructor Details
Instance Method Details
#next ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/reliable/worker.rb', line 21 def next uuid = @redis.brpoplpush pending.key, processing.key return if uuid.nil? item = @redis.get uuid if item catch(:failed) do process item, &@block @redis.lpop_and_del processing.key, uuid logger.info "Processed #{uuid}" end end item rescue StandardError => e @redis.rpoplpush processing.key, failed.key notify(e, uuid: uuid, worker: processing.key) nil end |
#notify(e, other = {}) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/reliable/worker.rb', line 55 def notify(e, other = {}) # TODO: make configurable logger.info e.inspect logger.info e.backtrace logger.info other.inspect end |