good_job 3.6.2 → 3.7.1

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: 2bcf55b958dd5e2d0c0711ff1d1a52e94daa21a0f54c96e264934be70f4eb71a
4
- data.tar.gz: bafd6907fd2f9ed5bf41b04b0d3f844407c85de9b488f6c0715413a77134ef27
3
+ metadata.gz: 79ee8980f9408a7e530f6dbc4037f742033e3dbe9919442f08e854314730ef31
4
+ data.tar.gz: bf17a0b7e1fe8cb4d4f7bdfd20b333e2f9e1ce67504e34a9195e1e0921827284
5
5
  SHA512:
6
- metadata.gz: 34ea4a118657a0ea9fb43ef82e6d01fc275269bb8d172d9a6baa4db30af141faf90256e350a77fe09bb821cfdf51c4efe0416576576809b377ed68a4408cc339
7
- data.tar.gz: 96f8567cbd0c52742dd5e60046c8e81d249de5a78a6a7f3dde1f0185316407e965f060275bcfce2fc902df3c27ae83124d37351f241dba7241443c652a168837
6
+ metadata.gz: 955afa8f3f3a224afb58824525a1b230abecbdbfd395e4e31a8dad5498fb32618c77d1e3c70a1503a3228c8e8ea3bdfdb4dccb9238ff0554ad43005e325a64c5
7
+ data.tar.gz: '029ba620af1d42c78b5b0d61524ac5338f501383b7ed166ff559cff4f0505a81485bef07b8aa04179ab17ab9fa6fca96a84b2a61694e7da18832b365fde8e1a1'
data/CHANGELOG.md CHANGED
@@ -1,12 +1,46 @@
1
1
  # Changelog
2
2
 
3
+ ## [v3.7.1](https://github.com/bensheldon/good_job/tree/v3.7.1) (2022-12-12)
4
+
5
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v3.7.0...v3.7.1)
6
+
7
+ **Fixed bugs:**
8
+
9
+ - Fix disabling of interval cleanups [\#768](https://github.com/bensheldon/good_job/pull/768) ([zarqman](https://github.com/zarqman))
10
+
11
+ ## [v3.7.0](https://github.com/bensheldon/good_job/tree/v3.7.0) (2022-12-10)
12
+
13
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v3.6.2...v3.7.0)
14
+
15
+ **Implemented enhancements:**
16
+
17
+ - Add GoodJob version to start banner [\#766](https://github.com/bensheldon/good_job/pull/766) ([zarqman](https://github.com/zarqman))
18
+
19
+ **Fixed bugs:**
20
+
21
+ - Always preserve job records created by cron [\#767](https://github.com/bensheldon/good_job/pull/767) ([bensheldon](https://github.com/bensheldon))
22
+
23
+ **Merged pull requests:**
24
+
25
+ - Bump nokogiri from 1.13.9 to 1.13.10 [\#765](https://github.com/bensheldon/good_job/pull/765) ([dependabot[bot]](https://github.com/apps/dependabot))
26
+ - Remove JRuby 9.2 from testing matrix [\#763](https://github.com/bensheldon/good_job/pull/763) ([bensheldon](https://github.com/bensheldon))
27
+ - Bump actions/cache from 1 to 3 [\#762](https://github.com/bensheldon/good_job/pull/762) ([dependabot[bot]](https://github.com/apps/dependabot))
28
+ - Bump actions/upload-artifact from 2 to 3 [\#761](https://github.com/bensheldon/good_job/pull/761) ([dependabot[bot]](https://github.com/apps/dependabot))
29
+ - Bump actions/add-to-project from 0.3.0 to 0.4.0 [\#759](https://github.com/bensheldon/good_job/pull/759) ([dependabot[bot]](https://github.com/apps/dependabot))
30
+ - Bump alex-page/github-project-automation-plus from 9a05133789dbc96bd560ec84223a0ad49253d342 to 1f8873e97e3c8f58161a323b7c568c1f623a1c4d [\#758](https://github.com/bensheldon/good_job/pull/758) ([dependabot[bot]](https://github.com/apps/dependabot))
31
+ - Bump selenium-webdriver from 4.6.1 to 4.7.1 [\#757](https://github.com/bensheldon/good_job/pull/757) ([dependabot[bot]](https://github.com/apps/dependabot))
32
+ - Add explicit ruby version in Gemfile for Heroku demo [\#755](https://github.com/bensheldon/good_job/pull/755) ([bensheldon](https://github.com/bensheldon))
33
+
3
34
  ## [v3.6.2](https://github.com/bensheldon/good_job/tree/v3.6.2) (2022-12-04)
4
35
 
5
36
  [Full Changelog](https://github.com/bensheldon/good_job/compare/v3.6.1...v3.6.2)
6
37
 
7
- **Merged pull requests:**
38
+ **Fixed bugs:**
8
39
 
9
40
  - Redirect to Jobs path after destroy [\#754](https://github.com/bensheldon/good_job/pull/754) ([BilalBudhani](https://github.com/BilalBudhani))
41
+
42
+ **Merged pull requests:**
43
+
10
44
  - Bump pg from 1.4.4 to 1.4.5 [\#751](https://github.com/bensheldon/good_job/pull/751) ([dependabot[bot]](https://github.com/apps/dependabot))
11
45
 
12
46
  ## [v3.6.1](https://github.com/bensheldon/good_job/tree/v3.6.1) (2022-11-30)
data/README.md CHANGED
@@ -203,17 +203,10 @@ Usage:
203
203
  Options:
204
204
  [--before-seconds-ago=SECONDS] # Destroy records finished more than this many seconds ago (env var: GOOD_JOB_CLEANUP_PRESERVED_JOBS_BEFORE_SECONDS_AGO, default: 1209600 (14 days))
205
205
 
206
- Destroys preserved job records.
206
+ Manually destroys preserved job records.
207
207
 
208
- By default, GoodJob destroys job records when the job is performed and this
209
- command is not necessary.
210
-
211
- However, when `GoodJob.preserve_job_records = true`, the jobs will be
212
- preserved in the database. This is useful when wanting to analyze or
213
- inspect job performance.
214
-
215
- If you are preserving job records this way, use this command regularly
216
- to destroy old records and preserve space in your database.
208
+ By default, GoodJob automatically destroys job records when the job is performed
209
+ and this command is not required to be used.
217
210
  ```
218
211
 
219
212
  ### Configuration options
@@ -280,8 +273,8 @@ Available configuration options are:
280
273
  - `cron` (hash) cron configuration. Defaults to `{}`. You can also set this as a JSON string with the environment variable `GOOD_JOB_CRON`
281
274
  - `cleanup_discarded_jobs` (boolean) whether to destroy discarded jobs when cleaning up preserved jobs using the `$ good_job cleanup_preserved_jobs` CLI command or calling `GoodJob.cleanup_preserved_jobs`. Defaults to `true`. Can also be set with the environment variable `GOOD_JOB_CLEANUP_DISCARDED_JOBS`. _This configuration is only used when {GoodJob.preserve_job_records} is `true`._
282
275
  - `cleanup_preserved_jobs_before_seconds_ago` (integer) number of seconds to preserve jobs when using the `$ good_job cleanup_preserved_jobs` CLI command or calling `GoodJob.cleanup_preserved_jobs`. Defaults to `1209600` (14 days). Can also be set with the environment variable `GOOD_JOB_CLEANUP_PRESERVED_JOBS_BEFORE_SECONDS_AGO`. _This configuration is only used when {GoodJob.preserve_job_records} is `true`._
283
- - `cleanup_interval_jobs` (integer) Number of jobs a Scheduler will execute before cleaning up preserved jobs. Defaults to `1000`. Can also be set with the environment variable `GOOD_JOB_CLEANUP_INTERVAL_JOBS`.
284
- - `cleanup_interval_seconds` (integer) Number of seconds a Scheduler will wait before cleaning up preserved jobs. Defaults to `600` (10 minutes). Can also be set with the environment variable `GOOD_JOB_CLEANUP_INTERVAL_SECONDS`.
276
+ - `cleanup_interval_jobs` (integer) Number of jobs a Scheduler will execute before cleaning up preserved jobs. Defaults to `1000`. Disable with `nil`. Can also be set with the environment variable `GOOD_JOB_CLEANUP_INTERVAL_JOBS`.
277
+ - `cleanup_interval_seconds` (integer) Number of seconds a Scheduler will wait before cleaning up preserved jobs. Defaults to `600` (10 minutes). Disable with `nil`. Can also be set with the environment variable `GOOD_JOB_CLEANUP_INTERVAL_SECONDS`.
285
278
  - `inline_execution_respects_schedule` (boolean) Opt-in to future behavior of inline execution respecting scheduled jobs. Defaults to `false`.
286
279
  - `logger` ([Rails Logger](https://api.rubyonrails.org/classes/ActiveSupport/Logger.html)) lets you set a custom logger for GoodJob. It should be an instance of a Rails `Logger` (Default: `Rails.logger`).
287
280
  - `preserve_job_records` (boolean) keeps job records in your database even after jobs are completed. (Default: `true`)
@@ -460,7 +453,9 @@ GoodJob's concurrency control strategy for `perform_limit` is "optimistic retry
460
453
 
461
454
  GoodJob can enqueue jobs on a recurring basis that can be used as a replacement for cron.
462
455
 
463
- Cron-style jobs are run on every GoodJob process (e.g. CLI or `async` execution mode) when `config.good_job.enable_cron = true`, but GoodJob's cron uses unique indexes to ensure that only a single job is enqueued at the given time interval.
456
+ Cron-style jobs are run on every GoodJob process (e.g. CLI or `async` execution mode) when `config.good_job.enable_cron = true`.
457
+
458
+ GoodJob's cron uses unique indexes to ensure that only a single job is enqueued at the given time interval. In order for this to work, GoodJob must preserve cron-created job records; these records will be automatically deleted like any other preserved record.
464
459
 
465
460
  Cron-format is parsed by the [`fugit`](https://github.com/floraison/fugit) gem, which has support for seconds-level resolution (e.g. `* * * * * *`) and natural language parsing (e.g. `every second`).
466
461
 
@@ -931,9 +926,9 @@ config.good_job.preserve_job_records = false # defaults to true; can also be `fa
931
926
  GoodJob will automatically delete preserved job records after 14 days. The retention period, as well as the frequency GoodJob checks for deletable records can be configured:
932
927
 
933
928
  ```ruby
934
- config.good_job.cleanup_preserved_jobs_before_seconds_ago = 14.days.to_i
929
+ config.good_job.cleanup_preserved_jobs_before_seconds_ago = 14.days
935
930
  config.good_job.cleanup_interval_jobs = 1_000 # Number of executed jobs between deletion sweeps.
936
- config.good_job.cleanup_interval_seconds = 10.minutes.to_i # Number of seconds between deletion sweeps.
931
+ config.good_job.cleanup_interval_seconds = 10.minutes # Number of seconds between deletion sweeps.
937
932
  ```
938
933
 
939
934
  It is also possible to manually trigger a cleanup of preserved job records:
@@ -300,7 +300,7 @@ module GoodJob
300
300
  reenqueued = result.retried? || retried_good_job_id.present?
301
301
  if result.unhandled_error && GoodJob.retry_on_unhandled_error
302
302
  save!
303
- elsif GoodJob.preserve_job_records == true || reenqueued || (result.unhandled_error && GoodJob.preserve_job_records == :on_unhandled_error)
303
+ elsif GoodJob.preserve_job_records == true || reenqueued || (result.unhandled_error && GoodJob.preserve_job_records == :on_unhandled_error) || cron_key.present?
304
304
  self.finished_at = Time.current
305
305
  save!
306
306
  else
data/lib/good_job/cli.rb CHANGED
@@ -128,23 +128,16 @@ module GoodJob
128
128
  # @!macro thor.desc
129
129
  desc :cleanup_preserved_jobs, "Destroys preserved job records."
130
130
  long_desc <<~DESCRIPTION
131
- Destroys preserved job records.
131
+ Manually destroys preserved job records.
132
132
 
133
- By default, GoodJob destroys job records when the job is performed and this
134
- command is not necessary.
135
-
136
- However, when `GoodJob.preserve_job_records = true`, the jobs will be
137
- preserved in the database. This is useful when wanting to analyze or
138
- inspect job performance.
139
-
140
- If you are preserving job records this way, use this command regularly
141
- to destroy old records and preserve space in your database.
133
+ By default, GoodJob automatically destroys job records when the job is performed
134
+ and this command is not required to be used.
142
135
 
143
136
  DESCRIPTION
144
137
  method_option :before_seconds_ago,
145
138
  type: :numeric,
146
139
  banner: 'SECONDS',
147
- desc: "Destroy records finished more than this many seconds ago (env var: GOOD_JOB_CLEANUP_PRESERVED_JOBS_BEFORE_SECONDS_AGO, default: 86400)"
140
+ desc: "Destroy records finished more than this many seconds ago (env var: GOOD_JOB_CLEANUP_PRESERVED_JOBS_BEFORE_SECONDS_AGO, default: 1209600 (14 days))"
148
141
 
149
142
  def cleanup_preserved_jobs
150
143
  set_up_application!
@@ -221,8 +221,7 @@ module GoodJob
221
221
  )&.to_i
222
222
  end
223
223
 
224
- # Whether to destroy discarded jobs when cleaning up preserved jobs.
225
- # This configuration is only used when {GoodJob.preserve_job_records} is +true+.
224
+ # Whether to automatically destroy discarded jobs that have been preserved.
226
225
  # @return [Boolean]
227
226
  def cleanup_discarded_jobs?
228
227
  return rails_config[:cleanup_discarded_jobs] unless rails_config[:cleanup_discarded_jobs].nil?
@@ -231,8 +230,7 @@ module GoodJob
231
230
  true
232
231
  end
233
232
 
234
- # Number of seconds to preserve jobs when using the +good_job cleanup_preserved_jobs+ CLI command.
235
- # This configuration is only used when {GoodJob.preserve_job_records} is +true+.
233
+ # Number of seconds to preserve jobs before automatic destruction.
236
234
  # @return [Integer]
237
235
  def cleanup_preserved_jobs_before_seconds_ago
238
236
  (
@@ -243,25 +241,29 @@ module GoodJob
243
241
  ).to_i
244
242
  end
245
243
 
246
- # Number of jobs a {Scheduler} will execute before cleaning up preserved jobs.
244
+ # Number of jobs a {Scheduler} will execute before automatically cleaning up preserved jobs.
247
245
  # @return [Integer, nil]
248
246
  def cleanup_interval_jobs
249
- value = (
250
- rails_config[:cleanup_interval_jobs] ||
251
- env['GOOD_JOB_CLEANUP_INTERVAL_JOBS'] ||
252
- DEFAULT_CLEANUP_INTERVAL_JOBS
253
- )
247
+ value = if rails_config.key?(:cleanup_interval_jobs)
248
+ rails_config[:cleanup_interval_jobs]
249
+ elsif env.key?('GOOD_JOB_CLEANUP_INTERVAL_JOBS')
250
+ env['GOOD_JOB_CLEANUP_INTERVAL_JOBS']
251
+ else
252
+ DEFAULT_CLEANUP_INTERVAL_JOBS
253
+ end
254
254
  value.present? ? value.to_i : nil
255
255
  end
256
256
 
257
- # Number of seconds a {Scheduler} will wait before cleaning up preserved jobs.
257
+ # Number of seconds a {Scheduler} will wait before automatically cleaning up preserved jobs.
258
258
  # @return [Integer, nil]
259
259
  def cleanup_interval_seconds
260
- value = (
261
- rails_config[:cleanup_interval_seconds] ||
262
- env['GOOD_JOB_CLEANUP_INTERVAL_SECONDS'] ||
263
- DEFAULT_CLEANUP_INTERVAL_SECONDS
264
- )
260
+ value = if rails_config.key?(:cleanup_interval_seconds)
261
+ rails_config[:cleanup_interval_seconds]
262
+ elsif env.key?('GOOD_JOB_CLEANUP_INTERVAL_SECONDS')
263
+ env['GOOD_JOB_CLEANUP_INTERVAL_SECONDS']
264
+ else
265
+ DEFAULT_CLEANUP_INTERVAL_SECONDS
266
+ end
265
267
  value.present? ? value.to_i : nil
266
268
  end
267
269
 
@@ -53,7 +53,7 @@ module GoodJob
53
53
  process_id = event.payload[:process_id]
54
54
 
55
55
  info(tags: [process_id]) do
56
- "GoodJob started scheduler with queues=#{performer_name} max_threads=#{max_threads}."
56
+ "GoodJob #{GoodJob::VERSION} started scheduler with queues=#{performer_name} max_threads=#{max_threads}."
57
57
  end
58
58
  end
59
59
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module GoodJob
3
3
  # GoodJob gem version.
4
- VERSION = '3.6.2'
4
+ VERSION = '3.7.1'
5
5
  end
data/lib/good_job.rb CHANGED
@@ -54,9 +54,10 @@ module GoodJob
54
54
  # @!attribute [rw] preserve_job_records
55
55
  # @!scope class
56
56
  # Whether to preserve job records in the database after they have finished (default: +true+).
57
- # By default, GoodJob deletes job records after the job is completed successfully.
58
57
  # If you want to preserve jobs for latter inspection, set this to +true+.
59
58
  # If you want to preserve only jobs that finished with error for latter inspection, set this to +:on_unhandled_error+.
59
+ # If you do not want to preserve jobs, set this to +false+.
60
+ # When using GoodJob's cron functionality, job records will be preserved for a brief time to prevent duplicate jobs.
60
61
  # @return [Boolean, Symbol, nil]
61
62
  mattr_accessor :preserve_job_records, default: true
62
63
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: good_job
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.2
4
+ version: 3.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Sheldon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-04 00:00:00.000000000 Z
11
+ date: 2022-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob