gpt4 book ai didi

ruby - 带有 Resque : enqueuing jobs with uninteded arguments 的 ActiveJob

转载 作者:数据小太阳 更新时间:2023-10-29 08:03:11 26 4
gpt4 key购买 nike

尝试实现某种取消作业功能。为了destroy a job with Resque ,需要传递给它的特定参数。不过,我似乎错误地传递了意外信息。

enter image description here

我只希望参数值位于外括号内。我正在这样创建工作:

PhysicalServerProvisionJob.perform_later('123')                        

我希望能够:

Resque::Job.destroy(:default, PhysicalServerProvisionJob, '123')

但是由于传入了额外的信息,这是不可能的。如果这是不可避免的,是否有另一种方法来销毁特定的排队作业?

最佳答案

因为 Resque::Job.destroy 正在寻找所有参数的精确匹配,所以它对查找 ActiveJob 类没有帮助。

这是我为解决这个问题而编写的脚本:

# Pop jobs off the queue until there are no more
while job = Resque.reserve('default')
# Check this job for the ActiveJob class name we're looking for;
# if it does not match, push it back onto a different queue
unless job.args.to_s.include?('PhysicalServerProvisionJob')
Resque.push('another_queue', class: job.payload_class.to_s, args: job.args)
end
end

关于ruby - 带有 Resque : enqueuing jobs with uninteded arguments 的 ActiveJob,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35589052/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com