Sha256: a445f9574682a1b46ab8bc9909594d65f28e6ab44f6e189499dba7338eb76f7e
Contents?: true
Size: 1.37 KB
Versions: 1
Compression:
Stored size: 1.37 KB
Contents
module Sidetiq # Public: Mixin for Sidekiq::Worker classes. # # Examples # # class MyWorker # include Sidekiq::Worker # include Sidetiq::Schedulable # # # Daily at midnight # tiq { daily } # end module Schedulable module ClassMethods # Public: Returns a Float timestamp of the last scheduled run. def last_scheduled_occurrence get_timestamp "last" end # Public: Returns a Float timestamp of the next scheduled run. def next_scheduled_occurrence get_timestamp "next" end def tiq(*args, &block) # :nodoc: Sidetiq.logger.warn "DEPRECATION WARNING: Sidetiq::Schedulable#tiq" << " is deprecated and will be removed. Use" << " Sidetiq::Schedulable#recurrence instead." recurrence(*args, &block) end def recurrence(options = {}, &block) # :nodoc: clock = Sidetiq::Clock.instance clock.mon_synchronize do schedule = clock.schedule_for(self) schedule.instance_eval(&block) schedule.set_options(options) end end private def get_timestamp(key) Sidekiq.redis do |redis| (redis.get("sidetiq:#{name}:#{key}") || -1).to_f end end end def self.included(klass) # :nodoc: klass.extend(Sidetiq::Schedulable::ClassMethods) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sidetiq-0.3.5 | lib/sidetiq/schedulable.rb |