gpt4 book ai didi

ruby-on-rails - 使用Delayed::Job时使用ActiveJob设置优先级

转载 作者:行者123 更新时间:2023-12-04 22:39:56 25 4
gpt4 key购买 nike

使用ActiveJob排队作业时,如何设置延迟的作业优先级?

class GuestsCleanupJob < ApplicationJob
queue_as :high_priority

def perform(*guests)
# Do something later
end
end

最佳答案

我花了一段时间,但是我在Delayed::Job文档中找到了这种方法:

Delayed::Worker.queue_attributes = {
default: { priority: 11 },
high_priority: { priority: 1 },
low_priority: { priority: 75 }
}

我已将其添加到初始化程序中,并且只想共享(如果有其他人遇到此情况)!

关于ruby-on-rails - 使用Delayed::Job时使用ActiveJob设置优先级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50414865/

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