activejob 4.2.0.beta4 → 4.2.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b7f0d0bb6e1251caa7d81084bb08533b08fad421
4
- data.tar.gz: 68455756afb12ee46fd20d005339f53b429ffc06
3
+ metadata.gz: e0a61dc5a6408052bac810485af089a5c1477c39
4
+ data.tar.gz: af2e846dd9d0dfb548af8d181f30d8bb023c597f
5
5
  SHA512:
6
- metadata.gz: ad1b0d84c6ef53c2f1c9e0859d7dc1b4d1a08dd24f2eca11c181b433cfd318984216b63e9f32330f9bbabf5581a1e4c7f7d8dd897cebab16f40f3ab05a0c484c
7
- data.tar.gz: af98007efc01844df75eade2e77443043f543a120fbdc58319aa95340bcec5f5a1fac82162d098dff3de90e7fc2d680192d4094d8d41663d9de6f7425912c2f9
6
+ metadata.gz: 879f7096af7b18d69247b03177c43c580add3cca004f8bbaf478d44d50f30bea247a0a188f36100a072874d321312f50c2684e31ea781f0dedb265c2713fc415
7
+ data.tar.gz: 3f46dffac8950c8ddb2b120c1cc52ab14174d3b1782227de98edf91c75cc522471774a57f3bebee1fa1406aa624fdeb9406e42dc21dfb6195da0252f8c255198
data/README.md CHANGED
@@ -5,7 +5,7 @@ of queueing backends. These jobs can be everything from regularly scheduled
5
5
  clean-ups, to billing charges, to mailings. Anything that can be chopped up into
6
6
  small units of work and run in parallel, really.
7
7
 
8
- It also serves as the backend for ActionMailer's #deliver_later functionality
8
+ It also serves as the backend for Action Mailer's #deliver_later functionality
9
9
  that makes it easy to turn any mailing into a job for running later. That's
10
10
  one of the most common jobs in a modern web application: Sending emails outside
11
11
  of the request-response cycle, so the user doesn't have to wait on it.
@@ -26,7 +26,8 @@ Set the queue adapter for Active Job:
26
26
  ActiveJob::Base.queue_adapter = :inline # default queue adapter
