specwrk 0.21.2 → 0.21.4

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: 52b6a68ed1cf336c660524fcd9c5e668450b0ce5a28046ccfb7dc7140bf64070
4
- data.tar.gz: 532ab297997be008455c5bd02cade0ff03ef86fb2b4e8a988bd3981feb08f7b2
3
+ metadata.gz: 794dba7b09d0dcf664f9188a6c79274cd7dcaa7eb513cf002c6f610cc110313a
4
+ data.tar.gz: cc8e64d775de00bb49eb90f18de7a87f55a62b7b043fb95545b8151e6e0484b6
5
5
  SHA512:
6
- metadata.gz: 903e0cb393b6a7a2001336aa5792df9485b5b0975206aae3906500acafbdd88bed5d8f0ad824dc565e2b5c4a4dd48d3a3db47c19ad4b9fea3e3d2828fa987e10
7
- data.tar.gz: 38056a0a56c20a5a8de5b6cacc6e161ba153c6b4466d6145c599a8ad1d1b693ee5d81e330d6f77878ecc43d9422a905afa447d5157e287f8df4e4271f069759d
6
+ metadata.gz: c98f4269ee9bdea9a2798d1b98474c430569f656eefe8b30f573f0a221e7e39258bad53904ce2c9994ab0064fdf27c3e0b0b022cfd114297fc0b1325a2b6ba66
7
+ data.tar.gz: feef8c77b996f164ee491630efe426e3735b6f72616df6ac881af4c21e6ecc796aa0990c405e4060990d1b6e479dffc2f0c8079a2641d4e1ff94ccc2c5ef2bcd
data/CHANGELOG.md CHANGED
@@ -1,7 +1,15 @@
1
1
  # Changelog
2
2
 
3
3
  ## Unreleased
4
- [Compare](https://github.com/danielwestendorf/specwrk/compare/v0.21.2...main)
4
+ [Compare](https://github.com/danielwestendorf/specwrk/compare/v0.21.4...main)
5
+
6
+ ## v0.21.4 — 2026-10-12
7
+ [Compare](https://github.com/danielwestendorf/specwrk/compare/v0.21.3...v0.21.4)
8
+ - Return a Rack-compliant empty response when the worker queue is empty — [#199](https://github.com/danielwestendorf/specwrk/pull/199) by [@danielwestendorf](https://github.com/danielwestendorf)
9
+
10
+ ## v0.21.3 — 2026-10-11
11
+ [Compare](https://github.com/danielwestendorf/specwrk/compare/v0.21.2...v0.21.3)
12
+ - Make worker heartbeat intervals and expiration timeouts configurable — [#198](https://github.com/danielwestendorf/specwrk/pull/198) by [@danielwestendorf](https://github.com/danielwestendorf)
5
13
 
6
14
  ## v0.21.2 — 2026-10-10
7
15
  [Compare](https://github.com/danielwestendorf/specwrk/compare/v0.21.1...v0.21.2)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Specwrk
4
- VERSION = "0.21.2"
4
+ VERSION = "0.21.4"
5
5
  end
@@ -12,7 +12,7 @@ module Specwrk
12
12
  if examples.any?
13
13
  [200, {"content-type" => "application/json"}, [JSON.generate(examples)]]
14
14
  elsif pending.empty? && processing.empty? && completed.empty?
15
- [204, {"content-type" => "text/plain"}, ["Waiting for sample to be seeded."]]
15
+ [204, {}, []]
16
16
  elsif completed.any? && processing.empty?
17
17
  [410, {"content-type" => "text/plain"}, ["That's a good lad. Run along now and go home."]]
18
18
  elsif expired_examples.length.positive?
@@ -59,13 +59,18 @@ module Specwrk
59
59
  @expired_examples ||= processing.to_h.select { |_id, example| expired?(example) }
60
60
  end
61
61
 
62
- # Has the worker missed two heartbeat check-ins?
62
+ # Has the worker missed its configured heartbeat timeout?
63
63
  def expired?(example)
64
64
  return false unless example[:worker_id]
65
65
  return false unless example[:processing_started_at]
66
- return false unless example[:processing_started_at] < (Time.now - 20).to_i
67
66
 
68
- workers_last_heartbeats[example[:worker_id]] < Time.now - 20
67
+ timeout = Integer(ENV.fetch("SPECWRK_WORKER_HEARTBEAT_TIMEOUT", "60"))
68
+ raise ArgumentError, "SPECWRK_WORKER_HEARTBEAT_TIMEOUT must be greater than 0" unless timeout.positive?
69
+
70
+ cutoff = Time.now - timeout
71
+ return false unless example[:processing_started_at] < cutoff.to_i
72
+
73
+ workers_last_heartbeats[example[:worker_id]] < cutoff
69
74
  end
70
75
 
71
76
  def workers_last_heartbeats
@@ -97,11 +97,14 @@ module Specwrk
97
97
  end
98
98
 
99
99
  def thump
100
+ heartbeat_interval = Integer(ENV.fetch("SPECWRK_HEARTBEAT_INTERVAL", "5"))
101
+ raise ArgumentError, "SPECWRK_HEARTBEAT_INTERVAL must be greater than 0" unless heartbeat_interval.positive?
102
+
100
103
  while running && !Specwrk.force_quit
101
- sleep 10
104
+ sleep heartbeat_interval
102
105
 
103
106
  begin
104
- client.heartbeat if client.last_request_at.nil? || client.last_request_at < Time.now - 9
107
+ client.heartbeat if client.last_request_at.nil? || client.last_request_at < Time.now - heartbeat_interval + 1
105
108
  rescue
106
109
  warn "Heartbeat failed!"
107
110
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specwrk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.2
4
+ version: 0.21.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Westendorf