hirefire-resource 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c981cc399cbd8abdb5a0416b0f05286621aef47c03db25fb646607f553976f6
4
- data.tar.gz: '08047393729ab2f071e4d08cd49e5ca92e6cdeae1ed5875da52df996b6b7b358'
3
+ metadata.gz: 0d45d749acb1ce30e85634881f98f7259e9b2bd24f6f76983d2e5c946e1222d1
4
+ data.tar.gz: 9f5b1702bef3cda52f67ea3b1ff35045a600cf0df83da2f17e3c608b4890481d
5
5
  SHA512:
6
- metadata.gz: 92e00b6fdc3d51f7a2f363b83b77e6c9da56f2d535e163f2e40fc6c0260bcfaadfea060f0ef3e03e4e19809698d1d898382625cb3f42dc30dd0ad00949b3943b
7
- data.tar.gz: 3d9780fda27839409e76c48b66143fad5149d5e77217737c2a90004dfb3dea8018b24aad24e00be15030e73d8791c7e8b9126b85b4586e0f9b5242a3922b0923
6
+ metadata.gz: 65e6fd490177ea36113595126becc4b32d7068852f3a4b03af53a43327961f80726ea5e7deb01b4e20c9ea5db7c2601bea4c3c1c9e1e55f773bb84d7a5ff9606
7
+ data.tar.gz: 27fcb7a34f1383e44cff4243e9ec61748ac9947efcead5c649b12f9c19bdec150225781046ce57f62d622ae5a7e8ac8b4d4ee0f753b8adfe9471fed5300fc939
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v1.0.6
2
+
3
+ * Ensure that discarded jobs are not used when measuring queue size and latency with Good Job v3 and v4.
4
+
1
5
  ## v1.0.5
2
6
 
3
7
  * Increase process name length constraint from 30 to 63.
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HireFire
4
- VERSION = "1.0.5"
4
+ VERSION = "1.0.6"
5
5
  end
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.5
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-15 00:00:00.000000000 Z
11
+ date: 2024-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appraisal