workhorse 1.4.5 → 1.5.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: ef9cd623d06cab42a5c5a849f9a5c334c0bb8f4dd517f2c84e5ba3c4df611b24
4
- data.tar.gz: 9681900417bc660a347afeeaebf6cf57fa342268afc38c24b4e5ce11479ce1e3
3
+ metadata.gz: d1159cb21bdb8fcb4a31ae5857ad5dcc16191879ac6f8025830b97cb6627df8c
4
+ data.tar.gz: c963ee57e992cf754cde1e91df6a93d7d207aff663b3bbdae443050605918e63
5
5
  SHA512:
6
- metadata.gz: 86a5b9f9db82efbd890dc77fa763dcc1052027df45d922358428e721bfe3e900670e28b1e55af06e04972fef7c6408fe8a445239443f0707063281d4baf344fe
7
- data.tar.gz: 74f47b979b3589b5530947638c7ec7a6acbb9f85599c88bd9eccaf25fcecf5a92addecb58fa9357bc07eb840bf16b31e5a7fe7fe2f9a6e11fa697b31d9aaf526
6
+ metadata.gz: 05b57e6750c6bdf4d693d503f0d0659f7dcb23c49c6a3f11d47ed31ba665cf5b5bae1f1aa6c6ea925fa35125260da37e9b31aeccd644e9cbefce26c50284104b
7
+ data.tar.gz: f9832222d5b3bd0edb56089c06a6eb1ba36ef4d496580aab83d75a75760c583dd2b74647a0d196be58b3e4f5b91096228bee0cbb7df7cfe9b6efbb7bc92bb32e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # Workhorse Changelog
2
2
 
3
+ ## 1.5.0 - 2026-07-01
4
+
5
+ * Change `DetectStaleJobsJob` to accept `locked_to_started_threshold` and
6
+ `run_time_threshold` as keyword arguments instead of reading from global
7
+ configuration. The config options `Workhorse.stale_detection_locked_to_started_threshold`
8
+ and `Workhorse.stale_detection_run_time_threshold` have been removed.
9
+
10
+ If you were previously configuring thresholds globally:
11
+
12
+ ```ruby
13
+ # Before
14
+ Workhorse.setup do |config|
15
+ config.stale_detection_locked_to_started_threshold = 300
16
+ config.stale_detection_run_time_threshold = 3600
17
+ end
18
+ Workhorse.enqueue(DetectStaleJobsJob.new)
19
+
20
+ # After
21
+ Workhorse.enqueue(DetectStaleJobsJob.new(locked_to_started_threshold: 300, run_time_threshold: 3600))
22
+ ```
23
+
24
+ * Add `queues` keyword argument to `DetectStaleJobsJob` to restrict stale job
25
+ detection to specific queues. When omitted, all queues are checked (existing
26
+ behavior).
27
+
28
+ Sitrox reference: #132256.
29
+
3
30
  ## 1.4.5 - 2026-05-09
4
31
 
5
32
  * Close the lockfile after releasing the lock in the ShellHandler.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.5
1
+ 1.5.0
@@ -5,24 +5,27 @@ module Workhorse::Jobs
5
5
  # exception is thrown (which may cause a notification if you configured
6
6
  # {Workhorse.on_exception} accordingly).
7
7
  #
8
- # The thresholds are obtained from the configuration options
9
- # {Workhorse.stale_detection_locked_to_started_threshold} and
10
- # {Workhorse.stale_detection_run_time_threshold}.
11
- #
12
- # @example Schedule stale job detection
8
+ # @example Schedule stale job detection with default thresholds
13
9
  # Workhorse.enqueue(DetectStaleJobsJob.new)
14
10
  #
15
- # @example Configure thresholds
16
- # Workhorse.setup do |config|
17
- # config.stale_detection_locked_to_started_threshold = 300 # 5 minutes
18
- # config.stale_detection_run_time_threshold = 3600 # 1 hour
19
- # end
11
+ # @example Schedule with custom thresholds
12
+ # Workhorse.enqueue(DetectStaleJobsJob.new(locked_to_started_threshold: 300, run_time_threshold: 3600))
13
+ #
14
+ # @example Only check specific queues
15
+ # Workhorse.enqueue(DetectStaleJobsJob.new(queues: ['mailer', 'reports']))
20
16
  class DetectStaleJobsJob
21
17
  # Creates a new stale job detection job.
22
- # Reads configuration thresholds at initialization time.
23
- def initialize
24
- @locked_to_started_threshold = Workhorse.stale_detection_locked_to_started_threshold
25
- @run_time_threshold = Workhorse.stale_detection_run_time_threshold
18
+ #
19
+ # @param locked_to_started_threshold [Integer] Maximum number of seconds a job is
20
+ # allowed to stay 'locked' before an exception is raised. Set to 0 to skip this check.
21
+ # @param run_time_threshold [Integer] Maximum number of seconds a job is allowed to
22
+ # run before an exception is raised. Set to 0 to skip this check.
23
+ # @param queues [Array<String>, nil] If given, only check jobs in these queues.
24
+ # If `nil` (default), all queues are checked.
25
+ def initialize(locked_to_started_threshold: 3 * 60, run_time_threshold: 12 * 60, queues: nil)
26
+ @locked_to_started_threshold = locked_to_started_threshold
27
+ @run_time_threshold = run_time_threshold
28
+ @queues = queues
26
29
  end
