module Sidecloq::Utils
Useful stuff
Public Class Methods
included(klass)
click to toggle source
# File lib/sidecloq/utils.rb, line 74 def self.included(klass) klass.extend(ClassMethods) end
Public Instance Methods
logger()
click to toggle source
# File lib/sidecloq/utils.rb, line 35 def logger @logger ||= ContextLogger.new( defined?(Sidekiq::Logging) ? 'Sidecloq' : {sidecloq: true} ) end
redis(&block)
click to toggle source
# File lib/sidecloq/utils.rb, line 41 def redis(&block) self.class.redis(&block) end
will_never_run(cronline)
click to toggle source
finds cron lines that are impossible, like '0 5 31 2 *' note: does not attempt to fully validate the cronline
# File lib/sidecloq/utils.rb, line 47 def will_never_run(cronline) # look for non-existent day of month split = cronline.split(/\s+/) if split.length > 3 && split[2] =~ /\d+/ && split[3] =~ /\d+/ month = split[3].to_i day = split[2].to_i # special case for leap-year detection return true if month == 2 && day <= 29 return !Date.valid_date?(0, month, day) else false end end