Sha256: 93ec7a6621ed32f5d9fd0375ec05c75e74fdee91368d6f45118f266cbd975db0
Contents?: true
Size: 636 Bytes
Versions: 2
Compression:
Stored size: 636 Bytes
Contents
module SimpleWorker class RetryListener < AbstractListener include RedisSupport attr_reader :max_retries def initialize(redis, max_retries, namespace, jobid) @redis = redis @max_retries = max_retries @namespace = namespace @jobid = jobid @tracker = {} end def on_task_expire(hostname, task) # warning nil converted to 0 count = @tracker[task].to_i if count < max_retries fire_retry task @tracker[task] = (count + 1) end end private def fire_retry(task) @redis.rpush(tasks_key, task) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
simpleworker-0.1.1 | lib/simpleworker/retry_listener.rb |
simpleworker-0.1.0 | lib/simpleworker/retry_listener.rb |