Class: Delayed::Backend::Redis::Functions
- Inherits:
-
Redis::Scripting::Module
- Object
- Redis::Scripting::Module
- Delayed::Backend::Redis::Functions
- Defined in:
- lib/delayed/backend/redis/functions.rb
Instance Method Summary collapse
- #bulk_update(action, ids, flavor, query, now) ⇒ Object
- #create_singleton(job_id, queue, strand, now) ⇒ Object
- #destroy_job(job_id, now) ⇒ Object
- #enqueue(job_id, queue, strand, now) ⇒ Object
- #fail_job(job_id) ⇒ Object
- #find_available(queue, limit, offset, min_priority, max_priority, now) ⇒ Object
- #get_and_lock_next_available(worker_name, queue, min_priority, max_priority, now) ⇒ Object
-
#initialize(redis) ⇒ Functions
constructor
A new instance of Functions.
- #run_script(script, keys, argv) ⇒ Object
- #set_running(job_id) ⇒ Object
- #tickle_strand(job_id, strand, now) ⇒ Object
Constructor Details
#initialize(redis) ⇒ Functions
Returns a new instance of Functions.
6 7 8 |
# File 'lib/delayed/backend/redis/functions.rb', line 6 def initialize(redis) super(redis, File.dirname(__FILE__)) end |
Instance Method Details
#bulk_update(action, ids, flavor, query, now) ⇒ Object
51 52 53 54 |
# File 'lib/delayed/backend/redis/functions.rb', line 51 def bulk_update(action, ids, flavor, query, now) ids = (ids || []).join(",") run(:bulk_update, [], [action, ids, flavor, query, now.utc.to_f]) end |
#create_singleton(job_id, queue, strand, now) ⇒ Object
31 32 33 |
# File 'lib/delayed/backend/redis/functions.rb', line 31 def create_singleton(job_id, queue, strand, now) run(:enqueue, [], [job_id, queue, strand, now.utc.to_f, true]) end |
#destroy_job(job_id, now) ⇒ Object
35 36 37 |
# File 'lib/delayed/backend/redis/functions.rb', line 35 def destroy_job(job_id, now) run(:destroy_job, [], [job_id, now.utc.to_f]) end |
#enqueue(job_id, queue, strand, now) ⇒ Object
27 28 29 |
# File 'lib/delayed/backend/redis/functions.rb', line 27 def enqueue(job_id, queue, strand, now) run(:enqueue, [], [job_id, queue, strand, now.utc.to_f]) end |
#fail_job(job_id) ⇒ Object
43 44 45 |
# File 'lib/delayed/backend/redis/functions.rb', line 43 def fail_job(job_id) run(:fail_job, [], [job_id]) end |
#find_available(queue, limit, offset, min_priority, max_priority, now) ⇒ Object
18 19 20 |
# File 'lib/delayed/backend/redis/functions.rb', line 18 def find_available(queue, limit, offset, min_priority, max_priority, now) run(:find_available, [], [queue, limit, offset, min_priority, max_priority, now.utc.to_f]) end |
#get_and_lock_next_available(worker_name, queue, min_priority, max_priority, now) ⇒ Object
22 23 24 25 |
# File 'lib/delayed/backend/redis/functions.rb', line 22 def get_and_lock_next_available(worker_name, queue, min_priority, max_priority, now) attrs = run(:get_and_lock_next_available, [], [queue, min_priority, max_priority, worker_name, now.utc.to_f]) Hash[*attrs] end |
#run_script(script, keys, argv) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/delayed/backend/redis/functions.rb', line 10 def run_script(script, keys, argv) result = nil ms = Benchmark.ms { result = super } line = 'Redis Jobs Timing: %s (%.1fms)' % [script.name, ms] ActiveRecord::Base.logger.debug(line) result end |
#set_running(job_id) ⇒ Object
47 48 49 |
# File 'lib/delayed/backend/redis/functions.rb', line 47 def set_running(job_id) run(:set_running, [], [job_id]) end |
#tickle_strand(job_id, strand, now) ⇒ Object
39 40 41 |
# File 'lib/delayed/backend/redis/functions.rb', line 39 def tickle_strand(job_id, strand, now) run(:tickle_strand, [], [job_id, strand, now.utc.to_f]) end |