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 +4 -4
- data/CHANGELOG.md +11 -0
- data/Gemfile.lock +1 -1
- data/lib/solid_queue_guard/checks/runtime/recurring_stale_check.rb +45 -5
- data/lib/solid_queue_guard/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0f68d16b641aa34f7cf2cda0731e1f279d4078466271f25bdac801d812a1c050
|
|
4
|
+
data.tar.gz: d9765f83f9e100ec1508603cc6e6c461ca5835a925d32ef30b993d122eafb6ce
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
@@ -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
|
|
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
|
|
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
|