activejob 6.0.0.beta1 → 6.0.1.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
  SHA256:
3
- metadata.gz: 4efdf023b31288a45487abbafc8fc37207c470167a9f2d770a5d3364e4a7c399
4
- data.tar.gz: e2476b972bf30c7bfb9cdce2ee2fb5018e2253d6b1bb28142dcbb169bf834c2d
3
+ metadata.gz: 84abc8e708f7bfb7ef9f115924370a1e482adeda57c4288790e33a5a4b8f1090
4
+ data.tar.gz: 0a5b9c4d638e9549768c4d41f4133715b5309f1983f05e40d129fcc271def350
5
5
  SHA512:
6
- metadata.gz: 2f5b5589be292b9df0693b61a38f8a1b5d8a8b88ecd4ec2eb22556f18fd8795fa7be9f447057626ed9f852bb543807a96eefa28989a27f16ee946a5e91550614
7
- data.tar.gz: 694d741cfd413f0bae6165706b5924a6cb5ae7a6240d5fc6d09c3cc1b4020d1fc3006ae154b932a3734126530b3ff112c29f56839ca9b630ab7ed467dda3f38a
6
+ metadata.gz: f1862412be6005f2e7186e7ce97eca4a3f0dbc4495bff03b1323530cd2fd6ccfdfd668c1edc71483f98090bb2b0186f36709df8836d54905ba670f4530d54e9b
7
+ data.tar.gz: 0f10b70d485333860da44f27de51749c5b43c9d47d93ab9f4d9255d53a6cb2771d379bed12004c4b95e86b093af4db65e0239837af87ebdc459ff6731e84bcc4
@@ -1,3 +1,41 @@
1
+ ## Rails 6.0.1.rc1 (October 31, 2019) ##
2
+
3
+ * No changes.
4
+
5
+
6
+ ## Rails 6.0.0 (August 16, 2019) ##
7
+
8
+ * `assert_enqueued_with` and `assert_performed_with` can now test jobs with relative delay.
9
+
10
+ *Vlado Cingel*
11
+
12
+
13
+ ## Rails 6.0.0.rc2 (July 22, 2019) ##
14
+
15
+ * No changes.
16
+
17
+
18
+ ## Rails 6.0.0.rc1 (April 24, 2019) ##
19
+
20
+ * Use individual execution counters when calculating retry delay.
21
+
22
+ *Patrik Bóna*
23
+
24
+ * Make job argument assertions with `Time`, `ActiveSupport::TimeWithZone`, and `DateTime` work by dropping microseconds. Microsecond precision is lost during serialization.
25
+
26
+ *Gannon McGibbon*
27
+
28
+
29
+ ## Rails 6.0.0.beta3 (March 11, 2019) ##
30
+
31
+ * No changes.
32
+
33
+
34
+ ## Rails 6.0.0.beta2 (February 25, 2019) ##
35
+
36
+ * No changes.
37
+
38
+
1
39
  ## Rails 6.0.0.beta1 (January 18, 2019) ##
2
40
 
3
41
  * Return false instead of the job instance when `enqueue` is aborted.
@@ -19,7 +57,7 @@
19
57
 
20
58
  *Edouard Chin*
21
59
 
22
- * Restore HashWithIndifferentAccess support to ActiveJob::Arguments.deserialize.
60
+ * Restore `HashWithIndifferentAccess` support to `ActiveJob::Arguments.deserialize`.
23
61
 
24
62
  *Gannon McGibbon*
25
63
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Active Job -- Make work happen later
1
+ # Active Job Make work happen later
2
2
 
3
3
  Active Job is a framework for declaring jobs and making them run on a variety
4
4
  of queuing backends. These jobs can be everything from regularly scheduled
@@ -17,12 +17,13 @@ about API differences between Delayed Job and Resque. Picking your queuing
17
17
  backend becomes more of an operational concern, then. And you'll be able to
18
18
  switch between them without having to rewrite your jobs.
19
19
 
