简体   繁体   English

如何确定使用delayed_jobs gem创建的作业的优先级?

[英]How do I prioritize a job created with the delayed_jobs gem?

I am using the delayed_job gem like this: 我正在使用delayed_job gem这样:

Delayed::Job.enqueue Note.new(parameter_hash)

The jobs are processed by Heroku workers. 这些工作由Heroku工作人员处理。 I need to prioritize some jobs. 我需要优先考虑一些工作。 I know there is a priority setting for delayed_job, but I'm not sure how to use it with the above job creation line. 我知道delayed_job有一个优先级设置,但我不确定如何将它与上述作业创建行一起使用。

How do I make a job higher priority? 我如何把工作放在更高的优先级?

According to the docs, by default jobs are scheduled with a priority of 0--which is the highest priority. 根据文档,默认情况下,作业的优先级为0 - 这是最高优先级。 In this case, lower numbers have higher priorities. 在这种情况下,较低的数字具有较高的优先级

To schedule some jobs at different priorities, use: 要按不同的优先级安排一些工作,请使用:

Delayed::Job.enqueue Note.new(parameter_hash), :priority => 10

Again, though, lower number = higher priority. 但是,较低的数字=较高的优先级。 A job with a priority of 0 is higher priority than one with 10. 优先级为0的作业优先级高于10的作业。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM