hirefire-resource 1.0.4 → 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: 1d0159499127d61d2281f345a3c4b50cb1a975012aed540d34a6463b53d5cc77
4
- data.tar.gz: 6424c3fd3462880b0e2a635ddde4fefdce30740b4eee3edaabf7ff9d29a0a895
3
+ metadata.gz: 0d45d749acb1ce30e85634881f98f7259e9b2bd24f6f76983d2e5c946e1222d1
4
+ data.tar.gz: 9f5b1702bef3cda52f67ea3b1ff35045a600cf0df83da2f17e3c608b4890481d
5
5
  SHA512:
6
- metadata.gz: 60f7e44322babde5329e98b57c0698cd0ac9824f98cb4d83de30cd9dc750fdfb8845ddd8916a754d62011f397a2565afe437dd71b1d8f36ab4d8fa6f634cde96
7
- data.tar.gz: f40b10e7e7d7a24824970f19a235619feec0171c374ca5a16ff5263c3a36996a44ad3088ab6aacee7cf8bf9abdf6175d8faa43cb5fc7bc2f4d255ce3ace0dd08
6
+ metadata.gz: 65e6fd490177ea36113595126becc4b32d7068852f3a4b03af53a43327961f80726ea5e7deb01b4e20c9ea5db7c2601bea4c3c1c9e1e55f773bb84d7a5ff9606
7
+ data.tar.gz: 27fcb7a34f1383e44cff4243e9ec61748ac9947efcead5c649b12f9c19bdec150225781046ce57f62d622ae5a7e8ac8b4d4ee0f753b8adfe9471fed5300fc939
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
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
+
5
+ ## v1.0.5
6
+
7
+ * Increase process name length constraint from 30 to 63.
8
+ * Add tests for `solid_queue ~> 1`.
9
+ * Drop tests for `ruby ~> 2.7`.
10
+
1
11
  ## v1.0.4
2
12
 
3
13
  * Add support for `good_job ~> 4`, for the `job_queue_size`, `job_queue_latency` and `queue` (deprecated) macros.
@@ -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.
@@ -37,13 +37,13 @@ module HireFire
37
37
  query = query.where(priority: options[:min_priority]..) if options.key?(:min_priority)
38
38
  query = query.where(priority: ..options[:max_priority]) if options.key?(:max_priority)
39
39
  query = query.where(queue: queues) unless queues.empty?
40
- query.count.tap { ActiveRecord::Base.clear_active_connections! }
40
+ query.count
41
41
  when :active_record_2
42
42
  # Note: There is no queue column in delayed_job <= 2.x
43
43
  query = ::Delayed::Job.scoped(conditions: ["run_at <= ? AND failed_at is NULL", Time.now.utc])
44
44
  query = query.scoped(conditions: ["priority >= ?", options[:min_priority]]) if options.key?(:min_priority)
45
45
  query = query.scoped(conditions: ["priority <= ?", options[:max_priority]]) if options.key?(:max_priority)
46
- query.count.tap { ActiveRecord::Base.clear_active_connections! if ActiveRecord::Base.respond_to?(:clear_active_connections!) }
46
+ query.count
47
47
  when :mongoid
48
48
  query = ::Delayed::Job.where(:failed_at => nil, :run_at.lte => Time.now.utc)
49
49
  query = query.where(:priority.gte => options[:min_priority]) if options.key?(:min_priority)
@@ -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.4"
4
+ VERSION = "1.0.6"
5
5
  end
@@ -6,7 +6,7 @@ module HireFire
6
6
 
7
7
  class MissingDynoBlockError < StandardError; end
8
8
 
9
- PROCESS_NAME_PATTERN = /\A[a-zA-Z][a-zA-Z0-9_-]{0,29}\z/
9
+ PROCESS_NAME_PATTERN = /\A[a-zA-Z][a-zA-Z0-9_-]{0,62}\z/
10
10
 
11
11
  attr_reader :name
12
12
 
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
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-07-26 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
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
89
  requirements: []
90
- rubygems_version: 3.5.11
90
+ rubygems_version: 3.5.22
91
91
  signing_key:
92
92
  specification_version: 4
93
93
  summary: HireFire integration library for Ruby applications