A wrapper for batch processes. It was designed to be used with an asynchronous library like delayed_job or resque. Code wrapped in a batchy block will have it's start and end time logged. Batchy will keep track of the current state of the batch from new to running to completion. Errors not handled in the batched code will be caught by batchy and logged. Callbacks can be defined for success, failure or both.
$ gem install batchy
Or if you're using bundler add batchy to your Gemfile and
$ bundle install
If you're using Rails, you can generate a migration with
$ rails generate batchy:active_record $ rake db:migrate
For a full list of configuration options, check the documentation.
Batchy.configure do | c | c.allow_duplicates = false c.raise_errors = false c.name_process = true c.process_name_prefix = "[BATCHY]" c.allow_mass_sigkill = false c.add_global_success_callback do | bch | # do something on success end c.add_global_failure_callback do | bch | # do something on failure end c.add_global_ensure_callback do | bch | # do something regardless of end state end end