activejob 5.2.0.beta2 → 5.2.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activejob might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/CHANGELOG.md +19 -0
- data/MIT-LICENSE +1 -1
- data/README.md +2 -2
- data/lib/active_job.rb +1 -1
- data/lib/active_job/core.rb +10 -4
- data/lib/active_job/exceptions.rb +11 -1
- data/lib/active_job/gem_version.rb +1 -1
- data/lib/active_job/queue_adapter.rb +12 -18
- data/lib/active_job/queue_adapters/sidekiq_adapter.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 22740a6da98359f759282d65708730726ce4ccee566733c2c73a5bbf4811808d
|
4
|
+
data.tar.gz: '08bd369e143aec6108fcc72a3a4ec5eabccf28769c0ce856a5421d073cd25ceb'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ae6dc0ae85e69b66c1bbc0b1815a79aefcb7a846d690322df90cacceb87303494eca3999836953cf650e932161ae406e5bc9d95f65aef599029a101f88434a4
|
7
|
+
data.tar.gz: bd30c867a68f1d51c3440f944e465e391729dd3a735eaf2c279e0f01b66c698f949c8b108b2d7c2fb37d16bd68cb38d0be4aea1d612cb49b7cfd1a51188c6797
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
## Rails 5.2.0.rc1 (January 30, 2018) ##
|
2
|
+
|
3
|
+
* Allow block to be passed to `ActiveJob::Base.discard_on` to allow custom handling of discard jobs.
|
4
|
+
|
5
|
+
Example:
|
6
|
+
|
7
|
+
class RemoteServiceJob < ActiveJob::Base
|
8
|
+
discard_on(CustomAppException) do |job, exception|
|
9
|
+
ExceptionNotifier.caught(exception)
|
10
|
+
end
|
11
|
+
|
12
|
+
def perform(*args)
|
13
|
+
# Might raise CustomAppException for something domain specific
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
*Aidan Haran*
|
18
|
+
|
19
|
+
|
1
20
|
## Rails 5.2.0.beta2 (November 28, 2017) ##
|
2
21
|
|
3
22
|
* No changes.
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -100,7 +100,7 @@ The latest version of Active Job can be installed with RubyGems:
|
|
100
100
|
$ gem install activejob
|
101
101
|
```
|
102
102
|
|
103
|
-
Source code can be downloaded as part of the Rails project on GitHub
|
103
|
+
Source code can be downloaded as part of the Rails project on GitHub:
|
104
104
|
|
105
105
|
* https://github.com/rails/rails/tree/master/activejob
|
106
106
|
|
@@ -117,7 +117,7 @@ API documentation is at:
|
|
117
117
|
|
118
118
|
* http://api.rubyonrails.org
|
119
119
|
|
120
|
-
Bug reports
|
120
|
+
Bug reports for the Ruby on Rails project can be filed here:
|
121
121
|
|
122
122
|
* https://github.com/rails/rails/issues
|
123
123
|
|
data/lib/active_job.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright (c) 2014-
|
4
|
+
# Copyright (c) 2014-2018 David Heinemeier Hansson
|
5
5
|
#
|
6
6
|
# Permission is hereby granted, free of charge, to any person obtaining
|
7
7
|
# a copy of this software and associated documentation files (the
|
data/lib/active_job/core.rb
CHANGED
@@ -97,17 +97,23 @@ module ActiveJob
|
|
97
97
|
# ==== Examples
|
98
98
|
#
|
99
99
|
# class DeliverWebhookJob < ActiveJob::Base
|
100
|
+
# attr_writer :attempt_number
|
101
|
+
#
|
102
|
+
# def attempt_number
|
103
|
+
# @attempt_number ||= 0
|
104
|
+
# end
|
105
|
+
#
|
100
106
|
# def serialize
|
101
|
-
# super.merge('attempt_number' =>
|
107
|
+
# super.merge('attempt_number' => attempt_number + 1)
|
102
108
|
# end
|
103
109
|
#
|
104
110
|
# def deserialize(job_data)
|
105
111
|
# super
|
106
|
-
#
|
112
|
+
# self.attempt_number = job_data['attempt_number']
|
107
113
|
# end
|
108
114
|
#
|
109
|
-
# rescue_from(
|
110
|
-
# raise exception if
|
115
|
+
# rescue_from(Timeout::Error) do |exception|
|
116
|
+
# raise exception if attempt_number > 5
|
111
117
|
# retry_job(wait: 10)
|
112
118
|
# end
|
113
119
|
# end
|
@@ -61,18 +61,28 @@ module ActiveJob
|
|
61
61
|
# Discard the job with no attempts to retry, if the exception is raised. This is useful when the subject of the job,
|
62
62
|
# like an Active Record, is no longer available, and the job is thus no longer relevant.
|
63
63
|
#
|
64
|
+
# You can also pass a block that'll be invoked. This block is yielded with the job instance as the first and the error instance as the second parameter.
|
65
|
+
#
|
64
66
|
# ==== Example
|
65
67
|
#
|
66
68
|
# class SearchIndexingJob < ActiveJob::Base
|
67
69
|
# discard_on ActiveJob::DeserializationError
|
70
|
+
# discard_on(CustomAppException) do |job, exception|
|
71
|
+
# ExceptionNotifier.caught(exception)
|
72
|
+
# end
|
68
73
|
#
|
69
74
|
# def perform(record)
|
70
75
|
# # Will raise ActiveJob::DeserializationError if the record can't be deserialized
|
76
|
+
# # Might raise CustomAppException for something domain specific
|
71
77
|
# end
|
72
78
|
# end
|
73
79
|
def discard_on(exception)
|
74
80
|
rescue_from exception do |error|
|
75
|
-
|
81
|
+
if block_given?
|
82
|
+
yield self, exception
|
83
|
+
else
|
84
|
+
logger.error "Discarded #{self.class} due to a #{exception}. The original exception was #{error.cause.inspect}."
|
85
|
+
end
|
76
86
|
end
|
77
87
|
end
|
78
88
|
end
|
@@ -29,28 +29,22 @@ module ActiveJob
|
|
29
29
|
# Specify the backend queue provider. The default queue adapter
|
30
30
|
# is the +:async+ queue. See QueueAdapters for more
|
31
31
|
# information.
|
32
|
-
def queue_adapter=(
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
assign_adapter(name_or_adapter_or_class.to_s,
|
42
|
-
ActiveJob::QueueAdapters.lookup(name_or_adapter_or_class).new)
|
32
|
+
def queue_adapter=(name_or_adapter)
|
33
|
+
case name_or_adapter
|
34
|
+
when Symbol, String
|
35
|
+
queue_adapter = ActiveJob::QueueAdapters.lookup(name_or_adapter).new
|
36
|
+
assign_adapter(name_or_adapter.to_s, queue_adapter)
|
37
|
+
else
|
38
|
+
if queue_adapter?(name_or_adapter)
|
39
|
+
adapter_name = "#{name_or_adapter.class.name.demodulize.remove('Adapter').underscore}"
|
40
|
+
assign_adapter(adapter_name, name_or_adapter)
|
43
41
|
else
|
44
|
-
|
45
|
-
adapter_name = "#{name_or_adapter_or_class.class.name.demodulize.remove('Adapter').underscore}"
|
46
|
-
assign_adapter(adapter_name,
|
47
|
-
name_or_adapter_or_class)
|
48
|
-
else
|
49
|
-
raise ArgumentError
|
50
|
-
end
|
42
|
+
raise ArgumentError
|
51
43
|
end
|
52
44
|
end
|
45
|
+
end
|
53
46
|
|
47
|
+
private
|
54
48
|
def assign_adapter(adapter_name, queue_adapter)
|
55
49
|
self._queue_adapter_name = adapter_name
|
56
50
|
self._queue_adapter = queue_adapter
|
@@ -18,7 +18,7 @@ module ActiveJob
|
|
18
18
|
# Rails.application.config.active_job.queue_adapter = :sidekiq
|
19
19
|
class SidekiqAdapter
|
20
20
|
def enqueue(job) #:nodoc:
|
21
|
-
#Sidekiq::Client does not support symbols as keys
|
21
|
+
# Sidekiq::Client does not support symbols as keys
|
22
22
|
job.provider_job_id = Sidekiq::Client.push \
|
23
23
|
"class" => JobWrapper,
|
24
24
|
"wrapped" => job.class.to_s,
|
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: 5.2.0.
|
4
|
+
version: 5.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:
|
11
|
+
date: 2018-01-30 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: 5.2.0.
|
19
|
+
version: 5.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: 5.2.0.
|
26
|
+
version: 5.2.0.rc1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: globalid
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,8 +86,8 @@ homepage: http://rubyonrails.org
|
|
86
86
|
licenses:
|
87
87
|
- MIT
|
88
88
|
metadata:
|
89
|
-
source_code_uri: https://github.com/rails/rails/tree/v5.2.0.
|
90
|
-
changelog_uri: https://github.com/rails/rails/blob/v5.2.0.
|
89
|
+
source_code_uri: https://github.com/rails/rails/tree/v5.2.0.rc1/activejob
|
90
|
+
changelog_uri: https://github.com/rails/rails/blob/v5.2.0.rc1/activejob/CHANGELOG.md
|
91
91
|
post_install_message:
|
92
92
|
rdoc_options: []
|
93
93
|
require_paths:
|
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
104
|
version: 1.3.1
|
105
105
|
requirements: []
|
106
106
|
rubyforge_project:
|
107
|
-
rubygems_version: 2.
|
107
|
+
rubygems_version: 2.7.3
|
108
108
|
signing_key:
|
109
109
|
specification_version: 4
|
110
110
|
summary: Job framework with pluggable queues.
|