浩文 联系 关于本站 登录 注册
  • 关注新浪微博:
  • 关注微信公众号:

Sidekiq Github wiki 中文文档

计划作业

commit信息:Adding a small note saying the `average_scheduled_poll_interval` also applies to the "retry" queue in addition to the "scheduled" queue. I couldn't find this information elsewhere than in the code. | 提交者:jarthod | 提交时间:2020-11-07 | 版本:cb164e3

Sidekiq允许你安排作业执行的时间。你可以使用perform_in(interval_in_seconds, *args) 或者 perform_at(timestamp, *args) 而不是标准的 perform_async(*args):

MyWorker.perform_in(3.hours, 'mike', 1)
MyWorker.perform_at(3.hours.from_now, 'mike', 1)

例如,如果你想在用户注册之后三小时发给他们一个邮件,这将非常有用。排队之前的计划作业以便立即执行。

时区

Sidekiq的调度与时区无关。Sidekiq在时间戳参数上调用.to_f,这能避免了时区混乱。了解详情,请查看这些issue

检测新作业

Sidekiq的调度程序并精确。它默认大约每5秒检测一次计划作业。(在Sidekiq 5.1之前是15秒)。这也适用于retry队列(请参见错误支持)。你可以调整这个间隔。

Sidekiq.configure_server do |config|
  config.average_scheduled_poll_interval = 15
end

周期作业

Sidekiq 商业版支持周期作业。其他的第三方gem也有类似功能。

上一篇: 高级选项 下一篇: 延时扩展