good_job 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +3 -2
- data/lib/good_job/cli.rb +1 -10
- data/lib/good_job/configuration.rb +1 -1
- data/lib/good_job/version.rb +1 -1
- data/lib/good_job.rb +22 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4c1686f53ec7019417a342069c499c829dccb4f8cfcbd7396623b96e9edd2fe
|
4
|
+
data.tar.gz: de4e3d7a20e47c63aad25dd167a640b83a9349f0b8933d4692afc6f8b12d16d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfe017b7ea652b134c009622e5a7b1d83e7d502a4f066b49538ffca138555f4395d6279f7256a10c872e1967aa127bb82eba17a72fbf8930adcd12da9650dbf4
|
7
|
+
data.tar.gz: 1e5178b1d9ddf492347e6f25b10bae710dc25454974436fad322b306698a25bdf29d777f54de5c988479b56a21d2b0a8cfdc7b7f87799ae5cf6f7df4c76f4b6b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v2.0.3](https://github.com/bensheldon/good_job/tree/v2.0.3) (2021-08-31)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v2.0.2...v2.0.3)
|
6
|
+
|
7
|
+
**Closed issues:**
|
8
|
+
|
9
|
+
- Expose CLI `cleanup_preserved_jobs` functionality via `GoodJob`? [\#351](https://github.com/bensheldon/good_job/issues/351)
|
10
|
+
|
11
|
+
**Merged pull requests:**
|
12
|
+
|
13
|
+
- Implement `GoodJob.cleanup_preserved_jobs`, fixes \#351 [\#356](https://github.com/bensheldon/good_job/pull/356) ([aried3r](https://github.com/aried3r))
|
14
|
+
|
3
15
|
## [v2.0.2](https://github.com/bensheldon/good_job/tree/v2.0.2) (2021-08-27)
|
4
16
|
|
5
17
|
[Full Changelog](https://github.com/bensheldon/good_job/compare/v1.99.1...v2.0.2)
|
data/README.md
CHANGED
@@ -184,7 +184,7 @@ separate isolated execution pools with semicolons and threads with colons.
|
|
184
184
|
|
185
185
|
#### `good_job cleanup_preserved_jobs`
|
186
186
|
|
187
|
-
`good_job cleanup_preserved_jobs` deletes preserved job records. See
|
187
|
+
`good_job cleanup_preserved_jobs` deletes preserved job records. See `GoodJob.preserve_job_records` for when this command is useful.
|
188
188
|
|
189
189
|
```bash
|
190
190
|
$ bundle exec good_job help cleanup_preserved_jobs
|
@@ -724,7 +724,8 @@ It is also necessary to delete these preserved jobs from the database after a ce
|
|
724
724
|
- For example, in a Rake task:
|
725
725
|
|
726
726
|
```ruby
|
727
|
-
GoodJob
|
727
|
+
GoodJob.cleanup_preserved_jobs # Will keep 1 day of job records by default.
|
728
|
+
GoodJob.cleanup_preserved_jobs(older_than: 7.days) # It also takes custom arguments.
|
728
729
|
```
|
729
730
|
|
730
731
|
- For example, using the `good_job` command-line utility:
|
data/lib/good_job/cli.rb
CHANGED
@@ -134,16 +134,7 @@ module GoodJob
|
|
134
134
|
|
135
135
|
configuration = GoodJob::Configuration.new(options)
|
136
136
|
|
137
|
-
|
138
|
-
|
139
|
-
ActiveSupport::Notifications.instrument(
|
140
|
-
"cleanup_preserved_jobs.good_job",
|
141
|
-
{ before_seconds_ago: configuration.cleanup_preserved_jobs_before_seconds_ago, timestamp: timestamp }
|
142
|
-
) do |payload|
|
143
|
-
deleted_records_count = GoodJob::Job.finished(timestamp).delete_all
|
144
|
-
|
145
|
-
payload[:deleted_records_count] = deleted_records_count
|
146
|
-
end
|
137
|
+
GoodJob.cleanup_preserved_jobs(older_than: configuration.cleanup_preserved_jobs_before_seconds_ago)
|
147
138
|
end
|
148
139
|
|
149
140
|
no_commands do
|
@@ -16,7 +16,7 @@ module GoodJob
|
|
16
16
|
DEFAULT_DEVELOPMENT_ASYNC_POLL_INTERVAL = -1
|
17
17
|
# Default number of threads to use per {Scheduler}
|
18
18
|
DEFAULT_MAX_CACHE = 10000
|
19
|
-
# Default number of seconds to preserve jobs for {CLI#cleanup_preserved_jobs}
|
19
|
+
# Default number of seconds to preserve jobs for {CLI#cleanup_preserved_jobs} and {GoodJob.cleanup_preserved_jobs}
|
20
20
|
DEFAULT_CLEANUP_PRESERVED_JOBS_BEFORE_SECONDS_AGO = 24 * 60 * 60
|
21
21
|
# Default to always wait for jobs to finish for {Adapter#shutdown}
|
22
22
|
DEFAULT_SHUTDOWN_TIMEOUT = -1
|
data/lib/good_job/version.rb
CHANGED
data/lib/good_job.rb
CHANGED
@@ -42,7 +42,8 @@ module GoodJob
|
|
42
42
|
# By default, GoodJob deletes job records after the job is completed successfully.
|
43
43
|
# If you want to preserve jobs for latter inspection, set this to +true+.
|
44
44
|
# If you want to preserve only jobs that finished with error for latter inspection, set this to +:on_unhandled_error+.
|
45
|
-
# If +true+, you will need to clean out jobs using the +good_job cleanup_preserved_jobs+ CLI command
|
45
|
+
# If +true+, you will need to clean out jobs using the +good_job cleanup_preserved_jobs+ CLI command or
|
46
|
+
# by using +Goodjob.cleanup_preserved_jobs+.
|
46
47
|
# @return [Boolean, nil]
|
47
48
|
mattr_accessor :preserve_job_records, default: false
|
48
49
|
|
@@ -114,6 +115,26 @@ module GoodJob
|
|
114
115
|
end
|
115
116
|
end
|
116
117
|
|
118
|
+
# Deletes preserved job records.
|
119
|
+
# By default, GoodJob deletes job records when the job is performed and this
|
120
|
+
# method is not necessary. However, when `GoodJob.preserve_job_records = true`,
|
121
|
+
# the jobs will be preserved in the database. This is useful when wanting to
|
122
|
+
# analyze or inspect job performance.
|
123
|
+
# If you are preserving job records this way, use this method regularly to
|
124
|
+
# delete old records and preserve space in your database.
|
125
|
+
# @params older_than [nil,Numeric,ActiveSupport::Duration] Jobs olders than this will be deleted (default: +86400+).
|
126
|
+
# @return [Integer] Number of jobs that were deleted.
|
127
|
+
def self.cleanup_preserved_jobs(older_than: nil)
|
128
|
+
older_than ||= GoodJob::Configuration.new({}).cleanup_preserved_jobs_before_seconds_ago
|
129
|
+
timestamp = Time.current - older_than
|
130
|
+
|
131
|
+
ActiveSupport::Notifications.instrument("cleanup_preserved_jobs.good_job", { older_than: older_than, timestamp: timestamp }) do |payload|
|
132
|
+
deleted_records_count = GoodJob::Job.finished(timestamp).delete_all
|
133
|
+
|
134
|
+
payload[:deleted_records_count] = deleted_records_count
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
117
138
|
def self._executables
|
118
139
|
[].concat(
|
119
140
|
CronManager.instances,
|
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: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Sheldon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|