active_job_resque_solo 0.3.7 → 1.0.2

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
- SHA1:
3
- metadata.gz: 72502b86b6c49cfeb92e359f9340a3737dba7981
4
- data.tar.gz: e03691514ce1c21284e3387046cec327b6231ccd
2
+ SHA256:
3
+ metadata.gz: 126eccd94fe2707054d3f71df759356195a2a35384d1e23f4e41e372e9018689
4
+ data.tar.gz: 9057a3920c53718249521315d5fa14768c449a4ee3fe2515528330f94ff7badb
5
5
  SHA512:
6
- metadata.gz: 33698ec7e0d40e624378bd4d46d90b2becb2ec92a731a0752b9f1accd709135f33ce4fe523e1b0afbeabc0ddd96a2319758d1ff8b0164f0442e8233b492818ad
7
- data.tar.gz: 58dfa53e53233c4eeda6359ad2e07bf31bc6a14643c2647da9e932c35824a3dc01b01d4780e33718440dc5acbf7fe75cac4872953e9e40264d848e45101f34bc
6
+ metadata.gz: 202daaa606d4210ffbec4cfd40f8205a31f2bfc3eb9117da4aad29cb78f7edb7f9a22a39fd2b272c2ea9f8ddcd58df7afbad63751fcbb0b2618b7ad9fe070d8b
7
+ data.tar.gz: af1ae2f42cfb0ea09ad8b501bada453c5e1d58216cc8cbf79aaa4cb9b12dfdcabea1b9ee4108a99367eceef3ce4a27ea87285e9d69cbf3faf24745c88b0fa0ff
data/.travis.yml CHANGED
@@ -1,8 +1,9 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.2.0
5
- - 2.3.0
6
- - 2.4.0
4
+ - 2.5.7
5
+ - 2.6.0
6
+ - 2.7.0
7
+ - 3.0.1
7
8
  - ruby-head
8
- before_install: gem install bundler -v 1.15.4
9
+ before_install: gem install bundler -v "$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1)"
data/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ # 1.0.2
2
+ * If a worker is processing a job that does not have ActiveJob arguments, allow it to be enqueued rather than failing with an error. This happens if a job has been queued by Resque directly without ActiveJob.
3
+
4
+ # 1.0.1
5
+
6
+ * Allow Rails 6.
7
+
8
+ # 1.0.0
9
+
10
+ * Breaking change: Allow a job to reschedule itself while it executing but not enqueued.
11
+ * Adds `solo_self_enqueueing` as an option to control the re-enqueueing behavior. Use `solo_self_enqueueing :prevent` for the behavior prior to version 1.0.0.
12
+
13
+ # 0.3.9
14
+
15
+ * Add CI test for Ruby 2.5.0.
16
+
17
+ # 0.3.8
18
+
19
+ * Fix bug that caused ActiveJobResqueSolo to fail to realize that the Rails app was configured for Resque.
20
+
1
21
  # 0.3.7
2
22
 
3
23
  * Fix bug that would prevent resque-scheduler from enqueuing jobs with no arguments.
data/README.md CHANGED
@@ -77,7 +77,7 @@ end
77
77
  ```
78
78
 
79
79
  Specify `solo_any_args` to allow only one instance of your job to be enqueued or executing at any given
80
- time regardless of the arugments used in each instance.
80
+ time regardless of the arguments used in each instance.
81
81
 
82
82
  `solo_any_args` overrides `solo_only_args` and `solo_except_args`.
83
83
 
@@ -119,6 +119,29 @@ class MyJob < ActiveJob::Base
119
119
  end
120
120
  ```
121
121
 
122
+ ## Re-enqueueing from within the job
123
+
124
+ The default behavior of this gem allows a Job to re-enqueue itself while it is
125
+ executing. If you know that your job should not be re-enqueueing itself, you can
126
+ prevent inadvertent re-enqueueing of the job by using `solo_self_enqueueing :prevent`.
127
+
128
+ Jobs that `fail` or `raise` an error may be retried by the framework, and are not
129
+ affected by this option.
130
+
131
+ ```ruby
132
+ class MyJob < ActiveJob::Base
133
+
134
+ include ActiveJob::Plugins::Resque::Solo
135
+
136
+ solo_self_enqueueing :prevent
137
+
138
+ def perform(*args)
139
+ MyJob.perform_later # <== this will not enqueue a job because of :prevent, above.
140
+ raise MyError # <== retries are still allowed
141
+ end
142
+ end
143
+ ```
144
+
122
145
  ## Duplicate enqueues are possible
123
146
 
124
147
  While this plugin will greatly reduce duplicate instances of a job from being
@@ -126,6 +149,10 @@ enqueued, a job may be enqueued multiple times if the Redis response times are
126
149
  very slow. Slowness could be caused by extremely high load on Redis or networking
127
150
  issues.
128
151
 
152
+ Since duplicate enqueueing of jobs is a possibility, make sure that that your code
153
+ does not rely on this gem for sensitive, critical sections of code that must not
154
+ be processed more than once.
155
+
129
156
  The locks are acquired for dynamic amounts of time, but expire quickly, typically
130
157
  in one second. Killed workers will not leave long-lived, orphaned locks to
131
158
  adversely block jobs from being enqueued.
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.required_ruby_version = ">= 2.2.0"
26
26
 
27
- spec.add_dependency "rails", ">= 4.2.0", "< 6"
27
+ spec.add_dependency "rails", ">= 4.2.0"
28
28
 
29
29
  spec.add_development_dependency "byebug"
30
30
  spec.add_development_dependency "bundler"
@@ -29,7 +29,7 @@ module ActiveJob
29
29
  end
30
30
 
31
31
  def solo_inspector
32
- @solo_inspector ||= Inspector.new(@solo_any_args, @solo_only_args, @solo_except_args, @solo_lock_key_prefix)
32
+ @solo_inspector ||= Inspector.new(@solo_any_args, @solo_only_args, @solo_except_args, @solo_lock_key_prefix, @solo_self_enqueueing)
33
33
  end
34
34
 
35
35
  def solo_lock_key_prefix(key_prefix)
@@ -37,6 +37,11 @@ module ActiveJob
37
37
  raise ArgumentError, "solo_lock_key_prefix cannot be blank or only spaces." if @solo_lock_key_prefix.blank?
38
38
 
39
39
  end
40
+
41
+ def solo_self_enqueueing(setting)
42
+ raise ArgumentError, "solo_self_enqueueing may only be set to :allow or :prevent." unless [:allow, :prevent].include?(setting)
43
+ @solo_self_enqueueing = (setting == :allow)
44
+ end
40
45
  end
41
46
  end
42
47
  end
@@ -8,17 +8,18 @@ module ActiveJob
8
8
  module Solo
9
9
  class Inspector
10
10
 
11
- def initialize(any_args, only_args, except_args, lock_key_prefix)
11
+ def initialize(any_args, only_args, except_args, lock_key_prefix, self_enqueuing)
12
12
  @any_args = !!any_args
13
13
  @only_args = only_args
14
14
  @except_args = except_args || []
15
15
  # always ignore the ActiveJob symbol hash key.
16
16
  @except_args << "_aj_symbol_keys" unless @except_args.include?("_aj_symbol_keys")
17
17
  @lock_key_prefix = lock_key_prefix.present? ? lock_key_prefix : "ajr_solo"
18
+ @self_enqueueing = self_enqueuing
18
19
  end
19
20
 
20
21
  def self.resque_present?
21
- ActiveJob::Base.queue_adapter == ActiveJob::QueueAdapters::ResqueAdapter
22
+ ActiveJob::Base.queue_adapter.is_a? ActiveJob::QueueAdapters::ResqueAdapter
22
23
  end
23
24
 
24
25
  def around_enqueue(job, block)
@@ -63,7 +64,11 @@ module ActiveJob
63
64
  is_executing = ::Resque.workers.any? do |worker|
64
65
  processing = worker.processing
65
66
  next false if processing.blank?
67
+
66
68
  args = processing["payload"]["args"][0]
69
+ next false if args.blank?
70
+ next false if (@self_enqueueing.nil? || @self_enqueueing) && args['job_id'] == job.job_id
71
+
67
72
  job_with_args_eq?(job_class, job_arguments, args)
68
73
  end
69
74
 
@@ -1,3 +1,3 @@
1
1
  module ActiveJobResqueSolo
2
- VERSION = "0.3.7"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_job_resque_solo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phillip Kinkade
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-05 00:00:00.000000000 Z
11
+ date: 2021-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -17,9 +17,6 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 4.2.0
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '6'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,9 +24,6 @@ dependencies:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: 4.2.0
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '6'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: byebug
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -131,8 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
125
  - !ruby/object:Gem::Version
132
126
  version: '0'
133
127
  requirements: []
134
- rubyforge_project:
135
- rubygems_version: 2.6.6
128
+ rubygems_version: 3.0.3
136
129
  signing_key:
137
130
  specification_version: 4
138
131
  summary: Prevents duplicate ActiveJob+Resque jobs from being enqueued.