good_job 4.0.1 → 4.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
2
  SHA256:
3
- metadata.gz: 5725006ff1eae761677d25b8f89d55903532b80c6850a8a58ad6506823316763
4
- data.tar.gz: fe91ce725bd86202334c86c308443a3c5e5b0c71b680be4d5086b87b0349fe8a
3
+ metadata.gz: e2bd0a03d12095efe56c49c36fce5dbef909efbb4a984203c49b5ad2e0ba2fc5
4
+ data.tar.gz: 5bc6fc1c127bcffe8388b8f0994c3a2c82b31952387c6be67a35fc280bf1c4cd
5
5
  SHA512:
6
- metadata.gz: 96ca288be634ed11773a66da6e3cad2f60c6cf8736cd33b41f5ce85681160d3a26e283f63f15914e480b5e8587b257ba95e9baed8f08c08c084c28c961320a29
7
- data.tar.gz: d7d6fee108acbfd3743a6520b9f6283bb3cb999a7ce51f87c4d3ae80864d8b0cfe1e34bbb0517c42c8b807145dae315f60f8907bbc601d2aade905b8ff37fa53
6
+ metadata.gz: 0a4c1d788d8c8ea031b4b4654b65b7fe170a0f24d1ffb2550a150de100c8c73f66a4b7d3b19bce99b7f752230c50c5b59829bd906cc3036759553b5615b1b451
7
+ data.tar.gz: 25b4458b92cbeca4db9f6486ee73e41f415b12ab585b35d7724f24e88f99e86b038be2e73f67b4e4bc6c60ff3d01df7903529ab9c859d3df9259db0a113460bc
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## [v4.0.2](https://github.com/bensheldon/good_job/tree/v4.0.2) (2024-07-08)
4
+
5
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v4.0.1...v4.0.2)
6
+
7
+ **Fixed bugs:**
8
+
9
+ - Fix a rails 6.1 deprecation warning for the duration attribute [\#1408](https://github.com/bensheldon/good_job/pull/1408) ([Earlopain](https://github.com/Earlopain))
10
+ - Actually remove deprecated configuration for `cleanup_interval_seconds`, `cleanup_interval_jobs`; remove deprecated `Lockable` [\#1406](https://github.com/bensheldon/good_job/pull/1406) ([bensheldon](https://github.com/bensheldon))
11
+
12
+ **Closed issues:**
13
+
14
+ - PG::UndefinedColumn: ERROR: column good\_job\_processes.lock\_type does not exist [\#1405](https://github.com/bensheldon/good_job/issues/1405)
15
+ - undefined method `duration=' for an instance of GoodJob::Execution [\#1404](https://github.com/bensheldon/good_job/issues/1404)
16
+ - v3 deprecations are still present [\#1399](https://github.com/bensheldon/good_job/issues/1399)
17
+
18
+ **Merged pull requests:**
19
+
20
+ - Fix Batch integration test to not exhaust database connection thread pool [\#1409](https://github.com/bensheldon/good_job/pull/1409) ([bensheldon](https://github.com/bensheldon))
21
+ - Discrete cleanup [\#1401](https://github.com/bensheldon/good_job/pull/1401) ([Earlopain](https://github.com/Earlopain))
22
+
3
23
  ## [v4.0.1](https://github.com/bensheldon/good_job/tree/v4.0.1) (2024-07-08)
4
24
 
5
25
  [Full Changelog](https://github.com/bensheldon/good_job/compare/v4.0.0...v4.0.1)
@@ -25,6 +25,8 @@ module GoodJob
25
25
  self.advisory_lockable_column = 'active_job_id'
26
26
  self.implicit_order_column = 'created_at'
27
27
 
28
+ self.ignored_columns += ["is_discrete"]
29
+
28
30
  define_model_callbacks :perform
29
31
  define_model_callbacks :perform_unlocked, only: :after
30
32
 
@@ -216,14 +218,6 @@ module GoodJob
216
218
  def coalesce_scheduled_at_created_at
217
219
  arel_table.coalesce(arel_table['scheduled_at'], arel_table['created_at'])
218
220
  end
219
-
220
- def discrete_support?
221
- true
222
- end
223
- end
224
-
225
- def discrete?
226
- is_discrete?
227
221
  end
228
222
 
229
223
  # Build an ActiveJob instance and deserialize the arguments, using `#active_job_data`.
@@ -545,17 +539,6 @@ module GoodJob
545
539
  false
546
540
  end
547
541
 
548
- def make_discrete
549
- self.is_discrete = true
550
- self.id = active_job_id
551
- self.job_class = serialized_params['job_class']
552
- self.executions_count ||= 0
553
-
554
- current_time = Time.current
555
- self.created_at ||= current_time
556
- self.scheduled_at ||= current_time
557
- end
558
-
559
542
  # Return formatted serialized_params for display in the dashboard
560
543
  # @return [Hash]
561
544
  def display_serialized_params
@@ -14,6 +14,9 @@ module GoodJob # :nodoc:
14
14
 
15
15
  alias_attribute :performed_at, :created_at
16
16
 
17
+ # TODO: Remove when support for Rails 6.1 is dropped
18
+ attribute :duration, :interval
19
+
17
20
  def number
18
21
  serialized_params.fetch('executions', 0) + 1
19
22
  end
@@ -46,8 +46,6 @@ module GoodJob
46
46
  # Errored but will not be retried
47
47
  scope :discarded, -> { finished.where.not(error: nil) }
48
48
 
49
- scope :unfinished_undiscrete, -> { where(finished_at: nil, retried_good_job_id: nil, is_discrete: [nil, false]) }
50
-
51
49
  # TODO: it would be nice to enforce these values at the model
52
50
  # validates :active_job_id, presence: true
53
51
  # validates :scheduled_at, presence: true
@@ -9,7 +9,7 @@ module GoodJob # :nodoc:
9
9
  :last_at
10
10
 
11
11
  def initialize(cleanup_interval_seconds: false, cleanup_interval_jobs: false)
12
- raise ArgumentError, "Do not use `0`. Use `false` to disable, or -1 to always run" if cleanup_interval_seconds == 0 || cleanup_interval_jobs == 0 # rubocop:disable Style/NumericPredicate
12
+ raise ArgumentError, "Do not use `0` for cleanup intervals. Use `false` to disable, or -1 to always run" if cleanup_interval_seconds == 0 || cleanup_interval_jobs == 0 # rubocop:disable Style/NumericPredicate
13
13
 
14
14
  self.cleanup_interval_seconds = cleanup_interval_seconds
15
15
  self.cleanup_interval_jobs = cleanup_interval_jobs
@@ -230,8 +230,8 @@ module GoodJob
230
230
  def queue_select_limit
231
231
  (
232
232
  options[:queue_select_limit] ||
233
- rails_config[:queue_select_limit] ||
234
- env['GOOD_JOB_QUEUE_SELECT_LIMIT']
233
+ rails_config[:queue_select_limit] ||
234
+ env['GOOD_JOB_QUEUE_SELECT_LIMIT']
235
235
  )&.to_i
236
236
  end
237
237
 
@@ -240,8 +240,8 @@ module GoodJob
240
240
  def idle_timeout
241
241
  (
242
242
  options[:idle_timeout] ||
243
- rails_config[:idle_timeout] ||
244
- env['GOOD_JOB_IDLE_TIMEOUT']
243
+ rails_config[:idle_timeout] ||
244
+ env['GOOD_JOB_IDLE_TIMEOUT']
245
245
  )&.to_i || nil
246
246
  end
247
247
 
@@ -269,69 +269,38 @@ module GoodJob
269
269
  # Positive values will clean up after that many jobs have run, false or 0 will disable, and -1 will clean up after every job.
270
270
  # @return [Integer, Boolean, nil]
271
271
  def cleanup_interval_jobs
272
- if rails_config.key?(:cleanup_interval_jobs)
273
- value = rails_config[:cleanup_interval_jobs]
274
- if value.nil?
275
- GoodJob.deprecator.warn(
276
- %(Setting `config.good_job.cleanup_interval_jobs` to `nil` will no longer disable count-based cleanups in GoodJob v4. Set to `false` to disable, or `-1` to run every time.)
277
- )
278
- value = false
279
- elsif value == 0 # rubocop:disable Style/NumericPredicate
280
- GoodJob.deprecator.warn(
281
- %(Setting `config.good_job.cleanup_interval_jobs` to `0` will disable count-based cleanups in GoodJob v4. Set to `false` to disable, or `-1` to run every time.)
282
- )
283
- value = -1
284
- end
285
- elsif env.key?('GOOD_JOB_CLEANUP_INTERVAL_JOBS')
286
- value = env['GOOD_JOB_CLEANUP_INTERVAL_JOBS']
287
- if value.blank?
288
- GoodJob.deprecator.warn(
289
- %(Setting `GOOD_JOB_CLEANUP_INTERVAL_JOBS` to `""` will no longer disable count-based cleanups in GoodJob v4. Set to `0` to disable, or `-1` to run every time.)
290
- )
291
- value = false
292
- elsif value == '0'
293
- value = false
294
- end
272
+ value = if rails_config.key?(:cleanup_interval_jobs)
273
+ rails_config[:cleanup_interval_jobs]
274
+ elsif env.key?('GOOD_JOB_CLEANUP_INTERVAL_JOBS')
275
+ env['GOOD_JOB_CLEANUP_INTERVAL_JOBS']
276
+ end
277
+
278
+ if value.in? [nil, "", true]
279
+ DEFAULT_CLEANUP_INTERVAL_JOBS
280
+ elsif value.in? [0, "0", false, "false"]
281
+ false
295
282
  else
296
- value = DEFAULT_CLEANUP_INTERVAL_JOBS
283
+ value ? value.to_i : false
297
284
  end
298
-
299
- value ? value.to_i : false
300
285
  end
301
286
 
302
287
  # Number of seconds a {Scheduler} will wait before automatically cleaning up preserved jobs.
303
288
  # Positive values will clean up after that many jobs have run, false or 0 will disable, and -1 will clean up after every job.
304
- # @return [Integer, nil]
289
+ # @return [Integer, Boolean, nil]
305
290
  def cleanup_interval_seconds
306
- if rails_config.key?(:cleanup_interval_seconds)
307
- value = rails_config[:cleanup_interval_seconds]
308
-
309
- if value.nil?
310
- GoodJob.deprecator.warn(
311
- %(Setting `config.good_job.cleanup_interval_seconds` to `nil` will no longer disable time-based cleanups in GoodJob v4. Set to `false` to disable, or `-1` to run every time.)
312
- )
313
- value = false
314
- elsif value == 0 # rubocop:disable Style/NumericPredicate
315
- GoodJob.deprecator.warn(
316
- %(Setting `config.good_job.cleanup_interval_seconds` to `0` will disable time-based cleanups in GoodJob v4. Set to `false` to disable, or `-1` to run every time.)
317
- )
318
- value = -1
319
- end
320
- elsif env.key?('GOOD_JOB_CLEANUP_INTERVAL_SECONDS')
321
- value = env['GOOD_JOB_CLEANUP_INTERVAL_SECONDS']
322
- if value.blank?
323
- GoodJob.deprecator.warn(
324
- %(Setting `GOOD_JOB_CLEANUP_INTERVAL_SECONDS` to `""` will no longer disable time-based cleanups in GoodJob v4. Set to `0` to disable, or `-1` to run every time.)
325
- )
326
- value = false
327
- elsif value == '0'
328
- value = false
329
- end
291
+ value = if rails_config.key?(:cleanup_interval_seconds)
292
+ rails_config[:cleanup_interval_seconds]
293
+ elsif env.key?('GOOD_JOB_CLEANUP_INTERVAL_SECONDS')
294
+ env['GOOD_JOB_CLEANUP_INTERVAL_SECONDS']
295
+ end
296
+
297
+ if value.nil? || value == "" || value == true
298
+ DEFAULT_CLEANUP_INTERVAL_SECONDS
299
+ elsif value.in? [0, "0", false, "false"]
300
+ false
330
301
  else
331
- value = DEFAULT_CLEANUP_INTERVAL_SECONDS
302
+ value ? value.to_i : false
332
303
  end
333
-
334
- value ? value.to_i : false
335
304
  end
336
305
 
337
306
  # Tests whether to daemonize the process.
@@ -2,7 +2,7 @@
2
2
 
3
3
  module GoodJob
4
4
  # GoodJob gem version.
5
- VERSION = '4.0.1'
5
+ VERSION = '4.0.2'
6
6
 
7
7
  # GoodJob version as Gem::Version object
8
8
  GEM_VERSION = Gem::Version.new(VERSION)
data/lib/good_job.rb CHANGED
@@ -269,7 +269,11 @@ module GoodJob
269
269
  # Tests whether GoodJob can be safely upgraded to v4
270
270
  # @return [Boolean]
271
271
  def self.v4_ready?
272
- GoodJob::Job.discrete_support? && GoodJob::Job.where(finished_at: nil).where(is_discrete: [nil, false]).none?
272
+ GoodJob.deprecator.warn(<<~MSG)
273
+ Calling `GoodJob.v4_ready?` is deprecated and will be removed in GoodJob v5.
274
+ If you are reading this deprecation you are already on v4.
275
+ MSG
276
+ true
273
277
  end
274
278
 
275
279
  # Deprecator for providing deprecation warnings.
@@ -281,9 +285,6 @@ module GoodJob
281
285
  end
282
286
  end
283
287
 
284
- include ActiveSupport::Deprecation::DeprecatedConstantAccessor
285
- deprecate_constant :Lockable, 'GoodJob::AdvisoryLockable', deprecator: deprecator
286
-
287
288
  # Whether all GoodJob migrations have been applied.
288
289
  # For use in tests/CI to validate GoodJob is up-to-date.
289
290
  # @return [Boolean]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: good_job
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Sheldon