Rails 3是否具有内置的merb的run_later函数?

时间:2021-10-18 12:00:17

I want to do background processing using closures. I don't care if the app crashes in the middle of this, as it will be idempotent and have many opportunities to be run, so it doesn't need a heavy-weight solution like Starling. In merb, I was able to do this with:

我想使用闭包进行后台处理。我不关心应用程序是否在此中间崩溃,因为它将是幂等的并且有很多机会可以运行,因此它不需要像Starling这样的重量级解决方案。在merb中,我能够做到这一点:

data_to_process = get_that_data
run_later do
  # process data in the data_to_process variable
end
# do work that needs to be responsive and
# doesn't depend on the processing of data_to_process

Is there an equivalent built in to Rails 3, or do I need to use one of the myriad plugins that were written to do something like that for Rails 2.2 and later? If I have to use a plugin for this kind of thing, which one is best for this use? It should ideally require no configuration and should take closures, as above.

是否有Rails 3内置的等价物,或者我是否需要使用为Rails 2.2及更高版本编写类似内容的无数插件之一?如果我必须使用插件来做这种事情,哪一个最适合这种用途?理想情况下,它应该不需要配置,并且应该采用闭包,如上所述。

2 个解决方案

#1


1  

For running things at a later time, delayed_job is the community standard. I would recommend learning how to use this and apply it to your situation.

对于以后运行的东西,delayed_job是社区标准。我建议学习如何使用它并将其应用到您的情况。

#2


2  

run_later port to Rails 3: https://github.com/jkraemer/run_later

run_later port to Rails 3:https://github.com/jkraemer/run_later

#1


1  

For running things at a later time, delayed_job is the community standard. I would recommend learning how to use this and apply it to your situation.

对于以后运行的东西,delayed_job是社区标准。我建议学习如何使用它并将其应用到您的情况。

#2


2  

run_later port to Rails 3: https://github.com/jkraemer/run_later

run_later port to Rails 3:https://github.com/jkraemer/run_later