Skip to content
Permalink
Browse files

Change the default adapter from inline to async

  • Loading branch information
dhh committed Feb 5, 2016
1 parent 7fe32d2 commit 625baa69d14881ac49ba2e5c7d9cac4b222d7022
Showing with 16 additions and 7 deletions.
  1. +7 −0 activejob/CHANGELOG.md
  2. +3 −3 activejob/lib/active_job/queue_adapter.rb
  3. +6 −4 guides/source/active_job_basics.md
@@ -1,3 +1,10 @@
* Change the default adapter from inline to async. It's a better default as tests will then not mistakenly
come to rely on behavior happening synchronously. This is especially important with things like jobs kicked off
in Active Record lifecycle callbacks.

*DHH*


## Rails 5.0.0.beta2 (February 01, 2016) ##

* No changes.
@@ -10,19 +10,19 @@ module QueueAdapter #:nodoc:

included do
class_attribute :_queue_adapter, instance_accessor: false, instance_predicate: false
self.queue_adapter = :inline
self.queue_adapter = :async
end

# Includes the setter method for changing the active queue adapter.
module ClassMethods
# Returns the backend queue provider. The default queue adapter
# is the +:inline+ queue. See QueueAdapters for more information.
# is the +:async+ queue. See QueueAdapters for more information.
def queue_adapter
_queue_adapter
end

# Specify the backend queue provider. The default queue adapter
# is the +:inline+ queue. See QueueAdapters for more
# is the +:async+ queue. See QueueAdapters for more
# information.
def queue_adapter=(name_or_adapter_or_class)
self._queue_adapter = interpret_adapter(name_or_adapter_or_class)
@@ -109,10 +109,12 @@ That's it!
Job Execution
-------------

For enqueuing and executing jobs you need to set up a queuing backend, that is to
say you need to decide for a 3rd-party queuing library that Rails should use.
Rails itself does not provide a sophisticated queuing system and just executes the
job immediately if no adapter is set.
For enqueuing and executing jobs in production you need to set up a queuing backend,
that is to say you need to decide for a 3rd-party queuing library that Rails should use.
Rails itself only provides an in-process queuing system, which only keeps the jobs in RAM.
If the process crashes or the machine is reset, then all outstanding jobs are lost with the
default async back-end. This may be fine for smaller apps or non-critical jobs, but most
production apps will need to pick a persistent backend.

### Backends

0 comments on commit 625baa6

Please sign in to comment.
You can’t perform that action at this time.