Skip to content

Commit 625baa6

Browse files
author
David Heinemeier Hansson
committed
Change the default adapter from inline to async
1 parent 7fe32d2 commit 625baa6

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

activejob/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
* Change the default adapter from inline to async. It's a better default as tests will then not mistakenly
2+
come to rely on behavior happening synchronously. This is especially important with things like jobs kicked off
3+
in Active Record lifecycle callbacks.
4+
5+
*DHH*
6+
7+
18
## Rails 5.0.0.beta2 (February 01, 2016) ##
29

310
* No changes.

activejob/lib/active_job/queue_adapter.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ module QueueAdapter #:nodoc:
1010

1111
included do
1212
class_attribute :_queue_adapter, instance_accessor: false, instance_predicate: false
13-
self.queue_adapter = :inline
13+
self.queue_adapter = :async
1414
end
1515

1616
# Includes the setter method for changing the active queue adapter.
1717
module ClassMethods
1818
# Returns the backend queue provider. The default queue adapter
19-
# is the +:inline+ queue. See QueueAdapters for more information.
19+
# is the +:async+ queue. See QueueAdapters for more information.
2020
def queue_adapter
2121
_queue_adapter
2222
end
2323

2424
# Specify the backend queue provider. The default queue adapter
25-
# is the +:inline+ queue. See QueueAdapters for more
25+
# is the +:async+ queue. See QueueAdapters for more
2626
# information.
2727
def queue_adapter=(name_or_adapter_or_class)
2828
self._queue_adapter = interpret_adapter(name_or_adapter_or_class)

guides/source/active_job_basics.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,12 @@ That's it!
109109
Job Execution
110110
-------------
111111

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

117119
### Backends
118120

0 commit comments

Comments
 (0)