hirefire-resource 1.0.5 → 1.0.6
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 +4 -0
- data/lib/hirefire/macro/bunny.rb +10 -0
- data/lib/hirefire/macro/good_job.rb +2 -0
- data/lib/hirefire/macro/helpers/good_job.rb +15 -0
- data/lib/hirefire/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0d45d749acb1ce30e85634881f98f7259e9b2bd24f6f76983d2e5c946e1222d1
|
|
4
|
+
data.tar.gz: 9f5b1702bef3cda52f67ea3b1ff35045a600cf0df83da2f17e3c608b4890481d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 65e6fd490177ea36113595126becc4b32d7068852f3a4b03af53a43327961f80726ea5e7deb01b4e20c9ea5db7c2601bea4c3c1c9e1e55f773bb84d7a5ff9606
|
|
7
|
+
data.tar.gz: 27fcb7a34f1383e44cff4243e9ec61748ac9947efcead5c649b12f9c19bdec150225781046ce57f62d622ae5a7e8ac8b4d4ee0f753b8adfe9471fed5300fc939
|
data/CHANGELOG.md
CHANGED
data/lib/hirefire/macro/bunny.rb
CHANGED
|
@@ -25,6 +25,16 @@ module HireFire
|
|
|
25
25
|
# with the accurate counting of jobs that are currently scheduled to run, leading to
|
|
26
26
|
# premature upscaling. If you want to be able to schedule jobs to run in the future,
|
|
27
27
|
# consider using the Delayed Message Plugin for RabbitMQ.
|
|
28
|
+
#
|
|
29
|
+
# @note The method relies on the `message_count` metric to determine the number of "Ready" messages
|
|
30
|
+
# in the queue. When using auto-acknowledgment, messages are acknowledged immediately upon delivery,
|
|
31
|
+
# causing the `message_count` to drop to zero, even if the consumer is processing messages. To ensure
|
|
32
|
+
# accurate metrics:
|
|
33
|
+
# - Enable manual acknowledgment (`manual_ack: true`) so that RabbitMQ tracks unacknowledged messages.
|
|
34
|
+
# - Set a reasonable prefetch limit (`channel.prefetch(x)`) to control the number of messages delivered
|
|
35
|
+
# to the consumer, allowing a measurable backlog to remain in the "Ready" state.
|
|
36
|
+
# This configuration ensures accurate scaling metrics and prevents premature depletion of the queue.
|
|
37
|
+
#
|
|
28
38
|
# @param queues [Array<String, Symbol>] Names of the queues for size measurement.
|
|
29
39
|
# @param amqp_url [String, nil] (optional) RabbitMQ URL for establishing a new connection.
|
|
30
40
|
# @return [Integer] Total job queue size.
|
|
@@ -28,6 +28,7 @@ module HireFire
|
|
|
28
28
|
query = good_job_class
|
|
29
29
|
query = query.where(queue_name: queues) if queues.any?
|
|
30
30
|
query = query.where(performed_at: nil)
|
|
31
|
+
query = query.where.not(error_event: discarded_enum).or(query.where(error_event: nil)) if error_event_supported?
|
|
31
32
|
query = query.where(scheduled_at: ..Time.now).or(query.where(scheduled_at: nil))
|
|
32
33
|
query = query.order(scheduled_at: :asc, created_at: :asc)
|
|
33
34
|
|
|
@@ -55,6 +56,7 @@ module HireFire
|
|
|
55
56
|
query = good_job_class
|
|
56
57
|
query = query.where(queue_name: queues) if queues.any?
|
|
57
58
|
query = query.where(performed_at: nil)
|
|
59
|
+
query = query.where.not(error_event: discarded_enum).or(query.where(error_event: nil)) if error_event_supported?
|
|
58
60
|
query = query.where(scheduled_at: ..Time.now).or(query.where(scheduled_at: nil))
|
|
59
61
|
query.count
|
|
60
62
|
end
|
|
@@ -13,6 +13,21 @@ module HireFire
|
|
|
13
13
|
::GoodJob::Execution
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
|
+
|
|
17
|
+
def error_event_supported?
|
|
18
|
+
Gem::Version.new(::GoodJob::VERSION) >= Gem::Version.new("3.0.0")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
[
|
|
22
|
+
:interrupted,
|
|
23
|
+
:unhandled,
|
|
24
|
+
:handled,
|
|
25
|
+
:retried,
|
|
26
|
+
:retry_stopped,
|
|
27
|
+
:discarded
|
|
28
|
+
].each_with_index do |event, index|
|
|
29
|
+
define_method(:"#{event}_enum") { index }
|
|
30
|
+
end
|
|
16
31
|
end
|
|
17
32
|
end
|
|
18
33
|
end
|
data/lib/hirefire/version.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.6
|
|
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-12-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: appraisal
|