good_job 3.27.0 → 3.27.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: 2b3817133850acc5176086af47b774bcb80a6ead4ee11e1121a10b23b5c7adb0
4
- data.tar.gz: 0d8d3412835f37b23122a821d7f1ea1f20120a1e1893d29fadcd6e6b8697bce5
3
+ metadata.gz: 1f1caf94daea82b4e273aeaa01d2a44def87934a36275fbe5ca007a27bfceb4d
4
+ data.tar.gz: ad46d59cc2166d6386a17a3d0924f27f81c16e1670121b7f252ec9515da4b011
5
5
  SHA512:
6
- metadata.gz: 984697d136c831db59efdd76f8ca3fc820263de06bdcfe7650f685d75ee0ef64cc3e4c39aa2919b84273b15bb15689bc1fb47afce99a597035266c70372a7c65
7
- data.tar.gz: f6f5942330d621fd89cc951a0f6731aa87578725f5959c9dfcf13c99252952e9c610385afcb03cc17a8bdeeb6a126d607e18c910b66353c01c941eb8e0a6c515
6
+ metadata.gz: 0c2be38cdbbfc7bb63f65451efc85ac51519f1ebabe7f9324ff5a652344b2e06fb75e93a0f0db0cda5038cf562ea793cf5eab6022cc219a304cab5be42b8dd0c
7
+ data.tar.gz: fe5e5d39d0f02a071d8906b155bac1b9467167565544595c38932870e85aff88569b5c9194ea20cf8ea403c134b3a8833e5075e3c8c0bda51982ddea31e6c406
data/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## [v3.27.2](https://github.com/bensheldon/good_job/tree/v3.27.2) (2024-03-27)
4
+
5
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v3.27.1...v3.27.2)
6
+
7
+ **Fixed bugs:**
8
+
9
+ - Use scope-resolutioned constants in Notifier loop [\#1300](https://github.com/bensheldon/good_job/pull/1300) ([bensheldon](https://github.com/bensheldon))
10
+ - Invoke inline Bootstrap Color Mode javascript above CSS link tag to better avoid flash of un-themed content [\#1298](https://github.com/bensheldon/good_job/pull/1298) ([bensheldon](https://github.com/bensheldon))
11
+
12
+ **Closed issues:**
13
+
14
+ - Buggy theme animation while switching tabs [\#1224](https://github.com/bensheldon/good_job/issues/1224)
15
+
16
+ ## [v3.27.1](https://github.com/bensheldon/good_job/tree/v3.27.1) (2024-03-24)
17
+
18
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v3.27.0...v3.27.1)
19
+
20
+ **Fixed bugs:**
21
+
22
+ - Start async adapters `after_initialize` instead of once Active Job and Active Record are loaded and Rails initialized? [\#1297](https://github.com/bensheldon/good_job/pull/1297) ([bensheldon](https://github.com/bensheldon))
23
+
3
24
  ## [v3.27.0](https://github.com/bensheldon/good_job/tree/v3.27.0) (2024-03-24)
4
25
 
5
26
  [Full Changelog](https://github.com/bensheldon/good_job/compare/v3.26.2...v3.27.0)
data/README.md CHANGED
@@ -11,6 +11,8 @@ GoodJob is a multithreaded, Postgres-based, Active Job backend for Ruby on Rails
11
11
  - **Designed for Active Job.** Complete support for [async, queues, delays, priorities, timeouts, and retries](https://edgeguides.rubyonrails.org/active_job_basics.html) with near-zero configuration.
12
12
  - **Built for Rails.** Fully adopts Ruby on Rails [threading and code execution guidelines](https://guides.rubyonrails.org/threading_and_code_execution.html) with [Concurrent::Ruby](https://github.com/ruby-concurrency/concurrent-ruby).
13
13
  - **Backed by Postgres.** Relies upon Postgres integrity, session-level Advisory Locks to provide run-once safety and stay within the limits of `schema.rb`, and LISTEN/NOTIFY to reduce queuing latency.
14
+ - **Fully featured.** Includes support for cron-like scheduled jobs, batches, concurrency and throttling controls, and a powerful Web Dashboard (check out the [Demo](https://goodjob-demo.herokuapp.com/)).
15
+ - **Flexible and lightweight.** Safely runnable within a single existing web process or scaled via an independent CLI process across development, test, and production environments.
14
16
  - **For most workloads.** Targets full-stack teams, economy-minded solo developers, and applications that enqueue 1-million jobs/day and more.
15
17
 
16
18
  For more of the story of GoodJob, read the [introductory blog post](https://island94.org/2020/07/introducing-goodjob-1-0).
@@ -21,6 +23,7 @@ For more of the story of GoodJob, read the [introductory blog post](https://isla
21
23
  | | Queues, priority, retries | Database | Concurrency | Reliability/Integrity | Latency |
22
24
  |-----------------|---------------------------|---------------------------------------|-------------------|------------------------|--------------------------|
23
25
  | **GoodJob** | ✅ Yes | ✅ Postgres | ✅ Multithreaded | ✅ ACID, Advisory Locks | ✅ Postgres LISTEN/NOTIFY |
26
+ | **Solid Queue** | ✅ Yes | ✅ Postgres and other databases ✨ | 🔶 Multithreaded in forked process | ✅ ACID, Advisory Locks | 🔶 Polling |
24
27
  | **Que** | ✅ Yes | 🔶️ Postgres, requires `structure.sql` | ✅ Multithreaded | ✅ ACID, Advisory Locks | ✅ Postgres LISTEN/NOTIFY |
25
28
  | **Delayed Job** | ✅ Yes | ✅ Postgres | 🔴 Single-threaded | ✅ ACID, record-based | 🔶 Polling |
26
29
  | **Sidekiq** | ✅ Yes | 🔴 Redis | ✅ Multithreaded | 🔴 Crashes lose jobs | ✅ Redis BRPOP |
@@ -6,6 +6,20 @@
6
6
  <meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
7
7
  <%= csrf_meta_tags %>
8
8
  <%= csp_meta_tag %>
9
+
10
+ <%# Bootstrap Color Modes
11
+ "It is suggested to include the JavaScript at the top of your page
12
+ to reduce potential screen flickering during reloading of your site."
13
+ https://getbootstrap.com/docs/5.3/customize/color-modes/#javascript
14
+ %>
15
+ <%= tag.script "", nonce: content_security_policy_nonce do %>
16
+ let theme = localStorage.getItem('good_job-theme');
17
+ if (!["light", "dark"].includes(theme)) {
18
+ theme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
19
+ }
20
+ document.documentElement.setAttribute('data-bs-theme', theme);
21
+ <% end %>
22
+
9
23
  <%# Do not use asset tag helpers to avoid paths being overriden by config.asset_host %>
10
24
  <%= tag.link rel: "stylesheet", href: frontend_static_path(:bootstrap, format: :css, v: GoodJob::VERSION, locale: nil), nonce: content_security_policy_nonce %>
11
25
  <%= tag.link rel: "stylesheet", href: frontend_static_path(:style, format: :css, v: GoodJob::VERSION, locale: nil), nonce: content_security_policy_nonce %>
@@ -16,14 +30,6 @@
16
30
  <% importmaps = GoodJob::FrontendsController.js_modules.keys.index_with { |module_name| frontend_module_path(module_name, format: :js, locale: nil, v: GoodJob::VERSION) } %>
17
31
  <%= tag.script({ imports: importmaps }.to_json.html_safe, type: "importmap", nonce: content_security_policy_nonce) %>
18
32
  <%= tag.script "", type: "module", nonce: content_security_policy_nonce do %> import "application"; <% end %>
19
- <%= tag.script "", nonce: content_security_policy_nonce do %>
20
- // Ensure theme is updated before dom loads to avoid flash of style
21
- let theme = localStorage.getItem('good_job-theme');
22
- if (!["light", "dark"].includes(theme)) {
23
- theme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
24
- }
25
- document.documentElement.setAttribute('data-bs-theme', theme);
26
- <% end %>
27
33
  </head>
28
34
  <body>
29
35
  <div class="d-flex flex-column min-vh-100">
@@ -30,7 +30,7 @@ module GoodJob
30
30
  GoodJob::Configuration.validate_execution_mode(@_execution_mode_override) if @_execution_mode_override
31
31
  @capsule = _capsule
32
32
 
33
- start_async if GoodJob.async_ready?
33
+ start_async if GoodJob._async_ready?
34
34
  self.class.instances << self
35
35
  end
36
36
 
@@ -49,22 +49,17 @@ module GoodJob
49
49
  end
50
50
 
51
51
  initializer "good_job.start_async" do
52
- # This hooks into the hookable places during Rails boot, which is unfortunately not Rails.application.initialized?
53
- # If an Adapter is initialized during boot, we want to want to start async executors once the framework dependencies have loaded.
54
- # When exactly that happens is out of our control because gems or application code may touch things earlier than expected.
55
- # For example, as of Rails 6.1, if an ActiveRecord model is touched during boot, that triggers ActiveRecord to load,
56
- # which touches DestroyAssociationAsyncJob, which loads ActiveJob, which may initialize a GoodJob::Adapter, all of which
57
- # happens _before_ ActiveRecord finishes loading. GoodJob will deadlock if an async executor is started in the middle of
58
- # ActiveRecord loading.
59
52
  config.after_initialize do
60
- ActiveSupport.on_load(:active_record) do
61
- ActiveSupport.on_load(:active_job) do
62
- GoodJob._framework_ready = true
63
- GoodJob._start_async_adapters
64
- end
65
- GoodJob._start_async_adapters
66
- end
67
- GoodJob._start_async_adapters
53
+ GoodJob._async_ready = true
54
+
55
+ # Ensure Active Record and Active Job are fully loaded
56
+ ActiveRecord::Base # rubocop:disable Lint/Void
57
+ ActiveJob::Base.queue_adapter
58
+
59
+ GoodJob::Adapter.instances
60
+ .select(&:execute_async?)
61
+ .reject(&:async_started?)
62
+ .each(&:start_async)
68
63
  end
69
64
  end
70
65
  end
@@ -50,7 +50,7 @@ module GoodJob # :nodoc:
50
50
  # Send a message via Postgres NOTIFY
51
51
  # @param message [#to_json]
52
52
  def self.notify(message)
53
- connection = Execution.connection
53
+ connection = ::GoodJob::Execution.connection
54
54
  connection.exec_query <<~SQL.squish
55
55
  NOTIFY #{CHANNEL}, #{connection.quote(message.to_json)}
56
56
  SQL
@@ -248,8 +248,8 @@ module GoodJob # :nodoc:
248
248
 
249
249
  def with_connection
250
250
  Rails.application.executor.wrap do
251
- self.connection = Execution.connection_pool.checkout.tap do |conn|
252
- Execution.connection_pool.remove(conn)
251
+ self.connection = ::GoodJob::Execution.connection_pool.checkout.tap do |conn|
252
+ ::GoodJob::Execution.connection_pool.remove(conn)
253
253
  end
254
254
  end
255
255
  connection.execute("SET application_name = #{connection.quote(self.class.name)}")
@@ -2,7 +2,7 @@
2
2
 
3
3
  module GoodJob
4
4
  # GoodJob gem version.
5
- VERSION = '3.27.0'
5
+ VERSION = '3.27.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
@@ -25,7 +25,6 @@ require_relative "good_job/configuration"
25
25
  require_relative "good_job/cron_manager"
26
26
  require_relative "good_job/current_thread"
27
27
  require_relative "good_job/daemon"
28
- require_relative "good_job/dependencies"
29
28
  require_relative "good_job/job_performer"
30
29
  require_relative "good_job/job_performer/metrics"
31
30
  require_relative "good_job/log_subscriber"
@@ -46,7 +45,6 @@ require_relative "good_job/thread_status"
46
45
  #
47
46
  # +GoodJob+ is the top-level namespace and exposes configuration attributes.
48
47
  module GoodJob
49
- include GoodJob::Dependencies
50
48
  include GoodJob::ThreadStatus
51
49
 
52
50
  # Default, null, blank value placeholder.
@@ -114,6 +112,11 @@ module GoodJob
114
112
  # @return [GoodJob::Capsule, nil]
115
113
  mattr_accessor :capsule, default: GoodJob::Capsule.new(configuration: configuration)
116
114
 
115
+ mattr_accessor :_async_ready, default: false
116
+ def self._async_ready?
117
+ _async_ready
118
+ end
119
+
117
120
  # Called with exception when a GoodJob thread raises an exception
118
121
  # @param exception [Exception] Exception that was raised
119
122
  # @return [void]
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.27.0
4
+ version: 3.27.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Sheldon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-24 00:00:00.000000000 Z
11
+ date: 2024-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob
@@ -404,7 +404,6 @@ files:
404
404
  - lib/good_job/cron_manager.rb
405
405
  - lib/good_job/current_thread.rb
406
406
  - lib/good_job/daemon.rb
407
- - lib/good_job/dependencies.rb
408
407
  - lib/good_job/engine.rb
409
408
  - lib/good_job/interrupt_error.rb
410
409
  - lib/good_job/job_performer.rb
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module GoodJob # :nodoc:
4
- # Extends GoodJob module to track Rails boot dependencies.
5
- module Dependencies
6
- extend ActiveSupport::Concern
7
-
8
- included do
9
- mattr_accessor :_framework_ready, default: false
10
- end
11
-
12
- class_methods do
13
- # Whether Rails framework has sufficiently initialized to enable Async execution.
14
- def async_ready?
15
- Rails.application.initialized? || _framework_ready
16
- end
17
-
18
- def _start_async_adapters
19
- return unless async_ready?
20
-
21
- ActiveJob::Base.queue_adapter # Ensure Active Job is initialized
22
- GoodJob::Adapter.instances
23
- .select(&:execute_async?)
24
- .reject(&:async_started?)
25
- .each(&:start_async)
26
- end
27
- end
28
- end
29
- end