resque-unique_by_arity 1.0.9 → 1.0.10

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: 06ef1c526f5dea1a56e51bbf8053e41854ec9e94
4
- data.tar.gz: 8bbd6cae274b5a245019e88b6297672eb66bfb92
3
+ metadata.gz: f633f3ff4e8bb0f3e870227767fa1354624387ae
4
+ data.tar.gz: 997bbaa637fd611baa63d107759df5c64c8e9dda
5
5
  SHA512:
6
- metadata.gz: '08fec6b73c8f0cb6d28a82d4b0b639835088dbe180f3f28ec86201b2256687dc92839d2added60f36a64b7930c2d0bea132412e2c7787e17ab8251c37f500f5f'
7
- data.tar.gz: bd024532330e4b82dac8e41f6b26c5747ec68f36a3a3a7db468c027a9e369dc003836ab150c20d18c36628dddc3b7ebc9ad33f568c508ae51378002937759df8
6
+ metadata.gz: 7697b2036bc838b6be804f30cf1c0d5e40b9566e9d4f21b8d6722449777bf0937724b8fcb5806b44296a3e7f36d22f08b8aa41729b2aab02beaad6b75b86d703
7
+ data.tar.gz: cc13bf8f10a09ca98ee1fc75d6f14a8519872d1d3df1a10fe6dacc399eabf9df20dd109f7dd84fcde7648e81f7a4c8f36a3b4eb8ba810088b0dc5362f01a6589
data/README.md CHANGED
@@ -5,10 +5,15 @@ NOTE:
5
5
  Requires `resque_solo` gem, and `resque-unique_at_runtime` gem; the latter is a fork of `resque-lonely_job`.
6
6
  Why? `resque-lonely_job` and `resque_solo` can't be used together, because their `redis_key` methods conflict.
7
7
 
8
+ Also - you must configure this gem *after* you define the perform class method in your job or the arity validation will not work properly.
9
+
8
10
  Example:
9
11
 
10
12
  ```ruby
11
13
  class MyJob
14
+ def self.perform(arg)
15
+ # do stuff
16
+ end
12
17
  include UniqueByArity::Cop.new(
13
18
  arity_for_uniqueness: 1,
14
19
  lock_after_execution_period: 60,
@@ -43,6 +48,9 @@ Some jobs have parameters that you do not want to consider for determination of
43
48
 
44
49
  ```ruby
45
50
  class MyJob
