solid_queue_guard 1.3.1 → 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: 437b060eb21ee49c674d1f5ddbb34471209bbecd11eef1a99a562249f134b1f1
4
- data.tar.gz: 0fb8e3a58e206ee4a0b78a4c815efb7397c1d5d55e153360d7655eee21ff81fa
3
+ metadata.gz: 0f68d16b641aa34f7cf2cda0731e1f279d4078466271f25bdac801d812a1c050
4
+ data.tar.gz: d9765f83f9e100ec1508603cc6e6c461ca5835a925d32ef30b993d122eafb6ce
5
5
  SHA512:
6
- metadata.gz: 9fd08d490a2dff9d8e4915ed2742a660433c781a3244c321097715aac51c73729c91b5ad2cbcc90200c53c336c6a5f7cd80feb3eaebd426e025426700b5f1db5
7
- data.tar.gz: da19ef71cf30e339ac2576a1749064f4ae904491bc0a67fdd61a9593feea6f2a48a051d13f260d6d0f739a43ed5aaddc5b5ef51e2183f98a58b36dbfdb3888bd
6
+ metadata.gz: 24f148012d857a399cb27ceab0ca17ed9b09e4215610e82aa96d9bbb2fa9b84b05b85e63723ffbe7edd57d65cb8c3ed81305ee0e2650ffb798aeffd55bbc1c11
7
+ data.tar.gz: bcd5ab443291828fbf19100ded2010d54d5d57cf764390623ca5e67d4291fb80c1fca37e5498ada656dfc95e184d8484e0a17e4763a0052f634a186980961bff
data/CHANGELOG.md CHANGED
@@ -5,6 +5,17 @@ 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
+
8
19
  ## [1.3.1] - 2026-07-31
9
20
 
10
21
  ### Fixed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- solid_queue_guard (1.3.1)
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)
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidQueueGuard
4
- VERSION = '1.3.1'
4
+ VERSION = '1.4.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solid_queue_guard
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafael Pissardo