Class: Delayed::Backend::Redis::Functions

Inherits:
Redis::Scripting::Module
  • Object
show all
Defined in:
lib/delayed/backend/redis/functions.rb

Instance Method Summary collapse

Constructor Details

#initialize(redis) ⇒ Functions

Returns a new instance of Functions.



8
9
10
# File 'lib/delayed/backend/redis/functions.rb', line 8

def initialize(redis)
  super(redis, File.dirname(__FILE__))
end

Instance Method Details

#bulk_update(action, ids, flavor, query, now) ⇒ Object



53
54
55
56
# File 'lib/delayed/backend/redis/functions.rb', line 53

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



33
34
35
# File 'lib/delayed/backend/redis/functions.rb', line 33

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



37
38
39
# File 'lib/delayed/backend/redis/functions.rb', line 37

def destroy_job(job_id, now)
  run(:destroy_job, [], [job_id, now.utc.to_f])
end

#enqueue(job_id, queue, strand, now) ⇒ Object



29
30
31
# File 'lib/delayed/backend/redis/functions.rb', line 29

def enqueue(job_id, queue, strand, now)
  run(:enqueue, [], [job_id, queue, strand, now.utc.to_f])
end

#fail_job(job_id) ⇒ Object



45
46
47
# File 'lib/delayed/backend/redis/functions.rb', line 45

def fail_job(job_id)
  run(:fail_job, [], [job_id])
end

#find_available(queue, limit, offset, min_priority, max_priority, now) ⇒ Object



20
21
22
# File 'lib/delayed/backend/redis/functions.rb', line 20

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



24
25
26
27
# File 'lib/delayed/backend/redis/functions.rb', line 24

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



12
13
14
15
16
17
18
# File 'lib/delayed/backend/redis/functions.rb', line 12

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



49
50
51
# File 'lib/delayed/backend/redis/functions.rb', line 49

def set_running(job_id)
  run(:set_running, [], [job_id])
end

#tickle_strand(job_id, strand, now) ⇒ Object



41
42
43
# File 'lib/delayed/backend/redis/functions.rb', line 41

def tickle_strand(job_id, strand, now)
  run(:tickle_strand, [], [job_id, strand, now.utc.to_f])
end