1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
Ruby on Rails
Find a file
David Heinemeier Hansson c14cc48ed7 Update README.md
2014-05-19 12:08:03 +02:00
lib Add GlobalID support for serialization 2014-05-19 12:06:09 +02:00
test Add GlobalID support for serialization 2014-05-19 12:06:09 +02:00
activejob.gemspec Skeleton gem 2014-05-18 11:44:28 +02:00
CHANGELOG.md Skeleton gem 2014-05-18 11:44:28 +02:00
Gemfile Add GlobalID support for serialization 2014-05-19 12:06:09 +02:00
Gemfile.lock Add GlobalID support for serialization 2014-05-19 12:06:09 +02:00
MIT-LICENSE Skeleton gem 2014-05-18 11:44:28 +02:00
Rakefile Implemented delayed job 2014-05-19 11:41:04 +03:00
README.md Update README.md 2014-05-19 12:08:03 +02:00

Active Job -- Make work happen later

Active Job is a framework for declaring jobs and making them run on a variety of queueing backends. These jobs can be everything from regularly scheduled clean-ups, billing charges, or mailings. Anything that can be chopped up into small units of work and run in parallel, really.

It also serves as the backend for ActionMailer's #deliver_later functionality that makes it easy to turn any mailing into a job for running later. That's one of the most common jobs in a modern web application: Sending emails outside of the request-response cycle, so the user doesn't have to wait on it.

GlobalID support

Active Job supports GlobalID serialization for parameters. This makes it possible to pass live Active Record objects to your job instead of class/id pairs, which you then have to manually deserialize. Before, jobs would look like this:

class TrashableCleanupJob
  def self.perfom(trashable_class, trashable_id, depth)
    trashable = trashable_class.constantize.find(trashable_id)
    trashable.cleanup(depth)
  end
end

Now you can simply do:

class TrashableCleanupJob
  def self.perfom(trashable, depth)
    trashable.cleanup(depth)
  end
end

This works with any class that mixes in ActiveModel::GlobalIdentification, which by default has been mixed into Active Record classes.

Supported queueing systems

We currently have adapters for:

  • Resque 1.x
  • Sidekiq
  • Sucker Punch
  • Delayed Job

We would like to have adapters for:

  • beanstalkd
  • rabbitmq

Under development as a gem, targeted for Rails inclusion

Active Job is currently being developed in a separate repository until it's ready to be merged in with Rails. The current plan is to have Active Job be part of the Rails 4.2 release, but plans may change depending on when this framework stabilizes and feels ready.

License

Active Job is released under the MIT license: