lib/sidekiq/api.rb in sidekiq-6.4.2 vs lib/sidekiq/api.rb in sidekiq-6.5.0
- old
+ new
@@ -189,11 +189,11 @@
Sidekiq.redis do |conn|
conn.mget(keys).each_with_index do |value, idx|
stat_hash[dates[idx]] = value ? value.to_i : 0
end
end
- rescue Redis::CommandError
+ rescue RedisConnection.adapter::CommandError
# mget will trigger a CROSSSLOT error when run against a Cluster
# TODO Someone want to add Cluster support?
end
stat_hash
@@ -292,10 +292,14 @@
transaction.srem("queues", name)
end
end
end
alias_method :💣, :clear
+
+ def as_json(options = nil) # :nodoc:
+ {name: name} # 5336
+ end
end
##
# Encapsulates a pending job within a Sidekiq queue or
# sorted set.
@@ -440,11 +444,12 @@
def safe_load(content, default)
yield(*YAML.load(content))
rescue => ex
# #1761 in dev mode, it's possible to have jobs enqueued which haven't been loaded into
# memory yet so the YAML can't be loaded.
- Sidekiq.logger.warn "Unable to load YAML: #{ex.message}" unless Sidekiq.options[:environment] == "development"
+ # TODO is this still necessary? Zeitwerk reloader should handle?
+ Sidekiq.logger.warn "Unable to load YAML: #{ex.message}" unless Sidekiq.config[:environment] == "development"
default
end
def uncompress_backtrace(backtrace)
if backtrace.is_a?(Array)
@@ -468,11 +473,11 @@
attr_reader :score
attr_reader :parent
def initialize(parent, score, item)
super(item)
- @score = score
+ @score = Float(score)
@parent = parent
end
def at
Time.at(score).utc
@@ -585,10 +590,14 @@
Sidekiq.redis do |conn|
conn.unlink(name)
end
end
alias_method :💣, :clear
+
+ def as_json(options = nil) # :nodoc:
+ {name: name} # 5336
+ end
end
class JobSet < SortedSet
def schedule(timestamp, message)
Sidekiq.redis do |conn|
@@ -604,11 +613,11 @@
loop do
range_start = page * page_size + offset_size
range_end = range_start + page_size - 1
elements = Sidekiq.redis { |conn|
- conn.zrange name, range_start, range_end, with_scores: true
+ conn.zrange name, range_start, range_end, withscores: true
}
break if elements.empty?
page -= 1
elements.reverse_each do |element, score|
yield SortedEntry.new(self, score, element)
@@ -627,11 +636,11 @@
else
[score, score]
end
elements = Sidekiq.redis { |conn|
- conn.zrangebyscore(name, begin_score, end_score, with_scores: true)
+ conn.zrangebyscore(name, begin_score, end_score, withscores: true)
}
elements.each_with_object([]) do |element, result|
data, job_score = element
entry = SortedEntry.new(self, job_score, data)
@@ -756,14 +765,14 @@
def retry_all
each(&:retry) while size > 0
end
def self.max_jobs
- Sidekiq.options[:dead_max_jobs]
+ Sidekiq[:dead_max_jobs]
end
def self.timeout
- Sidekiq.options[:dead_timeout_in_seconds]
+ Sidekiq[:dead_timeout_in_seconds]
end
end
##
# Enumerates the set of Sidekiq processes which are actively working