class Sidekiq::InterruptedSet
Constants
- DEFAULT_MAX_CAPACITY
- DEFAULT_MAX_TIMEOUT
Public Class Methods
max_jobs()
click to toggle source
# File lib/sidekiq/interrupted_set.rb, line 39 def self.max_jobs Sidekiq.options[:interrupted_max_jobs] || DEFAULT_MAX_CAPACITY end
new()
click to toggle source
Calls superclass method
# File lib/sidekiq/interrupted_set.rb, line 8 def initialize super "interrupted" end
timeout()
click to toggle source
# File lib/sidekiq/interrupted_set.rb, line 43 def self.timeout Sidekiq.options[:interrupted_timeout_in_seconds] || DEFAULT_MAX_TIMEOUT end
Public Instance Methods
put(message, opts = {})
click to toggle source
# File lib/sidekiq/interrupted_set.rb, line 12 def put(message, opts = {}) now = Time.now.to_f with_multi_connection(opts[:connection]) do |conn| conn.zadd(name, now.to_s, message) conn.zremrangebyscore(name, '-inf', now - self.class.timeout) conn.zremrangebyrank(name, 0, - self.class.max_jobs) end true end
retry_all()
click to toggle source
# File lib/sidekiq/interrupted_set.rb, line 35 def retry_all each(&:retry) while size > 0 end
with_multi_connection(conn) { |conn| ... }
click to toggle source
Yield block inside an existing multi connection or creates new one
# File lib/sidekiq/interrupted_set.rb, line 25 def with_multi_connection(conn, &block) return yield(conn) if conn Sidekiq.redis do |c| c.multi do |multi| yield(multi) end end end