更新计划作业的参数
Update args of a scheduled job
我已经安排了工作
Worker.perform_at(time, args)
而且我可以获取预定的作业
job = Sidekiq::ScheduledSet.new.find_job(jid)
job.args # this is the args I passed above
我需要更新 args
,它将在调用时传递给工作人员,即更新 job.args
。我该怎么做?
这行不通:
job.args = new_args
Sidekiq::ScheduledSet.new.to_a[0] = job
嗯,更新任务不是取消任务并使用新参数创建新任务的方法:
job = Sidekiq::ScheduledSet.new.find_job(jid)
## time = job.time // Or just set time needed.
Sidekiq::Status.cancel jid
Worker.perform_at(time, new_args)
它还可以让您更轻松地调试和记录作业,因为当您 edit/update 它们在运行时可能会导致很难识别的错误。
我已经安排了工作
Worker.perform_at(time, args)
而且我可以获取预定的作业
job = Sidekiq::ScheduledSet.new.find_job(jid)
job.args # this is the args I passed above
我需要更新 args
,它将在调用时传递给工作人员,即更新 job.args
。我该怎么做?
这行不通:
job.args = new_args
Sidekiq::ScheduledSet.new.to_a[0] = job
嗯,更新任务不是取消任务并使用新参数创建新任务的方法:
job = Sidekiq::ScheduledSet.new.find_job(jid)
## time = job.time // Or just set time needed.
Sidekiq::Status.cancel jid
Worker.perform_at(time, new_args)
它还可以让您更轻松地调试和记录作业,因为当您 edit/update 它们在运行时可能会导致很难识别的错误。