good_job 3.15.11 → 3.15.13

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: 983b4d8a2381c6564ab48334b2587ae33dee8cf1385d72456f29caf8dd99e26d
4
- data.tar.gz: fd4a54679b61b925f3c0fe6eb07d490f6b92014e2b7a12ac869f77c4c32482e2
3
+ metadata.gz: ce708c401123eb5129c55505dbc02c6e7bca76f6e3d0886a43a359fb1861d99f
4
+ data.tar.gz: 477481c84a743ba4f3a07e7940c8a0cd21c0ec99b4f86277bf86db5e1529a2ad
5
5
  SHA512:
6
- metadata.gz: 3d2d8be450c7f282e6b59c6a4730ab0eebb77c2f8c45eadf0fe556b6490b6b6e38cb247e205da275930f6bd2c4a5d23e844088004a13454e2286af72a001c095
7
- data.tar.gz: 61764d8612c50fa00ea2c5aadf2d2d5ea365f771cb43aedc87bc7456d0d2a1381a3985a518ffeecd382bec27b838ce423268175e0b68687a6722ef77d2b38f88
6
+ metadata.gz: 50152f710bbb121123e76a5ced97b06c0b0427cc6eefe6229d9fc6756cb586cba1f1d5624ddea198879a461909e34e631e8f5147940fcef8daf4615fd5c32311
7
+ data.tar.gz: a7981cac24a946d8edfc7a892a35383376325071bf89da5321f2c05138907d90ac0ca4e3220277ecc3d32a709abb9b63262c7d97581a3514e64488a645994ff2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ## [v3.15.13](https://github.com/bensheldon/good_job/tree/v3.15.13) (2023-06-14)
4
+
5
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v3.15.12...v3.15.13)
6
+
7
+ **Fixed bugs:**
8
+
9
+ - Replace uncached table\_exists? with cached table\_exists? [\#979](https://github.com/bensheldon/good_job/pull/979) ([cmcinnes-mdsol](https://github.com/cmcinnes-mdsol))
10
+
11
+ ## [v3.15.12](https://github.com/bensheldon/good_job/tree/v3.15.12) (2023-06-11)
12
+
13
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v3.15.11...v3.15.12)
14
+
15
+ **Fixed bugs:**
16
+
17
+ - Do not allow GoodJob to automatically start after Rails initialization if previously shutdown [\#976](https://github.com/bensheldon/good_job/pull/976) ([bensheldon](https://github.com/bensheldon))
18
+
19
+ **Merged pull requests:**
20
+
21
+ - Fix Rubocop linting [\#975](https://github.com/bensheldon/good_job/pull/975) ([bensheldon](https://github.com/bensheldon))
22
+ - Bump capybara from 3.38.0 to 3.39.1 [\#970](https://github.com/bensheldon/good_job/pull/970) ([dependabot[bot]](https://github.com/apps/dependabot))
23
+ - Bump thor from 1.2.1 to 1.2.2 [\#967](https://github.com/bensheldon/good_job/pull/967) ([dependabot[bot]](https://github.com/apps/dependabot))
24
+
3
25
  ## [v3.15.11](https://github.com/bensheldon/good_job/tree/v3.15.11) (2023-06-06)
4
26
 
5
27
  [Full Changelog](https://github.com/bensheldon/good_job/compare/v3.15.10...v3.15.11)
@@ -35,12 +35,7 @@ module GoodJob
35
35
  end
36
36
 
37
37
  def discrete_support?
38
- if connection.table_exists?(GoodJob::DiscreteExecution.table_name)
39
- true
40
- else
41
- migration_pending_warning!
42
- false
43
- end
38
+ DiscreteExecution.migrated?
44
39
  end
45
40
  end
46
41
 
@@ -21,7 +21,7 @@ module GoodJob
21
21
  # Can be overriden by child class.
22
22
  # @return [Boolean]
23
23
  def self.migrated?
24
- return true if connection.table_exists?(table_name)
24
+ return true if table_exists?
25
25
 
26
26
  migration_pending_warning!
27
27
  false
@@ -7,6 +7,9 @@ module GoodJob # :nodoc:
7
7
  include AssignableConnection
8
8
  include Lockable
9
9
 
10
+ STALE_INTERVAL = 30.seconds
11
+ EXPIRED_INTERVAL = 5.minutes
12
+
10
13
  self.table_name = 'good_job_processes'
11
14
 
12
15
  cattr_reader :mutex, default: Mutex.new
@@ -76,5 +79,21 @@ module GoodJob # :nodoc:
76
79
  def basename
77
80
  File.basename(state["proctitle"])
78
81
  end
82
+
83
+ def refresh
84
+ touch(:updated_at) # rubocop:disable Rails/SkipsModelValidations
85
+ end
86
+
87
+ def refresh_if_stale
88
+ refresh if stale?
89
+ end
90
+
91
+ def stale?
92
+ updated_at < STALE_INTERVAL.ago
93
+ end
94
+
95
+ def expired?
96
+ updated_at < EXPIRED_INTERVAL.ago
97
+ end
79
98
  end
80
99
  end
@@ -15,17 +15,18 @@ module GoodJob
15
15
  self.class.instances << self
16
16
  @configuration = configuration
17
17
 
18
- @autostart = true
18
+ @startable = true
19
19
  @running = false
20
20
  @mutex = Mutex.new
21
21
  end
22
22
 
23
- # Start executing jobs (if not already running).
24
- def start
25
- return if @running
23
+ # Start the capsule once. After a shutdown, {#restart} must be used to start again.
24
+ # @return [nil, Boolean] Whether the capsule was started.
25
+ def start(force: false)
26
+ return unless startable?(force: force)
26
27
 
27
28
  @mutex.synchronize do
28
- return if @running
29
+ return unless startable?(force: force)
29
30
 
30
31
  @notifier = GoodJob::Notifier.new(enable_listening: @configuration.enable_listen_notify)
31
32
  @poller = GoodJob::Poller.new(poll_interval: @configuration.poll_interval)
@@ -35,7 +36,7 @@ module GoodJob
35
36
 
36
37
  @cron_manager = GoodJob::CronManager.new(@configuration.cron_entries, start_on_initialize: true) if @configuration.enable_cron?
37
38
 
38
- @autostart = false
39
+ @startable = false
39
40
  @running = true
40
41
  end
41
42
  end
@@ -50,7 +51,7 @@ module GoodJob
50
51
  def shutdown(timeout: :default)
51
52
  timeout = timeout == :default ? @configuration.shutdown_timeout : timeout
52
53
  GoodJob._shutdown_all([@notifier, @poller, @scheduler, @cron_manager].compact, timeout: timeout)
53
- @autostart = false
54
+ @startable = false
54
55
  @running = false
55
56
  end
56
57
 
@@ -61,7 +62,7 @@ module GoodJob
61
62
  raise ArgumentError, "Capsule#restart cannot be called with a timeout of nil" if timeout.nil?
62
63
 
63
64
  shutdown(timeout: timeout)
64
- start
65
+ start(force: true)
65
66
  end
66
67
 
67
68
  # @return [Boolean] Whether the capsule is currently running.
@@ -76,10 +77,16 @@ module GoodJob
76
77
 
77
78
  # Creates an execution thread(s) with the given attributes.
78
79
  # @param job_state [Hash, nil] See {GoodJob::Scheduler#create_thread}.
79
- # @return [Boolean, nil] Whether work was started.
80
+ # @return [Boolean, nil] Whether the thread was created.
80
81
  def create_thread(job_state = nil)
81
- start if !running? && @autostart
82
+ start if startable?
82
83
  @scheduler&.create_thread(job_state)
83
84
  end
85
+
86
+ private
87
+
88
+ def startable?(force: false)
89
+ !@running && (@startable || force)
90
+ end
84
91
  end
85
92
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  module GoodJob
3
3
  # GoodJob gem version.
4
- VERSION = '3.15.11'
4
+ VERSION = '3.15.13'
5
5
 
6
6
  # GoodJob version as Gem::Version object
7
7
  GEM_VERSION = Gem::Version.new(VERSION)
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.15.11
4
+ version: 3.15.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Sheldon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-06 00:00:00.000000000 Z
11
+ date: 2023-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob