简体   繁体   English

Sidekiq + Rails:延迟的扩展默认工作程序

[英]Sidekiq + Rails: Delayed Extension Default Worker

I'm using Sidekiq in my Rails app to asynchronously perform some tasks. 我在Rails应用程序中使用Sidekiq异步执行一些任务。 I've created workers for some of my more complex operations, but there are a lot of simple cases where I call Class.delay.some_method . 我已经为一些更复杂的操作创建了工作程序,但是在很多简单的情况下,我将Class.delay.some_method I'd like to write tests to make sure these jobs are getting enqueued correctly. 我想编写测试以确保这些作业正确入队。

When I create a worker to perform these jobs, I can check the queueing by making assertions about SomeWorker.jobs in my specs. 当我创建一个工作人员来执行这些工作时,我可以通过在我的规格中对SomeWorker.jobs进行断言来检查队列。 Is there a way to do something similar when I call #delay on a class directly? 当我直接在类上调用#delay时,有没有办法做类似的事情? If it makes any difference, the class inherits from ActiveRecord::Base. 如果有什么不同,该类将从ActiveRecord :: Base继承。

assert_equal 1, Sidekiq::Extensions::DelayedClass.jobs.size

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

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