hirefire-resource 1.0.1 → 1.0.3
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 +8 -0
- data/README.md +5 -4
- data/lib/hirefire/macro/que.rb +71 -14
- data/lib/hirefire/version.rb +1 -1
- data/lib/hirefire/worker.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c60897b8911c796781d34001ae15a6eaa7a10baa884803858a235941acfbf438
|
4
|
+
data.tar.gz: 52ea32f6080f388bac51855b68720dda3399127dba93180f559e22b458338737
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d747c2ea92b9e9de7da34223ae65a1e04d3fd7a1c1f6f931ba8681b960c6060f117f2783650d9d3d4152b26a7ea5dfa0558d14e9137fb6a47799d29288ec7c26
|
7
|
+
data.tar.gz: f515e6eeba0c96c3f0bce84c797ad21af39824cdc015f74ef011e3dad1d6124e08010e6c7609aebf27cd8a9470fec7f2a3c766d6b9cea9c2fba0b33cfef35497
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## v1.0.3
|
2
|
+
|
3
|
+
* Add support for `que ~> 0` and `que ~> 1`, in addition to `que ~> 2`, for both the `job_queue_size` and `job_queue_latency` macros.
|
4
|
+
|
5
|
+
## v1.0.2
|
6
|
+
|
7
|
+
* Add support for dashes in `HireFire::Worker` names to match the Procfile process naming format. `HireFire::Worker` is implicitly used when configuring HireFire using the `HireFire::Configuration#dyno` method.
|
8
|
+
|
1
9
|
## v1.0.1
|
2
10
|
|
3
11
|
* Fix issue where jobs that were enqueued using `sidekiq < 7.2.1` and then processed with `sidekiq >= 7.2.1` (after updating) resulted in a `NoMethodError: undefined method 'queue' for Hash` error during checkups.
|
data/README.md
CHANGED
@@ -38,10 +38,11 @@ For more information, visit our [home page][HireFire].
|
|
38
38
|
## Release
|
39
39
|
|
40
40
|
1. Update the `HireFire::VERSION` constant.
|
41
|
-
2.
|
42
|
-
3.
|
43
|
-
4.
|
44
|
-
5.
|
41
|
+
2. Update Gemfile locks with `bundle` and `bundle exec appraisal`.
|
42
|
+
3. Ensure that `CHANGELOG.md` is up-to-date.
|
43
|
+
4. Commit changes with `git commit`.
|
44
|
+
5. Create a `git tag` matching the new version (e.g., `v1.0.0`).
|
45
|
+
6. Push the new git tag. Continuous Integration will handle the distribution process.
|
45
46
|
|
46
47
|
## License
|
47
48
|
|
data/lib/hirefire/macro/que.rb
CHANGED
@@ -9,6 +9,8 @@ module HireFire
|
|
9
9
|
extend HireFire::Utility
|
10
10
|
extend self
|
11
11
|
|
12
|
+
VERSION_1_0_0 = Gem::Version.new("1.0.0")
|
13
|
+
|
12
14
|
# Calculates the maximum job queue latency using Que. If no queues are specified, it
|
13
15
|
# measures latency across all available queues.
|
14
16
|
#
|
@@ -22,17 +24,11 @@ module HireFire
|
|
22
24
|
# @example Calculate latency across "default" and "mailer" queues
|
23
25
|
# HireFire::Macro::Que.job_queue_latency(:default, :mailer)
|
24
26
|
def job_queue_latency(*queues)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
#{filter_by_queues_if_any(queues)}
|
31
|
-
ORDER BY run_at ASC LIMIT 1
|
32
|
-
SQL
|
33
|
-
|
34
|
-
result = ::Que.execute(query).first
|
35
|
-
result ? (Time.now - result[:run_at].to_time) : 0.0
|
27
|
+
if version < VERSION_1_0_0
|
28
|
+
job_queue_latency_v0(*queues)
|
29
|
+
else
|
30
|
+
job_queue_latency_v1_v2(*queues)
|
31
|
+
end
|
36
32
|
end
|
37
33
|
|
38
34
|
# Calculates the total job queue size using Que. If no queues are specified, it
|
@@ -48,18 +44,75 @@ module HireFire
|
|
48
44
|
# @example Calculate size across "default" and "mailer" queues
|
49
45
|
# HireFire::Macro::Que.job_queue_size(:default, :mailer)
|
50
46
|
def job_queue_size(*queues)
|
47
|
+
if version < VERSION_1_0_0
|
48
|
+
job_queue_size_v0(*queues)
|
49
|
+
else
|
50
|
+
job_queue_size_v1_v2(*queues)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def job_queue_latency_v0(*queues)
|
51
57
|
query = <<~SQL
|
52
|
-
SELECT
|
58
|
+
SELECT run_at
|
59
|
+
FROM que_jobs
|
60
|
+
WHERE run_at <= NOW()
|
61
|
+
#{filter_by_queues_if_any(queues)}
|
62
|
+
ORDER BY run_at ASC
|
63
|
+
LIMIT 1
|
64
|
+
SQL
|
65
|
+
|
66
|
+
query_job_queue_latency(query)
|
67
|
+
end
|
68
|
+
|
69
|
+
def job_queue_latency_v1_v2(*queues)
|
70
|
+
query = <<~SQL
|
71
|
+
SELECT run_at
|
72
|
+
FROM que_jobs
|
53
73
|
WHERE run_at <= NOW()
|
54
74
|
AND finished_at IS NULL
|
55
75
|
AND expired_at IS NULL
|
56
76
|
#{filter_by_queues_if_any(queues)}
|
77
|
+
ORDER BY run_at ASC
|
78
|
+
LIMIT 1
|
57
79
|
SQL
|
58
80
|
|
59
|
-
|
81
|
+
query_job_queue_latency(query)
|
60
82
|
end
|
61
83
|
|
62
|
-
|
84
|
+
def job_queue_size_v0(*queues)
|
85
|
+
query = <<~SQL
|
86
|
+
SELECT COUNT(*) AS job_queue_size
|
87
|
+
FROM que_jobs
|
88
|
+
WHERE run_at <= NOW()
|
89
|
+
#{filter_by_queues_if_any(queues)}
|
90
|
+
SQL
|
91
|
+
|
92
|
+
query_job_queue_size(query)
|
93
|
+
end
|
94
|
+
|
95
|
+
def job_queue_size_v1_v2(*queues)
|
96
|
+
query = <<~SQL
|
97
|
+
SELECT COUNT(*) AS job_queue_size
|
98
|
+
FROM que_jobs
|
99
|
+
WHERE run_at <= NOW()
|
100
|
+
AND finished_at IS NULL
|
101
|
+
AND expired_at IS NULL
|
102
|
+
#{filter_by_queues_if_any(queues)}
|
103
|
+
SQL
|
104
|
+
|
105
|
+
query_job_queue_size(query)
|
106
|
+
end
|
107
|
+
|
108
|
+
def query_job_queue_latency(query)
|
109
|
+
result = ::Que.execute(query).first
|
110
|
+
result ? (Time.now - result[:run_at].to_time) : 0.0
|
111
|
+
end
|
112
|
+
|
113
|
+
def query_job_queue_size(query)
|
114
|
+
::Que.execute(query).first.fetch(:job_queue_size).to_i
|
115
|
+
end
|
63
116
|
|
64
117
|
def filter_by_queues_if_any(queues)
|
65
118
|
queues = normalize_queues(queues, allow_empty: true)
|
@@ -70,6 +123,10 @@ module HireFire
|
|
70
123
|
def sanitize_sql(value)
|
71
124
|
"'" + value.to_s.gsub(/['"\\]/, '\\\\\\&') + "'"
|
72
125
|
end
|
126
|
+
|
127
|
+
def version
|
128
|
+
Gem::Version.new(defined?(::Que::Version) ? ::Que::Version : ::Que::VERSION)
|
129
|
+
end
|
73
130
|
end
|
74
131
|
end
|
75
132
|
end
|
data/lib/hirefire/version.rb
CHANGED
data/lib/hirefire/worker.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hirefire-resource
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael van Rooijen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: appraisal
|
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
86
|
- !ruby/object:Gem::Version
|
87
87
|
version: '0'
|
88
88
|
requirements: []
|
89
|
-
rubygems_version: 3.5.
|
89
|
+
rubygems_version: 3.5.9
|
90
90
|
signing_key:
|
91
91
|
specification_version: 4
|
92
92
|
summary: HireFire integration library for Ruby applications
|