sidekiq 再試行の削除と再試行の違い
削除はJobを削除する
強制終了はデッドジョブにする
デッドジョブは再試行ができるので、一応削除じゃなくて強制終了の方がよさそう
コードを追う
code:ruby
post "/retries" do
redirect(request.path) unless params"key" params"key".each do |key| job = Sidekiq::RetrySet.new.fetch(*parse_params(key)).first
retry_or_delete_or_kill job, params if job
end
redirect_with_query("#{root_path}retries")
end
code:ruby
def retry_or_delete_or_kill(job, params)
job.retry
job.delete
job.kill
end
end
このjobのreceiverはSortedEntry
code:ruby
# Fetch jobs that match a given time or Range. Job ID is an
# optional second argument.
#
# @param score Time,Range a specific timestamp or range def fetch(score, jid = nil)
begin_score, end_score =
if score.is_a?(Range)
else
end
elements = Sidekiq.redis { |conn|
conn.zrange(name, begin_score, end_score, "BYSCORE", "withscores")
}
elements.each_with_object([]) do |element, result|
data, job_score = element
entry = SortedEntry.new(self, job_score, data)
result << entry if jid.nil? || entry.jid == jid
end
end
code:ruby
class SortedEntry < JobRecord
# remove this entry from the sorted set
def delete
if @value
@parent.delete_by_value(@parent.name, @value)
else
@parent.delete_by_jid(score, jid)
end
end
# Move this job from its current set into the Dead set.
def kill
remove_job do |message|
DeadSet.new.kill(message)
end
end
end
yana-gi.icon 大体名前から検討はつくけど、こういう時にちゃんとソースコード見にいくようにしたい