hirefire-resource 1.0.3 → 1.0.5

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: c60897b8911c796781d34001ae15a6eaa7a10baa884803858a235941acfbf438
4
- data.tar.gz: 52ea32f6080f388bac51855b68720dda3399127dba93180f559e22b458338737
3
+ metadata.gz: 8c981cc399cbd8abdb5a0416b0f05286621aef47c03db25fb646607f553976f6
4
+ data.tar.gz: '08047393729ab2f071e4d08cd49e5ca92e6cdeae1ed5875da52df996b6b7b358'
5
5
  SHA512:
6
- metadata.gz: d747c2ea92b9e9de7da34223ae65a1e04d3fd7a1c1f6f931ba8681b960c6060f117f2783650d9d3d4152b26a7ea5dfa0558d14e9137fb6a47799d29288ec7c26
7
- data.tar.gz: f515e6eeba0c96c3f0bce84c797ad21af39824cdc015f74ef011e3dad1d6124e08010e6c7609aebf27cd8a9470fec7f2a3c766d6b9cea9c2fba0b33cfef35497
6
+ metadata.gz: 92e00b6fdc3d51f7a2f363b83b77e6c9da56f2d535e163f2e40fc6c0260bcfaadfea060f0ef3e03e4e19809698d1d898382625cb3f42dc30dd0ad00949b3943b
7
+ data.tar.gz: 3d9780fda27839409e76c48b66143fad5149d5e77217737c2a90004dfb3dea8018b24aad24e00be15030e73d8791c7e8b9126b85b4586e0f9b5242a3922b0923
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## v1.0.5
2
+
3
+ * Increase process name length constraint from 30 to 63.
4
+ * Add tests for `solid_queue ~> 1`.
5
+ * Drop tests for `ruby ~> 2.7`.
6
+
7
+ ## v1.0.4
8
+
9
+ * Add support for `good_job ~> 4`, for the `job_queue_size`, `job_queue_latency` and `queue` (deprecated) macros.
10
+
1
11
  ## v1.0.3
2
12
 
3
13
  * Add support for `que ~> 0` and `que ~> 1`, in addition to `que ~> 2`, for both the `job_queue_size` and `job_queue_latency` macros.
@@ -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)
@@ -1,11 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "hirefire/macro/helpers/good_job"
4
+
3
5
  module HireFire
4
6
  module Macro
5
7
  module Deprecated
6
8
  # Provides backward compatibility with the deprecated GoodJob macro.
7
9
  # For new implementations, refer to {HireFire::Macro::GoodJob}.
8
10
  module GoodJob
11
+ include HireFire::Macro::Helpers::GoodJob
12
+
9
13
  # Retrieves the total number of jobs in the specified queue(s) using GoodJob.
10
14
  #
11
15
  # This method queries the PostgreSQL database through GoodJob. It's capable
@@ -21,8 +25,7 @@ module HireFire
21
25
  # @example Counting jobs in the "default" queue
22
26
  # HireFire::Macro::GoodJob.queue("default")
23
27
  def queue(*queues)
24
- base_class = defined?(::GoodJob::Execution) ? ::GoodJob::Execution : ::GoodJob::Job
25
- scope = base_class.only_scheduled.unfinished
28
+ scope = good_job_class.only_scheduled.unfinished
26
29
  scope = scope.where(queue_name: queues) if queues.any?
27
30
  scope.count
28
31
  end
@@ -1,12 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "helpers/good_job"
3
4
  require_relative "deprecated/good_job"
4
5
 
5
6
  module HireFire
6
7
  module Macro
7
8
  module GoodJob
8
- extend HireFire::Macro::Deprecated::GoodJob
9
9
  extend HireFire::Utility
10
+ extend HireFire::Macro::Helpers::GoodJob
11
+ extend HireFire::Macro::Deprecated::GoodJob
10
12
  extend self
11
13
 
12
14
  # Calculates the maximum job queue latency using GoodJob. If no queues are specified, it
@@ -23,9 +25,9 @@ module HireFire
23
25
  # HireFire::Macro::GoodJob.job_queue_latency(:default, :mailer)
24
26
  def job_queue_latency(*queues)
25
27
  queues = normalize_queues(queues, allow_empty: true)
26
- query = ::GoodJob::Execution
28
+ query = good_job_class
27
29
  query = query.where(queue_name: queues) if queues.any?
28
- query = query.where(finished_at: nil)
30
+ query = query.where(performed_at: nil)
29
31
  query = query.where(scheduled_at: ..Time.now).or(query.where(scheduled_at: nil))
30
32
  query = query.order(scheduled_at: :asc, created_at: :asc)
31
33
 
@@ -50,9 +52,9 @@ module HireFire
50
52
  # HireFire::Macro::GoodJob.job_queue_size(:default, :mailer)
51
53
  def job_queue_size(*queues)
52
54
  queues = normalize_queues(queues, allow_empty: true)
53
- query = ::GoodJob::Execution
55
+ query = good_job_class
54
56
  query = query.where(queue_name: queues) if queues.any?
55
- query = query.where(finished_at: nil)
57
+ query = query.where(performed_at: nil)
56
58
  query = query.where(scheduled_at: ..Time.now).or(query.where(scheduled_at: nil))
57
59
  query.count
58
60
  end
@@ -0,0 +1,19 @@
1
+ module HireFire
2
+ module Macro
3
+ module Helpers
4
+ module GoodJob
5
+ def self.included(base)
6
+ base.send(:private, :good_job_class)
7
+ end
8
+
9
+ def good_job_class
10
+ if Gem::Version.new(::GoodJob::VERSION) >= Gem::Version.new("4.0.0")
11
+ ::GoodJob::Job
12
+ else
13
+ ::GoodJob::Execution
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HireFire
4
- VERSION = "1.0.3"
4
+ VERSION = "1.0.5"
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.3
4
+ version: 1.0.5
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-05-23 00:00:00.000000000 Z
11
+ date: 2024-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appraisal
@@ -50,6 +50,7 @@ files:
50
50
  - lib/hirefire/macro/deprecated/resque.rb
51
51
  - lib/hirefire/macro/deprecated/sidekiq.rb
52
52
  - lib/hirefire/macro/good_job.rb
53
+ - lib/hirefire/macro/helpers/good_job.rb
53
54
  - lib/hirefire/macro/que.rb
54
55
  - lib/hirefire/macro/queue_classic.rb
55
56
  - lib/hirefire/macro/resque.rb
@@ -86,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
87
  - !ruby/object:Gem::Version
87
88
  version: '0'
88
89
  requirements: []
89
- rubygems_version: 3.5.9
90
+ rubygems_version: 3.5.22
90
91
  signing_key:
91
92
  specification_version: 4
92
93
  summary: HireFire integration library for Ruby applications