设置sidekiq后,我观察到关于传递给Sidekiq::Client.push
方法的参数的奇怪行为
如果我self.class
作为 args 给出,那么我要么得到一个要么SystemStackError (stack level too deep)
服务器简单地挂断,然后不接受任何请求。
Sidekiq::Client.enqueue(ActivityWorker, self.id, self.class)
SystemStackError (stack level too deep):
actionpack (3.2.12) lib/action_dispatch/middleware/reloader.rb:70
Rendered /usr/local/rvm/gems/ruby-1.9.3-p194@restro/gems/actionpack-3.2.12/lib/action_dispatch/middleware/templates/rescues/_trace.erb (2.0ms)
Rendered /usr/local/rvm/gems/ruby-1.9.3-p194@restro/gems/actionpack-3.2.12/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (2.0ms)
Rendered /usr/local/rvm/gems/ruby-1.9.3-p194@restro/gems/actionpack-3.2.12/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (37.8ms)
但是,如果我给予self.class.name
,那么它可以正常工作。
Sidekiq::Client.enqueue(ActivityWorker, self.id, self.class.name)
我发现参数在传递给工作人员之前已被序列化,但我无法弄清楚这种情况。
这是我的工人班
class ActivityWorker
include Sidekiq::Worker
sidekiq_options queue: 'high', retry: false
def perform(res_id, res_class)
# do some activity
end
end