20
+ You can read more about Active Job in the [Active Job Basics](https://edgeguides.rubyonrails.org/active_job_basics.html) guide.
20
21
 
21
22
  ## Usage
22
23
 
23
24
  To learn how to use your preferred queuing backend see its adapter
24
25
  documentation at
25
- [ActiveJob::QueueAdapters](http://api.rubyonrails.org/classes/ActiveJob/QueueAdapters.html).
26
+ [ActiveJob::QueueAdapters](https://api.rubyonrails.org/classes/ActiveJob/QueueAdapters.html).
26
27
 
27
28
  Declare a job like so:
28
29
 
@@ -86,7 +87,7 @@ by default has been mixed into Active Record classes.
86
87
 
87
88
  Active Job has built-in adapters for multiple queuing backends (Sidekiq,
88
89
  Resque, Delayed Job and others). To get an up-to-date list of the adapters
89
- see the API Documentation for [ActiveJob::QueueAdapters](http://api.rubyonrails.org/classes/ActiveJob/QueueAdapters.html).
90
+ see the API Documentation for [ActiveJob::QueueAdapters](https://api.rubyonrails.org/classes/ActiveJob/QueueAdapters.html).
90
91
 
91
92
  **Please note:** We are not accepting pull requests for new adapters. We
92
93
  encourage library authors to provide an ActiveJob adapter as part of
@@ -121,7 +122,7 @@ Active Job is released under the MIT license:
121
122
 
122
123
  API documentation is at:
123
124
 
124
- * http://api.rubyonrails.org
125
+ * https://api.rubyonrails.org
125
126
 
126
127
  Bug reports for the Ruby on Rails project can be filed here:
127
128
 
@@ -40,6 +40,9 @@ module ActiveJob
40
40
  # Timezone to be used during the job.
41
41
  attr_accessor :timezone
42
42
 
43
+ # Track when a job was enqueued
44
+ attr_accessor :enqueued_at
45
+
43
46
  # These methods will be included into any Active Job object, adding
44
47
  # helpers for de/serialization and creation of job instances.
45
48
  module ClassMethods
@@ -97,7 +100,8 @@ module ActiveJob
97
100
  "executions" => executions,
98
101
  "exception_executions" => exception_executions,
99
102
  "locale" => I18n.locale.to_s,
100
- "timezone" => Time.zone.try(:name)
103
+ "timezone" => Time.zone.try(:name),
104
+ "enqueued_at" => Time.now.utc.iso8601
101
105
  }
102
106
  end
103
107
 
@@ -137,6 +141,7 @@ module ActiveJob
137
141
  self.exception_executions = job_data["exception_executions"]
138
142
  self.locale = job_data["locale"] || I18n.locale.to_s
139
143
  self.timezone = job_data["timezone"] || Time.zone.try(:name)
144
+ self.enqueued_at = job_data["enqueued_at"]
140
145
  end
141
146
 
142
147
  private
@@ -67,7 +67,7 @@ module ActiveJob
67
67
  false
68
68
  else
69
69
  ActiveSupport::Deprecation.warn(
70
- "Rails 6.0 will return false when the enqueing is aborted. Make sure your code doesn't depend on it" \
70
+ "Rails 6.1 will return false when the enqueuing is aborted. Make sure your code doesn't depend on it" \
71
71
  " returning the instance of the job and set `config.active_job.return_false_on_aborted_enqueue = true`" \
72
72
  " to remove the deprecations."
73
73
  )
@@ -49,12 +49,10 @@ module ActiveJob
49
49
  # end
50
50
  def retry_on(*exceptions, wait: 3.seconds, attempts: 5, queue: nil, priority: nil)
51
51
  rescue_from(*exceptions) do |error|
52
- # Guard against jobs that were persisted before we started having individual executions counters per retry_on
53
- self.exception_executions ||= {}
54
- self.exception_executions[exceptions.to_s] = (exception_executions[exceptions.to_s] || 0) + 1
52
+ executions = executions_for(exceptions)
55
53
 
56
- if exception_executions[exceptions.to_s] < attempts
57
- retry_job wait: determine_delay(wait), queue: queue, priority: priority, error: error
54
+ if executions < attempts
55
+ retry_job wait: determine_delay(seconds_or_duration_or_algorithm: wait, executions: executions), queue: queue, priority: priority, error: error
58
56
  else
59
57
  if block_given?
60
58
  instrument :retry_stopped, error: error do
@@ -123,7 +121,7 @@ module ActiveJob
123
121
  end
124
122
 
125
123
  private
126
- def determine_delay(seconds_or_duration_or_algorithm)
124
+ def determine_delay(seconds_or_duration_or_algorithm:, executions:)
127
125
  case seconds_or_duration_or_algorithm
128
126
  when :exponentially_longer
129
127
  (executions**4) + 2
@@ -146,5 +144,14 @@ module ActiveJob
146
144
 
147
145
  ActiveSupport::Notifications.instrument("#{name}.active_job", payload, &block)
148
146
  end
147
+
148
+ def executions_for(exceptions)
149
+ if exception_executions
150
+ exception_executions[exceptions.to_s] = (exception_executions[exceptions.to_s] || 0) + 1
151
+ else
152
+ # Guard against jobs that were persisted before we started having individual executions counters per retry_on
153
+ executions
154
+ end
155
+ end
149
156
  end
150
157
  end
@@ -9,8 +9,8 @@ module ActiveJob
9
9
  module VERSION
10
10
  MAJOR = 6
11
11
  MINOR = 0
12
- TINY = 0
13
- PRE = "beta1"
12
+ TINY = 1
13
+ PRE = "rc1"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -70,7 +70,7 @@ module ActiveJob
70
70
  def perform_start(event)
71
71
  info do
72
72
  job = event.payload[:job]
73
- "Performing #{job.class.name} (Job ID: #{job.job_id}) from #{queue_name(event)}" + args_info(job)
73
+ "Performing #{job.class.name} (Job ID: #{job.job_id}) from #{queue_name(event)} enqueued at #{job.enqueued_at}" + args_info(job)
74
74
  end
75
75
  end
76
76
 
@@ -10,11 +10,11 @@ module ActiveJob
10
10
  # * {Que}[https://github.com/chanks/que]
11
11
  # * {queue_classic}[https://github.com/QueueClassic/queue_classic]
12
12
  # * {Resque}[https://github.com/resque/resque]
13
- # * {Sidekiq}[http://sidekiq.org]
13
+ # * {Sidekiq}[https://sidekiq.org]
14
14
  # * {Sneakers}[https://github.com/jondot/sneakers]
15
15
  # * {Sucker Punch}[https://github.com/brandonhilkert/sucker_punch]
16
- # * {Active Job Async Job}[http://api.rubyonrails.org/classes/ActiveJob/QueueAdapters/AsyncAdapter.html]
17
- # * {Active Job Inline}[http://api.rubyonrails.org/classes/ActiveJob/QueueAdapters/InlineAdapter.html]
16
+ # * {Active Job Async Job}[https://api.rubyonrails.org/classes/ActiveJob/QueueAdapters/AsyncAdapter.html]
17
+ # * {Active Job Inline}[https://api.rubyonrails.org/classes/ActiveJob/QueueAdapters/InlineAdapter.html]
18
18
  # * Please Note: We are not accepting pull requests for new adapters. See the {README}[link:files/activejob/README_md.html] for more details.
19
19
  #
20
20
  # === Backends Features
@@ -18,6 +18,26 @@ module ActiveJob
18
18
  # post.to_feed!
19
19
  # end
20
20
  # end
21
+ #
22
+ # Can be given a block that will evaluate in the context of the job
23
+ # allowing +self.arguments+ to be accessed so that a dynamic queue name
24
+ # can be applied:
25
+ #
26
+ # class PublishToFeedJob < ApplicationJob
27
+ # queue_as do
28
+ # post = self.arguments.first
29
+ #
30
+ # if post.paid?
31
+ # :paid_feeds
32
+ # else
33
+ # :feeds
34
+ # end
35
+ # end
36
+ #
37
+ # def perform(post)
38
+ # post.to_feed!
39
+ # end
40
+ # end
21
41
  def queue_as(part_name = nil, &block)
22
42
  if block_given?
23
43
  self.queue_name = block
@@ -353,7 +353,7 @@ module ActiveJob
353
353
  #
354
354
  #
355
355
  # The +args+ argument also accepts a proc which will get passed the actual
356
- # job's arguments. Your proc needs to returns a boolean value determining if
356
+ # job's arguments. Your proc needs to return a boolean value determining if
357
357
  # the job's arguments matches your expectation. This is useful to check only
358
358
  # for a subset of arguments.
359
359
  #
@@ -426,7 +426,7 @@ module ActiveJob
426
426
  # end
427
427
  #
428
428
  # The +args+ argument also accepts a proc which will get passed the actual
429
- # job's arguments. Your proc needs to returns a boolean value determining if
429
+ # job's arguments. Your proc needs to return a boolean value determining if
430
430
  # the job's arguments matches your expectation. This is useful to check only
431
431
  # for a subset of arguments.
432
432
  #
@@ -630,12 +630,27 @@ module ActiveJob
630
630
 
631
631
  def prepare_args_for_assertion(args)
632
632
  args.dup.tap do |arguments|
633
- arguments[:at] = arguments[:at].to_f if arguments[:at]
633
+ arguments[:at] = round_time_arguments(arguments[:at]) if arguments[:at]
634
+ arguments[:args] = round_time_arguments(arguments[:args]) if arguments[:args]
635
+ end
636
+ end
637
+
638
+ def round_time_arguments(argument)
639
+ case argument
640
+ when Time, ActiveSupport::TimeWithZone, DateTime
641
+ argument.change(usec: 0)
642
+ when Hash
643
+ argument.transform_values { |value| round_time_arguments(value) }
644
+ when Array
645
+ argument.map { |element| round_time_arguments(element) }
646
+ else
647
+ argument
634
648
  end
635
649
  end
636
650
 
637
651
  def deserialize_args_for_assertion(job)
638
652
  job.dup.tap do |new_job|
653
+ new_job[:at] = round_time_arguments(Time.at(new_job[:at])) if new_job[:at]
639
654
  new_job[:args] = ActiveJob::Arguments.deserialize(new_job[:args]) if new_job[:args]
640
655
  end
641
656
  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: 6.0.0.beta1
4
+ version: 6.0.1.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: 2019-01-18 00:00:00.000000000 Z
11
+ date: 2019-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 6.0.0.beta1
19
+ version: 6.0.1.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: 6.0.0.beta1
26
+ version: 6.0.1.rc1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: globalid
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -90,12 +90,15 @@ files:
90
90
  - lib/rails/generators/job/job_generator.rb
91
91
  - lib/rails/generators/job/templates/application_job.rb.tt
92
92
  - lib/rails/generators/job/templates/job.rb.tt
93
- homepage: http://rubyonrails.org
93
+ homepage: https://rubyonrails.org
94
94
  licenses:
95
95
  - MIT
96
96
  metadata:
97
- source_code_uri: https://github.com/rails/rails/tree/v6.0.0.beta1/activejob
98
- changelog_uri: https://github.com/rails/rails/blob/v6.0.0.beta1/activejob/CHANGELOG.md
97
+ bug_tracker_uri: https://github.com/rails/rails/issues
98
+ changelog_uri: https://github.com/rails/rails/blob/v6.0.1.rc1/activejob/CHANGELOG.md
99
+ documentation_uri: https://api.rubyonrails.org/v6.0.1.rc1/
100
+ mailing_list_uri: https://groups.google.com/forum/#!forum/rubyonrails-talk
101
+ source_code_uri: https://github.com/rails/rails/tree/v6.0.1.rc1/activejob
99
102
  post_install_message:
100
103
  rdoc_options: []
101
104
  require_paths:
@@ -111,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
114
  - !ruby/object:Gem::Version
112
115
  version: 1.3.1
113
116
  requirements: []
114
- rubygems_version: 3.0.1
117
+ rubygems_version: 3.0.3
115
118
  signing_key:
116
119
  specification_version: 4
117
120
  summary: Job framework with pluggable queues.