A batching framework
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
.gitignore
.ruby-gemset
.ruby-version
.travis.yml
Gemfile
MIT-LICENSE
README.rdoc
Rakefile
batchy.gemspec

README.rdoc

Batchy

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.

Installation

$ 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

Configuration

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