module ClockworkWeb
Constants
- DISABLED_KEY
- HEARTBEAT_KEY
- LAST_RUNS_KEY
- STATUS_KEY
- VERSION
Attributes
Public Class Methods
Source
# File lib/clockwork_web.rb, line 36 def self.disable(job) if redis redis.sadd(DISABLED_KEY, job) true else false end end
Source
# File lib/clockwork_web.rb, line 53 def self.disabled_jobs if redis Set.new(redis.smembers(DISABLED_KEY)) else Set.new end end
Source
# File lib/clockwork_web.rb, line 27 def self.enable(job) if redis redis.srem(DISABLED_KEY, job) true else false end end
Source
# File lib/clockwork_web.rb, line 45 def self.enabled?(job) if redis !redis.sismember(DISABLED_KEY, job) else true end end
Source
# File lib/clockwork_web.rb, line 84 def self.heartbeat if redis heartbeat = Time.now.to_i if heartbeat % 10 == 0 prev_heartbeat = redis.getset(HEARTBEAT_KEY, heartbeat).to_i if prev_heartbeat >= heartbeat redis.setex(STATUS_KEY, 60, "multiple") end end end end
Source
# File lib/clockwork_web.rb, line 75 def self.last_heartbeat if redis timestamp = redis.get(HEARTBEAT_KEY) if timestamp Time.at(timestamp.to_i) end end end
Source
# File lib/clockwork_web.rb, line 61 def self.last_runs if redis Hash[redis.hgetall(LAST_RUNS_KEY).map { |job, timestamp| [job, Time.at(timestamp.to_i)] }.sort_by { |job, time| [time, job] }] else {} end end
Source
# File lib/clockwork_web.rb, line 100 def self.multiple? redis && redis.get(STATUS_KEY) == "multiple" end
Source
# File lib/clockwork_web.rb, line 96 def self.running? last_heartbeat && last_heartbeat > Time.now - running_threshold end
Source
# File lib/clockwork_web.rb, line 69 def self.set_last_run(job) if redis redis.hset(LAST_RUNS_KEY, job, Time.now.to_i) end end