¶ ↑
BackgroundLiteThis Rails plugin supersedes the background plugin, available here:
http://github.com/imedo/background/tree/master
It allows you to execute methods in a background task with a very intuitive and easy syntax. It is as easy as that:
class MyModel def complex_operation(argument) ... end background_method :complex_operation end
Now, whenever MyModel#complex_operation is called, it will be run in the background process.
Refer to the Class#background_method documentation for details.
¶ ↑
What this plugin isThis plugin is an easy-to-use interface for background processing frameworks. Theoretically, you can use it in combination with any of the messaging / background processing frameworks out there, though there are not many handlers implemented yet. However, implementing a handler is very easy.
¶ ↑
What this plugin is NOTThis plugin is NOT a background processing framework. To make it work efficiently, you need an existing framework installed and configured. Right now, support for the ActiveMessaging framework is implemented.
However, there is out-of-the-box support for using script/runner to perform background tasks, as well as forking.
¶ ↑
When to use it-
Your Rails process gets unresponsive due to some time-consuming task.
-
The task does not need to show an immediate effect.
¶ ↑
Features-
Background processing using multiple background processing frameworks.
-
Fallback processing, if your background processing framework isn’t responding correctly.
-
Works out-of-the-box with script/runner and forking and DRb.
-
Fallback handler that streams messages containing background tasks to disk, to later replay jobs that failed because of a temporary error.
-
Error reporting through different channels, depending on the task at hand.
-
Exception notification.
-
Stdout (useful for debugging).
-
Stderr (useful for debugging).
-
Silent, which swallows all exceptions.
-
-
Supported processing frameworks.
-
ActiveMessaging.
-
Resque
-
script/runner.
-
fork (works only on Unix-like environments).
-
DRb with an example runner in scripts/background_queue (not really suitable for production use)
-
others might follow (it’s really easy to write a handler).
-
-
Easy configuration, depending on the environment, in config/background.yml.
-
Ability to override the configuration per method.
¶ ↑
DependenciesThere are no dependencies besides ActiveSupport, which is required by Rails anyways.
¶ ↑
InstallationJust copy the background_lite folder into vendor/plugins, and you’re good to go.
¶ ↑
ConfigurationDepending on the background processing framework that you are using, you might have to do some configuration. See the documentation of the respective background handler for details.
Copyright © 2008-2010 imedo GmbH, released under the MIT license