gpt4 book ai didi

ruby-on-rails - ActiveJob 是否有具有特定优先级的队列?

转载 作者:数据小太阳 更新时间:2023-10-29 06:46:55 25 4
gpt4 key购买 nike

查看下面的作业,我假设该作业在 low_priority 队列上运行。

class GuestsCleanupJob < ActiveJob::Base
queue_as :low_priority
#....
end

我同意这一点,但这只是队列的名称对吗?它实际上与优先级无关。例如,如果我创建了一个队列名为 :my_queue 的作业,它将被视为具有与 :low_priority 队列相同的优先级。

从文档中我无法找到任何表明我可以对排队的作业进行优先排序的信息。我知道 delayed_jobs 有这个功能,但我在 active_job 中没有找到它。

最佳答案

优先级取决于实际的 QueueAdapter 以及此适配器的配置方式。如果您的适配器不支持优先级或未正确配置,则 ActiveJob 也无法帮助您。

从这里找到有关适配器的更多详细信息:

http://edgeapi.rubyonrails.org/classes/ActiveJob/QueueAdapters.html

主要内容是:

The main point is to ensure that all Rails apps will have a job infrastructure in place. We can then have framework features and other gems build on top of that, without having to worry about API differences between various job runners such as Delayed Job and Resque. Picking your queuing backend becomes more of an operational concern, then. And you'll be able to switch between them without having to rewrite your jobs.

队列配置(包括优先级)成为 Adapter 的责任。

作为队列配置的示例,请参阅 Sidekiq wiki:

https://github.com/mperham/sidekiq/wiki/Advanced-Options#queues

关于ruby-on-rails - ActiveJob 是否有具有特定优先级的队列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32480865/

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