27
30
 
28
31
  # Executes the stale job detection.
@@ -38,6 +41,7 @@ module Workhorse::Jobs
38
41
  if @locked_to_started_threshold != 0
39
42
  rel = Workhorse::DbJob.locked
40
43
  rel = rel.where('locked_at < ?', @locked_to_started_threshold.seconds.ago)
44
+ rel = rel.where(queue: @queues) if @queues
41
45
  ids = rel.pluck(:id)
42
46
 
43
47
  unless ids.empty?
@@ -50,6 +54,7 @@ module Workhorse::Jobs
50
54
  if @run_time_threshold != 0
51
55
  rel = Workhorse::DbJob.started
52
56
  rel = rel.where('started_at < ?', @run_time_threshold.seconds.ago)
57
+ rel = rel.where(queue: @queues) if @queues
53
58
  ids = rel.pluck(:id)
54
59
 
55
60
  unless ids.empty?
data/lib/workhorse.rb CHANGED
@@ -98,18 +98,6 @@ module Workhorse
98
98
  mattr_accessor :clean_stuck_jobs
99
99
  self.clean_stuck_jobs = false
100
100
 
101
- # This setting is for {Workhorse::Jobs::DetectStaleJobsJob} and specifies the
102
- # maximum number of seconds a job is allowed to stay 'locked' before this job
103
- # throws an exception. Set this to 0 to skip this check.
104
- mattr_accessor :stale_detection_locked_to_started_threshold
105
- self.stale_detection_locked_to_started_threshold = 3 * 60
106
-
107
- # This setting is for {Workhorse::Jobs::DetectStaleJobsJob} and specifies the
108
- # maximum number of seconds a job is allowed to run before this job throws an
109
- # exception. Set this to 0 to skip this check.
110
- mattr_accessor :stale_detection_run_time_threshold
111
- self.stale_detection_run_time_threshold = 12 * 60
112
-
113
101
  # Maximum memory usage per {Workhorse::Worker} process in MB.
114
102
  # When exceeded, the watch command will restart the worker. Set to 0 to disable.
115
103
  #
data/workhorse.gemspec CHANGED
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: workhorse 1.4.5 ruby lib
2
+ # stub: workhorse 1.5.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "workhorse".freeze
6
- s.version = "1.4.5".freeze
6
+ s.version = "1.5.0".freeze
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
10
10
  s.authors = ["Sitrox".freeze]
11
- s.date = "2026-05-09"
11
+ s.date = "2026-07-01"
12
12
  s.files = [".github/workflows/ruby.yml".freeze, ".gitignore".freeze, ".releaser_config".freeze, ".rubocop.yml".freeze, "CHANGELOG.md".freeze, "FAQ.md".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "RUBY_VERSION".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/rubocop".freeze, "lib/active_job/queue_adapters/workhorse_adapter.rb".freeze, "lib/generators/workhorse/install_generator.rb".freeze, "lib/generators/workhorse/templates/bin/workhorse.rb".freeze, "lib/generators/workhorse/templates/config/initializers/workhorse.rb".freeze, "lib/generators/workhorse/templates/create_table_jobs.rb".freeze, "lib/workhorse.rb".freeze, "lib/workhorse/active_job_extension.rb".freeze, "lib/workhorse/daemon.rb".freeze, "lib/workhorse/daemon/shell_handler.rb".freeze, "lib/workhorse/db_job.rb".freeze, "lib/workhorse/enqueuer.rb".freeze, "lib/workhorse/jobs/cleanup_succeeded_jobs.rb".freeze, "lib/workhorse/jobs/detect_stale_jobs_job.rb".freeze, "lib/workhorse/jobs/run_active_job.rb".freeze, "lib/workhorse/jobs/run_rails_op.rb".freeze, "lib/workhorse/performer.rb".freeze, "lib/workhorse/poller.rb".freeze, "lib/workhorse/pool.rb".freeze, "lib/workhorse/scoped_env.rb".freeze, "lib/workhorse/worker.rb".freeze, "test/active_job/queue_adapters/workhorse_adapter_test.rb".freeze, "test/lib/db_schema.rb".freeze, "test/lib/jobs.rb".freeze, "test/lib/test_helper.rb".freeze, "test/workhorse/daemon_test.rb".freeze, "test/workhorse/db_job_test.rb".freeze, "test/workhorse/enqueuer_test.rb".freeze, "test/workhorse/performer_test.rb".freeze, "test/workhorse/poller_test.rb".freeze, "test/workhorse/pool_test.rb".freeze, "test/workhorse/worker_test.rb".freeze, "test/workhorse/yjit_test.rb".freeze, "workhorse.gemspec".freeze]
13
13
  s.homepage = "https://github.com/sitrox/workhorse".freeze
14
14
  s.licenses = ["MIT".freeze]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workhorse
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.5
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sitrox
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-05-09 00:00:00.000000000 Z
10
+ date: 2026-07-01 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activesupport
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  - !ruby/object:Gem::Version
120
120
  version: '0'
121
121
  requirements: []
122
- rubygems_version: 4.0.2
122
+ rubygems_version: 4.0.11
123
123
  specification_version: 4
124
124
  summary: Multi-threaded job backend with database queuing for ruby.
125
125
  test_files: