是否可以将参数传递给(resque-status)Resque::JobWithStatus?
我对 resque 还很陌生,但它看起来非常适合我的需求。
实际上,我正在尝试设置一个简单的测试应用程序,例如:
require 'resque'
require 'resque/job_with_status'
class WordAnalyzer < Resque::JobWithStatus
@queue = "word_analysis"
def self.perform(word)
puts "About to do heavy duty analysis on #{word}"
sleep 3 # fake analysis here
# this would be something impressive
puts "Finished with analysis on #{word}"
end
end
并通过不使用 resque-status 创建后台工作程序
WordAnalyzer.create(word)
,它可以完美运行(调用 enqueue 而不是创建工作程序)。 通过 resque-status,我得到了
参数数量错误(2 比 1) /.../resque_test/lib/word_analyzer.rb:6:在“执行”中 /.../.rvm/gems/ruby-1.9.2-p136/gems/resque-1.16.1/lib/resque/job.rb:127:in `执行'
我搜索了文档和代码,但是没有找到将参数传递给 resque-status 作业的正确方法。是否可以?
提前致谢。
I'm pretty new to resque, but it looks really good for my needs.
Actually, I'm trying to setup a simple test app like:
require 'resque'
require 'resque/job_with_status'
class WordAnalyzer < Resque::JobWithStatus
@queue = "word_analysis"
def self.perform(word)
puts "About to do heavy duty analysis on #{word}"
sleep 3 # fake analysis here
# this would be something impressive
puts "Finished with analysis on #{word}"
end
end
And creating a background worker by
WordAnalyzer.create(word)
Without resque-status, it works perfectly (with calling enqueue instead of creating the worker).
With resque-status, I get a
wrong number of arguments (2 for 1)
/.../resque_test/lib/word_analyzer.rb:6:in `perform'
/.../.rvm/gems/ruby-1.9.2-p136/gems/resque-1.16.1/lib/resque/job.rb:127:in `perform'
I've searched both docu and code, but didn't find the proper way of handing arguments to a resque-status job. Is it possible?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你应该
这样做并在执行方法中访问该单词
You should do
And access that word in perform method by