27
27
  ```
28
28
  Note: To learn how to use your preferred queueing backend see its adapter
29
- documentation at ActiveJob::QueueAdapters.
29
+ documentation at
30
+ [ActiveJob::QueueAdapters](http://api.rubyonrails.org/classes/ActiveJob/QueueAdapters.html).
30
31
 
31
32
  Declare a job like so:
32
33
 
@@ -110,7 +111,7 @@ Source code can be downloaded as part of the Rails project on GitHub
110
111
 
111
112
  ## License
112
113
 
113
- ActiveJob is released under the MIT license:
114
+ Active Job is released under the MIT license:
114
115
 
115
116
  * http://www.opensource.org/licenses/MIT
116
117
 
@@ -128,5 +129,3 @@ Bug reports can be filed for the Ruby on Rails project here:
128
129
  Feature requests should be discussed on the rails-core mailing list here:
129
130
 
130
131
  * https://groups.google.com/forum/?fromgroups#!forum/rubyonrails-core
131
-
132
-
@@ -32,7 +32,7 @@ module ActiveJob #:nodoc:
32
32
  # end
33
33
  #
34
34
  # Records that are passed in are serialized/deserialized using Global
35
- # Id. More information can be found in Arguments.
35
+ # ID. More information can be found in Arguments.
36
36
  #
37
37
  # To enqueue a job to be performed as soon the queueing system is free:
38
38
  #
@@ -22,6 +22,8 @@ module ActiveJob
22
22
  define_callbacks :enqueue
23
23
  end
24
24
 
25
+ # These methods will be included into any Active Job object, adding
26
+ # callbacks for +perform+ and +enqueue+ methods.
25
27
  module ClassMethods
26
28
  # Defines a callback that will get called right before the
27
29
  # job's perform method is executed.
@@ -17,6 +17,8 @@ module ActiveJob
17
17
  attr_writer :queue_name
18
18
  end
19
19
 
20
+ # These methods will be included into any Active Job object, adding
21
+ # helpers for de/serialization and creation of job instances.
20
22
  module ClassMethods
21
23
  # Creates a new job instance from a hash created with +serialize+
22
24
  def deserialize(job_data)
@@ -48,8 +50,8 @@ module ActiveJob
48
50
  end
49
51
  end
50
52
 
51
- # Creates a new job instance. Takes as arguments the arguments that
52
- # will be passed to the perform method.
53
+ # Creates a new job instance. Takes the arguments that will be
54
+ # passed to the perform method.
53
55
  def initialize(*arguments)
54
56
  @arguments = arguments
55
57
  @job_id = SecureRandom.uuid
@@ -84,6 +86,3 @@ module ActiveJob
84
86
  end
85
87
  end
86
88
  end
87
-
88
-
89
-
@@ -4,6 +4,7 @@ module ActiveJob
4
4
  module Enqueuing
5
5
  extend ActiveSupport::Concern
6
6
 
7
+ # Includes the +perform_later+ method for job initialization.
7
8
  module ClassMethods
8
9
  # Push a job onto the queue. The arguments must be legal JSON types
9
10
  # (string, int, float, nil, true, false, hash or array) or
@@ -22,7 +23,7 @@ module ActiveJob
22
23
  end
23
24
  end
24
25
 
25
- # Reschedule the job to be re-executed. This is useful in combination
26
+ # Reschedules the job to be re-executed. This is useful in combination
26
27
  # with the +rescue_from+ option. When you rescue an exception from your job
27
28
  # you can ask Active Job to retry performing your job.
28
29
  #
@@ -37,6 +38,7 @@ module ActiveJob
37
38
  # rescue_from(ErrorLoadingSite) do
38
39
  # retry_job queue: :low_priority
39
40
  # end
41
+ #
40
42
  # def perform(*args)
41
43
  # # raise ErrorLoadingSite if cannot scrape
42
44
  # end
@@ -6,6 +6,7 @@ module ActiveJob
6
6
  extend ActiveSupport::Concern
7
7
  include ActiveSupport::Rescuable
8
8
 
9
+ # Includes methods for executing and performing jobs instantly.
9
10
  module ClassMethods
10
11
  # Performs the job immediately.
11
12
  #
@@ -8,7 +8,7 @@ module ActiveJob
8
8
  MAJOR = 4
9
9
  MINOR = 2
10
10
  TINY = 0
11
- PRE = "beta4"
11
+ PRE = "rc1"
12
12
 
13
13
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
14
14
  end
@@ -75,7 +75,7 @@ module ActiveJob
75
75
  def perform(event)
76
76
  info do
77
77
  job = event.payload[:job]
78
- "Performed #{job.class.name} from #{queue_name(event)} in #{event.duration.round(2).to_s}ms"
78
+ "Performed #{job.class.name} from #{queue_name(event)} in #{event.duration.round(2)}ms"
79
79
  end
80
80
  end
81
81
 
@@ -2,9 +2,12 @@ require 'active_job/queue_adapters/inline_adapter'
2
2
  require 'active_support/core_ext/string/inflections'
3
3
 
4
4
  module ActiveJob
5
+ # The <tt>ActionJob::QueueAdapter</tt> module is used to load the
6
+ # correct adapter. The default queue adapter is the :inline queue.
5
7
  module QueueAdapter #:nodoc:
6
8
  extend ActiveSupport::Concern
7
9
 
10
+ # Includes the setter method for changing the active queue adapter.
8
11
  module ClassMethods
9
12
  mattr_reader(:queue_adapter) { ActiveJob::QueueAdapters::InlineAdapter }
10
13
 
@@ -13,12 +13,13 @@ module ActiveJob
13
13
  # * {Sneakers}[https://github.com/jondot/sneakers]
14
14
  # * {Sucker Punch}[https://github.com/brandonhilkert/sucker_punch]
15
15
  #
16
- # #### Backends Features
16
+ # === Backends Features
17
17
  #
18
18
  # | | Async | Queues | Delayed | Priorities | Timeout | Retries |
19
19
  # |-------------------|-------|--------|-----------|------------|---------|---------|
20
20
  # | Backburner | Yes | Yes | Yes | Yes | Job | Global |
21
21
  # | Delayed Job | Yes | Yes | Yes | Job | Global | Global |
22
+ # | Qu | Yes | Yes | No | No | No | Global |
22
23
  # | Que | Yes | Yes | Yes | Job | No | Job |
23
24
  # | queue_classic | Yes | Yes | No* | No | No | No |
24
25
  # | Resque | Yes | Yes | Yes (Gem) | Queue | Global | Yes |
@@ -6,10 +6,10 @@ module ActiveJob
6
6
  #
7
7
  # Delayed::Job (or DJ) encapsulates the common pattern of asynchronously
8
8
  # executing longer tasks in the background. Although DJ can have many
9
- # storage backends one of the most used is based on Active Record.
9
+ # storage backends, one of the most used is based on Active Record.
10
10
  # Read more about Delayed Job {here}[https://github.com/collectiveidea/delayed_job].
11
11
  #
12
- # To use Delayed Job set the queue_adapter config to +:delayed_job+.
12
+ # To use Delayed Job, set the queue_adapter config to +:delayed_job+.
13
13
  #
14
14
  # Rails.application.config.active_job.queue_adapter = :delayed_job
15
15
  class DelayedJobAdapter
@@ -2,6 +2,7 @@ module ActiveJob
2
2
  module QueueName
3
3
  extend ActiveSupport::Concern
4
4
 
5
+ # Includes the ability to override the default queue name and prefix.
5
6
  module ClassMethods
6
7
  mattr_accessor(:queue_name_prefix)
7
8
  mattr_accessor(:default_queue_name) { "default" }
@@ -53,7 +53,7 @@ module ActiveJob
53
53
  end
54
54
  end
55
55
 
56
- # Assert that no job have been enqueued.
56
+ # Asserts that no jobs have been enqueued.
57
57
  #
58
58
  # def test_jobs
59
59
  # assert_no_enqueued_jobs
@@ -77,13 +77,21 @@ module ActiveJob
77
77
  end
78
78
 
79
79
  # Asserts that the number of performed jobs matches the given number.
80
+ # If no block is passed, <tt>perform_enqueued_jobs</tt>
81
+ # must be called around the job call.
80
82
  #
81
83
  # def test_jobs
82
84
  # assert_performed_jobs 0
83
- # HelloJob.perform_later('xavier')
85
+ #
86
+ # perform_enqueued_jobs do
87
+ # HelloJob.perform_later('xavier')
88
+ # end
84
89
  # assert_performed_jobs 1
85
- # HelloJob.perform_later('yves')
86
- # assert_performed_jobs 2
90
+ #
91
+ # perform_enqueued_jobs do
92
+ # HelloJob.perform_later('yves')
93
+ # assert_performed_jobs 2
94
+ # end
87
95
  # end
88
96
  #
89
97
  # If a block is passed, that block should cause the specified number of
@@ -102,7 +110,7 @@ module ActiveJob
102
110
  def assert_performed_jobs(number)
103
111
  if block_given?
104
112
  original_count = performed_jobs.size
105
- yield
113
+ perform_enqueued_jobs { yield }
106
114
  new_count = performed_jobs.size
107
115
  assert_equal original_count + number, new_count,
108
116
  "#{number} jobs expected, but #{new_count - original_count} were performed"
@@ -116,8 +124,11 @@ module ActiveJob
116
124
  #
117
125
  # def test_jobs
118
126
  # assert_no_performed_jobs
119
- # HelloJob.perform_later('matthew')
120
- # assert_performed_jobs 1
127
+ #
128
+ # perform_enqueued_jobs do
129
+ # HelloJob.perform_later('matthew')
130
+ # assert_performed_jobs 1
131
+ # end
121
132
  # end
122
133
  #
123
134
  # If a block is passed, that block should not cause any job to be performed.
@@ -137,7 +148,7 @@ module ActiveJob
137
148
 
138
149
  # Asserts that the job passed in the block has been enqueued with the given arguments.
139
150
  #
140
- # def assert_enqueued_job
151
+ # def test_assert_enqueued_with
141
152
  # assert_enqueued_with(job: MyJob, args: [1,2,3], queue: 'low') do
142
153
  # MyJob.perform_later(1,2,3)
143
154
  # end
@@ -166,7 +177,7 @@ module ActiveJob
166
177
  original_performed_jobs = performed_jobs.dup
167
178
  clear_performed_jobs
168
179
  args.assert_valid_keys(:job, :args, :at, :queue)
169
- yield
180
+ perform_enqueued_jobs { yield }
170
181
  matching_job = performed_jobs.any? do |job|
171
182
  args.all? { |key, value| value == job[key] }
172
183
  end
@@ -175,6 +186,17 @@ module ActiveJob
175
186
  queue_adapter.performed_jobs = original_performed_jobs + performed_jobs
176
187
  end
177
188
 
189
+ def perform_enqueued_jobs
190
+ @old_perform_enqueued_jobs = queue_adapter.perform_enqueued_jobs
191
+ @old_perform_enqueued_at_jobs = queue_adapter.perform_enqueued_at_jobs
192
+ queue_adapter.perform_enqueued_jobs = true
193
+ queue_adapter.perform_enqueued_at_jobs = true
194
+ yield
195
+ ensure
196
+ queue_adapter.perform_enqueued_jobs = @old_perform_enqueued_jobs
197
+ queue_adapter.perform_enqueued_at_jobs = @old_perform_enqueued_at_jobs
198
+ end
199
+
178
200
  def queue_adapter
179
201
  ActiveJob::Base.queue_adapter
180
202
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activejob
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0.beta4
4
+ version: 4.2.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-30 00:00:00.000000000 Z
11
+ date: 2014-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,26 +16,26 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 4.2.0.beta4
19
+ version: 4.2.0.rc1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 4.2.0.beta4
26
+ version: 4.2.0.rc1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: globalid
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.3.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.3.0
41
41
  description: Declare job classes that can be run by a variety of queueing backends.
@@ -87,17 +87,17 @@ require_paths:
87
87
  - lib
88
88
  required_ruby_version: !ruby/object:Gem::Requirement
89
89
  requirements:
90
- - - '>='
90
+ - - ">="
91
91
  - !ruby/object:Gem::Version
92
92
  version: 1.9.3
93
93
  required_rubygems_version: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - '>'
95
+ - - ">"
96
96
  - !ruby/object:Gem::Version
97
97
  version: 1.3.1
98
98
  requirements: []
99
99
  rubyforge_project:
100
- rubygems_version: 2.2.1
100
+ rubygems_version: 2.2.2
101
101
  signing_key:
102
102
  specification_version: 4
103
103
  summary: Job framework with pluggable queues.