solid_queue_guard 1.3.0 → 1.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d67d9fdbc9de83d8566bfc3c7529e4be2bf3e924cba7f840b555869cd0b2a618
4
- data.tar.gz: 63368e74ee06a570c18d7f7cd7ea56de72355ae84327f883a01233f1bee38cd5
3
+ metadata.gz: 0f68d16b641aa34f7cf2cda0731e1f279d4078466271f25bdac801d812a1c050
4
+ data.tar.gz: d9765f83f9e100ec1508603cc6e6c461ca5835a925d32ef30b993d122eafb6ce
5
5
  SHA512:
6
- metadata.gz: 20bfa32ec7ae3b150414576877e57f432364f21df151082e6fd4a6d7da7c9b3802899223fcc33b37dc529b2ecf3a4723748b4a9ec30b5bd32fa168632cf73840
7
- data.tar.gz: 4b1553424fb1ad718edd40f22f06cf463837fc82bcb7350efd4c062b956cfd94a7cffdeb329460afbb23f17f40f0e30243b169c314c49f8679c41ed67ea89346
6
+ metadata.gz: 24f148012d857a399cb27ceab0ca17ed9b09e4215610e82aa96d9bbb2fa9b84b05b85e63723ffbe7edd57d65cb8c3ed81305ee0e2650ffb798aeffd55bbc1c11
7
+ data.tar.gz: bcd5ab443291828fbf19100ded2010d54d5d57cf764390623ca5e67d4291fb80c1fca37e5498ada656dfc95e184d8484e0a17e4763a0052f634a186980961bff
data/CHANGELOG.md CHANGED
@@ -5,6 +5,25 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.4.0] - 2026-08-03
9
+
10
+ ### Changed
11
+
12
+ - `recurring_stale` derives per-task thresholds from each task's schedule period
13
+ (`next_time - previous_time`, multiplied by `2` by default). Frequent crons alert sooner;
14
+ daily/weekly crons no longer force a single global window that hides shorter schedules.
15
+ - `config.checks.recurring_stale = { threshold: ... }` is now a **fallback** when the schedule
16
+ period cannot be derived (not a global override for every task).
17
+ - Optional `thresholds: { task_key: duration }` and `multiplier:` overrides for fine-tuning.
18
+
19
+ ## [1.3.1] - 2026-07-31
20
+
21
+ ### Fixed
22
+
23
+ - `thread_pool` and topology pool recommendations work with Solid Queue 1.6+, which renamed
24
+ `estimated_number_of_threads` to `estimated_database_pool_size`. Guard now reads whichever
25
+ private helper the installed gem exposes.
26
+
8
27
  ## [1.3.0] - 2026-07-29
9
28
 
10
29
  ### Changed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- solid_queue_guard (1.2.5)
4
+ solid_queue_guard (1.4.0)
5
5
  actionpack (>= 7.1, < 9.0)
6
6
  activejob (>= 7.1, < 9.0)
7
7
  activerecord (>= 7.1, < 9.0)
@@ -5,7 +5,7 @@ module SolidQueueGuard
5
5
  module Config
6
6
  class ThreadPoolCheck < Base
7
7
  def call
8
- required_threads = solid_queue_configuration.send(:estimated_number_of_threads)
8
+ required_pool = ConfigurationSizing.estimated_database_pool_size(solid_queue_configuration)
9
9
  pool_size = SolidQueue::Record.connection_pool&.size
10
10
 
11
11
  return skip('thread_pool', 'Queue database connection pool is not available') if pool_size.nil?
@@ -17,18 +17,18 @@ module SolidQueueGuard
17
17
  )
18
18
  end.max || 1
19
19
 
20
- if pool_size >= required_threads
20
+ if pool_size >= required_pool
21
21
  pass(
22
22
  'thread_pool',
23
23
  "Worker threads: #{max_worker_threads}, queue DB pool: #{pool_size}",
24
- metadata: { threads: max_worker_threads, pool: pool_size, required: required_threads }
24
+ metadata: { threads: max_worker_threads, pool: pool_size, required: required_pool }
25
25
  )
26
26
  else
27
27
  failure(
28
28
  'thread_pool',
29
29
  "Worker threads: #{max_worker_threads}, queue DB pool: #{pool_size}",
30
- suggestion: "Increase queue DB pool to at least #{required_threads} or reduce worker threads",
31
- metadata: { threads: max_worker_threads, pool: pool_size, required: required_threads }
30
+ suggestion: "Increase queue DB pool to at least #{required_pool} or reduce worker threads",
31
+ metadata: { threads: max_worker_threads, pool: pool_size, required: required_pool }
32
32
  )
33
33
  end
34
34
  end
@@ -4,15 +4,14 @@ module SolidQueueGuard
4
4
  module Checks
5
5
  module Runtime
6
6
  class RecurringStaleCheck < Base
7
+ DEFAULT_MULTIPLIER = 2
8
+
7
9
  def call
8
10
  with_queue_database do
9
11
  tasks = SolidQueue::RecurringTask.static
10
12
  return pass(check_id, 'No recurring tasks configured') if tasks.none?
11
13
 
12
- stale_tasks = tasks.select do |task|
13
- last_run = SolidQueue::RecurringExecution.where(task_key: task.key).maximum(:run_at)
14
- last_run.nil? || last_run < expected_staleness.ago
15
- end
14
+ stale_tasks = tasks.select { |task| stale?(task) }
16
15
 
17
16
  if stale_tasks.any?