51
+ def self.perform(arg1, arg2, arg3)
52
+ # do stuff
53
+ end
46
54
  include UniqueByArity::Cop.new(
47
55
  arity_for_uniqueness: 3,
48
56
  unique_at_runtime: true
@@ -59,6 +67,9 @@ Want this gem to tell you when it is misconfigured? It can.
59
67
 
60
68
  ```ruby
61
69
  class MyJob
70
+ def self.perform(arg1, arg2, arg3)
71
+ # do stuff
72
+ end
62
73
  include UniqueByArity::Cop.new(
63
74
  arity_for_uniqueness: 3,
64
75
  arity_validation: :warning, # or :skip, :error, or an error class to be raised, e.g. RuntimeError
@@ -81,6 +92,9 @@ Give the job a break after it finishes running, and don't allow another of the s
81
92
 
82
93
  ```ruby
83
94
  class MyJob
95
+ def self.perform(arg1)
96
+ # do stuff
97
+ end
84
98
  include UniqueByArity::Cop.new(
85
99
  arity_for_uniqueness: 1,
86
100
  lock_after_execution_period: 60,
@@ -95,6 +109,9 @@ If runtime lock keys get stale, they will expire on their own after some period.
95
109
 
96
110
  ```ruby
97
111
  class MyJob
112
+ def self.perform(arg1)
113
+ # do stuff
114
+ end
98
115
  include UniqueByArity::Cop.new(
99
116
  arity_for_uniqueness: 1,
100
117
  runtime_lock_timeout: 60 * 60 * 24 * 5, # 5 days
@@ -109,6 +126,9 @@ Prevent your app from running a job that is already running.
109
126
 
110
127
  ```ruby
111
128
  class MyJob
129
+ def self.perform(arg1)
130
+ # do stuff
131
+ end
112
132
  include UniqueByArity::Cop.new(
113
133
  arity_for_uniqueness: 1,
114
134
  unique_at_runtime: true
@@ -124,6 +144,9 @@ Prevent your app from queueing a job that is already queued in the same queue.
124
144
 
125
145
  ```ruby
126
146
  class MyJob
147
+ def self.perform(arg1)
148
+ # do stuff
149
+ end
127
150
  include UniqueByArity::Cop.new(
128
151
  arity_for_uniqueness: 1,
129
152
  unique_in_queue: true
@@ -137,6 +160,9 @@ Prevent your app from queueing a job that is already queued in *any* queue.
137
160
 
138
161
  ```ruby
139
162
  class MyJob
163
+ def self.perform(arg1)
164
+ # do stuff
165
+ end
140
166
  include UniqueByArity::Cop.new(
141
167
  arity_for_uniqueness: 1,
142
168
  unique_across_queues: true
@@ -153,6 +179,9 @@ prevent your app from queueing a job that is already queued in the same queue.
153
179
 
154
180
  ```ruby
155
181
  class MyJob
182
+ def self.perform(arg1)
183
+ # do stuff
184
+ end
156
185
  include UniqueByArity::Cop.new(
157
186
  arity_for_uniqueness: 1,
158
187
  unique_at_runtime: true,
@@ -169,6 +198,9 @@ prevent your app from queueing a job that is already queued in *any* queue.
169
198
 
170
199
  ```ruby
171
200
  class MyJob
201
+ def self.perform(arg1)
202
+ # do stuff
203
+ end
172
204
  include UniqueByArity::Cop.new(
173
205
  arity_for_uniqueness: 1,
174
206
  unique_at_runtime: true,
@@ -188,6 +220,9 @@ Redefine methods to customize all the things. Warning: This might be crazy-maki
188
220
 
189
221
  ```ruby
190
222
  class MyJob
223
+ def self.perform(arg1)
224
+ # do stuff
225
+ end
191
226
  include UniqueByArity::Cop.new(
192
227
  #...
193
228
  )
@@ -16,7 +16,7 @@ require "resque/unique_by_arity/validation"
16
16
  # class MyJob
17
17
  # include UniqueByArity::Cop.new(
18
18
  # arity_for_uniqueness: 1,
19
- # arity_for_validation: :warning, # or nil, false, or :error
19
+ # arity_validation: :warning, # or nil, false, or :error
20
20
  # unique_at_runtime: true,
21
21
  # unique_in_queue: true
22
22
  # )
@@ -60,10 +60,10 @@ module Resque
60
60
  def uniqueness_arity_for_uniqueness=(arity_for_uniqueness)
61
61
  @uniqueness_configuration.arity_for_uniqueness = arity_for_uniqueness
62
62
  end
63
- def uniqueness_arity_for_validation
63
+ def uniqueness_arity_validation
64
64
  @uniqueness_configuration.arity_validation
65
65
  end
66
- def uniqueness_arity_for_validation=(arity_validation)
66
+ def uniqueness_arity_validation=(arity_validation)
67
67
  @uniqueness_configuration.arity_validation = arity_validation
68
68
  end
69
69
  def uniqueness_lock_after_execution_period
@@ -2,7 +2,8 @@ require 'logger'
2
2
  module Resque
3
3
  module UniqueByArity
4
4
  class Configuration
5
- VALID_ARITY_VALIDATION_LEVELS = [ :warning, :error, nil, false ]
5
+ VALID_ARITY_VALIDATION_LEVELS = [ :warning, :error, :skip, nil, false ]
6
+ SKIPPED_ARITY_VALIDATION_LEVELS = [ :skip, nil, false ]
6
7
  attr_accessor :logger
7
8
  attr_accessor :log_level
8
9
  attr_accessor :arity_for_uniqueness
@@ -17,7 +18,7 @@ module Resque
17
18
  @log_level = options.key?(:log_level) ? options[:log_level] : :debug
18
19
  @arity_for_uniqueness = options.key?(:arity_for_uniqueness) ? options[:arity_for_uniqueness] : 1
19
20
  @arity_validation = options.key?(:arity_validation) ? options[:arity_validation] : :warning
20
- raise ArgumentError, "UniqueByArity::Cop.new requires arity_validation values of nil, false, :warning, :error, or an class descending from Exception but the value is #{@arity_validation} (#{@arity_validation.class})" unless VALID_ARITY_VALIDATION_LEVELS.include?(@arity_validation) || @arity_validation.ancestors.include?(Exception)
21
+ raise ArgumentError, "UniqueByArity::Cop.new requires arity_validation values of #{arity_validation.inspect}, or a class inheriting from Exception, but the value is #{@arity_validation} (#{@arity_validation.class})" unless VALID_ARITY_VALIDATION_LEVELS.include?(@arity_validation) || !@arity_validation.respond_to?(:ancestors) || @arity_validation.ancestors.include?(Exception)
21
22
  @lock_after_execution_period = options.key?(:lock_after_execution_period) ? options[:lock_after_execution_period] : nil
22
23
  @runtime_lock_timeout = options.key?(:runtime_lock_timeout) ? options[:runtime_lock_timeout] : nil
23
24
  @unique_at_runtime = options.key?(:unique_at_runtime) ? options[:unique_at_runtime] : false
@@ -48,6 +49,7 @@ module Resque
48
49
  logger: logger,
49
50
  log_level: log_level,
50
51
  arity_for_uniqueness: arity_for_uniqueness,
52
+ arity_validation: arity_validation,
51
53
  lock_after_execution_period: lock_after_execution_period,
52
54
  runtime_lock_timeout: runtime_lock_timeout,
53
55
  unique_at_runtime: unique_at_runtime,
@@ -57,7 +59,7 @@ module Resque
57
59
  end
58
60
 
59
61
  def skip_arity_validation?
60
- arity_validation == :skip
62
+ SKIPPED_ARITY_VALIDATION_LEVELS.include?(arity_validation)
61
63
  end
62
64
 
63
65
  def validate_arity(klass_string, perform_method)
@@ -1,5 +1,5 @@
1
1
  module Resque
2
2
  module UniqueByArity
3
- VERSION = "1.0.9"
3
+ VERSION = "1.0.10"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-unique_by_arity
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ version: 1.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Boling
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-17 00:00:00.000000000 Z
11
+ date: 2017-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: resque-unique_at_runtime