18
17
  warn(
@@ -28,7 +27,48 @@ module SolidQueueGuard
28
27
 
29
28
  private
30
29
 
31
- def expected_staleness
30
+ def stale?(task)
31
+ last_run = SolidQueue::RecurringExecution.where(task_key: task.key).maximum(:run_at)
32
+ last_run.nil? || last_run < expected_staleness_for(task).ago
33
+ end
34
+
35
+ def expected_staleness_for(task)
36
+ override = per_task_threshold(task.key)
37
+ return override if override
38
+
39
+ period = schedule_period_for(task)
40
+ return period * multiplier if period
41
+
42
+ fallback_threshold
43
+ end
44
+
45
+ def per_task_threshold(task_key)
46
+ thresholds = config.check_setting(:recurring_stale, :thresholds, nil)
47
+ return unless thresholds
48
+
49
+ thresholds[task_key.to_sym] || thresholds[task_key.to_s]
50
+ end
51
+
52
+ def schedule_period_for(task)
53
+ return unless task.respond_to?(:previous_time) && task.respond_to?(:next_time)
54
+
55
+ previous = task.previous_time
56
+ nxt = task.next_time
57
+ return unless previous && nxt
58
+
59
+ seconds = nxt - previous
60
+ return unless seconds.positive?
61
+
62
+ seconds.seconds
63
+ rescue StandardError
64
+ nil
65
+ end
66
+
67
+ def multiplier
68
+ config.check_setting(:recurring_stale, :multiplier, DEFAULT_MULTIPLIER)
69
+ end
70
+
71
+ def fallback_threshold
32
72
  config.check_setting(:recurring_stale, :threshold, config.stale_process_threshold * 2)
33
73
  end
34
74
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidQueueGuard
4
+ # Reads Solid Queue's estimated queue-DB pool requirement across gem versions.
5
+ #
6
+ # Solid Queue 1.6 renamed the private helper from +estimated_number_of_threads+
7
+ # to +estimated_database_pool_size+ (fiber workers need a different estimate).
8
+ # Both return the same value for classic thread workers: max capacity + 2.
9
+ module ConfigurationSizing
10
+ module_function
11
+
12
+ def estimated_database_pool_size(configuration = SolidQueue::Configuration.new)
13
+ if configuration.respond_to?(:estimated_database_pool_size, true)
14
+ configuration.send(:estimated_database_pool_size)
15
+ elsif configuration.respond_to?(:estimated_number_of_threads, true)
16
+ configuration.send(:estimated_number_of_threads)
17
+ else
18
+ raise NoMethodError,
19
+ 'SolidQueue::Configuration has neither estimated_database_pool_size ' \
20
+ 'nor estimated_number_of_threads'
21
+ end
22
+ end
23
+ end
24
+ end
@@ -33,11 +33,11 @@ module SolidQueueGuard
33
33
  def pool_recommendations
34
34
  return async_pool_recommendation if PumaPluginSupport.async_supervisor_mode?
35
35
 
36
- required_threads = configuration.estimated_number_of_threads
36
+ required_pool = ConfigurationSizing.estimated_database_pool_size(configuration)
37
37
  pool_size = SolidQueue::Record.connection_pool&.size
38
- return [] if pool_size.nil? || required_threads <= pool_size
38
+ return [] if pool_size.nil? || required_pool <= pool_size
39
39
 
40
- ["Increase queue DB pool to at least #{required_threads + 2} (currently #{pool_size})"]
40
+ ["Increase queue DB pool to at least #{required_pool} (currently #{pool_size})"]
41
41
  rescue StandardError
42
42
  []
43
43
  end
@@ -62,11 +62,11 @@ module SolidQueueGuard
62
62
  end
63
63
 
64
64
  def async_pool_recommendation
65
- required_threads = configuration.estimated_number_of_threads
65
+ required_pool = ConfigurationSizing.estimated_database_pool_size(configuration)
66
66
  pool_size = SolidQueue::Record.connection_pool&.size
67
- return [] if pool_size.nil? || required_threads <= pool_size
67
+ return [] if pool_size.nil? || required_pool <= pool_size
68
68
 
69
- ["Increase queue DB pool to at least #{required_threads + 2} " \
69
+ ["Increase queue DB pool to at least #{required_pool} " \
70
70
  "for async supervisor mode (currently #{pool_size})"]
71
71
  rescue StandardError
72
72
  []
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidQueueGuard
4
- VERSION = '1.3.0'
4
+ VERSION = '1.4.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solid_queue_guard
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafael Pissardo
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2026-07-29 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: actionpack
@@ -359,6 +358,7 @@ files:
359
358
  - lib/solid_queue_guard/checks/runtime/stale_process_check.rb
360
359
  - lib/solid_queue_guard/cli.rb
361
360
  - lib/solid_queue_guard/configuration.rb
361
+ - lib/solid_queue_guard/configuration_sizing.rb
362
362
  - lib/solid_queue_guard/engine.rb
363
363
  - lib/solid_queue_guard/formatters/json.rb
364
364
  - lib/solid_queue_guard/formatters/terminal.rb
@@ -394,7 +394,6 @@ metadata:
394
394
  bug_tracker_uri: https://github.com/rafael-pissardo/solid_queue_guard/issues
395
395
  documentation_uri: https://github.com/rafael-pissardo/solid_queue_guard#readme
396
396
  rubygems_mfa_required: 'true'
397
- post_install_message:
398
397
  rdoc_options: []
399
398
  require_paths:
400
399
  - lib
@@ -409,8 +408,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
409
408
  - !ruby/object:Gem::Version
410
409
  version: '0'
411
410
  requirements: []
412
- rubygems_version: 3.5.3
413
- signing_key:
411
+ rubygems_version: 3.6.9
414
412
  specification_version: 4
415
413
  summary: Production readiness checks and runtime guards for Rails Solid Queue.
416
414
  test_files: []