hirefire-resource 0.7.2 → 0.8.1

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: 14b05a951639660419ec0e420647752fef4b8e33ad615c0b4706cc70a9ceab87
4
- data.tar.gz: 2567a0a3a2d287d220d80f085b835093b845989969484c4ed1a13460ef07ee2b
3
+ metadata.gz: 78f25c9a7eeb6260b9e218267522c46be2493e9a2a3d9e0fa08b6514a803a62b
4
+ data.tar.gz: 52a780c5a441f99a93bce38a496b107b6da34a0a9493c8697b497a5df7912ac3
5
5
  SHA512:
6
- metadata.gz: 66fa48f86bf1377cb4ce1aa93e460621255a0f4802004d8ed3ba35ecb2fd59bfd86aa980589d9d6f4c6d69e5070195c7214c90858bb1f261dab799691e5ae643
7
- data.tar.gz: ace370aec4f4e8c60d0caa521b996917a3eaee8598a5515219c00e07335a7b211dad9f962bf3b9ae0fb618520ec565c6fc0802a12243f1977d7719c83682f4f4
6
+ metadata.gz: 9cdedb2500afde54bc12355bb54c44ac18b572f9c427d3dd2f84a94e4c9fd912bc0fa5400b357511d9ff3329423e6eace83d57fa9ff66ec75600f4ddb2d24856
7
+ data.tar.gz: 6da6c56397be5a92a5afb337dfbbc57bea9e775ae62274e92d975d6dd248199557043c9cf115f7a38a5a2aa6838e956868dbe629928c7be70a4a4ca48951fdeb
@@ -0,0 +1,36 @@
1
+ ## v0.8.1/Master
2
+
3
+ * Correct GoodJob macro to not count finished jobs.
4
+
5
+ ## v0.8.0
6
+
7
+ * Add GoodJob macro for `good_job` adapter. https://github.com/bensheldon/good_job
8
+
9
+ ## v0.7.5
10
+
11
+ * Fix compatibility issue with Que 1.x (backwards-compatible with Que 0.x).
12
+
13
+ ## v0.7.4
14
+
15
+ * Attempt to fix an issue where the STDOUT IO Stream has been closed for an unknown reason.
16
+ * This resulted in errors in an application with `log_queue_metrics` enabled after a random period of time.
17
+
18
+ ## v0.7.3
19
+
20
+ * Added priority queue support for bunny message count.
21
+ * Allows for passing in the `x-max-priority` option when opening up a queue to check the messages remaining.
22
+ * Usage: `HireFire::Macro::Bunny.queue(queue, amqp_url: url, "x-max-priority": 10 )`
23
+
24
+ ## v0.7.2
25
+
26
+ * Changed Que macro to query take into account scheduled jobs.
27
+
28
+ ## v0.7.1
29
+
30
+ * Made entire library threadsafe.
31
+
32
+ ## v0.7.0
33
+
34
+ * Made `HireFire::Resource.log_queue_metrics` optional. This is now disabled by default.
35
+ * Enable by setting `log_queue_metrics = true`.
36
+ * Required when using the `Manager::Web::Logplex::QueueTime` autoscaling strategy.
data/README.md CHANGED
@@ -6,13 +6,14 @@ Load-based scaling, schedule-based scaling, dyno crash recovery, for [Heroku](ht
6
6
 
7
7
  It supports practically any worker library. We provide out-of-the-box support for:
8
8
 
9
+ * Sidekiq
9
10
  * Delayed Job
10
11
  * Resque
12
+ * GoodJob
11
13
  * Qu
14
+ * Que
12
15
  * QueueClassic
13
- * Sidekiq
14
16
  * Bunny
15
- * Que
16
17
 
17
18
  *Note that you can write your own worker queue logic for almost any other worker library as well.
18
19
  HireFire can scale multiple individual worker libraries at the same time, as well as multiple individual queues for any worker library.*
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "hirefire-resource"
5
- gem.version = "0.7.2"
5
+ gem.version = "0.8.1"
6
6
  gem.platform = Gem::Platform::RUBY
7
7
  gem.authors = "Michael van Rooijen"
8
8
  gem.email = "michael@hirefire.io"
@@ -10,6 +10,12 @@ Gem::Specification.new do |gem|
10
10
  gem.summary = "Autoscaling for your Heroku dynos"
11
11
  gem.description = "Load- and schedule-based scaling for web- and worker dynos"
12
12
  gem.licenses = ["Apache License"]
13
+ gem.metadata = {
14
+ "homepage_uri" => "https://www.hirefire.io",
15
+ "changelog_uri" => "https://github.com/hirefire/hirefire-resource/blob/master/CHANGELOG.md",
16
+ "source_code_uri" => "https://github.com/hirefire/hirefire-resource/",
17
+ "bug_tracker_uri" => "https://github.com/hirefire/hirefire-resource/issues",
18
+ }
13
19
 
14
20
  gem.files = %x[git ls-files].split("\n")
15
21
  gem.executables = ["hirefire", "hirefireapp"]
@@ -6,9 +6,8 @@ HIREFIRE_PATH = File.expand_path("../hirefire", __FILE__)
6
6
  require "#{HIREFIRE_PATH}/#{file}"
7
7
  end
8
8
 
9
- %w[delayed_job resque sidekiq qu qc bunny que].each do |file|
9
+ %w[delayed_job resque sidekiq qu qc bunny que good_job].each do |file|
10
10
  require "#{HIREFIRE_PATH}/macro/#{file}"
11
11
  end
12
12
 
13
13
  require "#{HIREFIRE_PATH}/railtie" if defined?(Rails::Railtie)
14
-
@@ -70,11 +70,15 @@ module HireFire
70
70
 
71
71
  def count_messages(channel, queue_names, options)
72
72
  queue_names.inject(0) do |sum, queue_name|
73
- queue = channel.queue(queue_name, :durable => options[:durable])
73
+ if options.key?(:'x-max-priority')
74
+ queue = channel.queue(queue_name, :durable => options[:durable],
75
+ :arguments => {"x-max-priority" => options[:'x-max-priority']})
76
+ else
77
+ queue = channel.queue(queue_name, :durable => options[:durable])
78
+ end
74
79
  sum + queue.message_count
75
80
  end
76
81
  end
77
82
  end
78
83
  end
79
84
  end
80
-
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+
3
+ module HireFire
4
+ module Macro
5
+ module GoodJob
6
+ extend self
7
+
8
+ # Queries the PostgreSQL database through GoodJob in order to
9
+ # count the amount of jobs in the specified queue.
10
+ #
11
+ # @example Queue Macro Usage
12
+ # HireFire::Macro::GoodJob.queue # counts all queues.
13
+ # HireFire::Macro::GoodJob.queue("email") # counts the `email` queue.
14
+ #
15
+ # @param [String] queue the queue name to count. (default: nil # gets all queues)
16
+ # @return [Integer] the number of jobs in the queue(s).
17
+ #
18
+ def queue(*queues)
19
+ scope = ::GoodJob::Job.only_scheduled.unfinished
20
+ scope = scope.where(queue_name: queues) if queues.any?
21
+ scope.count
22
+ end
23
+ end
24
+ end
25
+ end
@@ -19,10 +19,17 @@ FROM que_jobs WHERE run_at < now() }.freeze
19
19
  # @param [String] queue the queue name to count. (default: nil # gets all queues)
20
20
  # @return [Integer] the number of jobs in the queue(s).
21
21
  #
22
- def queue(queue = nil)
23
- query = queue ? "#{QUERY} AND queue = '#{queue}'" : QUERY
22
+ def queue(*queues)
23
+ query = case
24
+ when queues.none? then QUERY
25
+ when queues.one? then "#{QUERY} AND queue = '#{queues.first}'"
26
+ else
27
+ queue_names = queues.map { |queue| "'#{queue}'" }.join(', ')
28
+ %Q{#{QUERY} AND queue IN (#{queue_names})}
29
+ end
30
+
24
31
  results = ::Que.execute(query).first
25
- results["total"].to_i
32
+ (results[:total] || results["total"]).to_i
26
33
  end
27
34
  end
28
35
  end
@@ -19,7 +19,7 @@ module HireFire
19
19
  #
20
20
  # When HireFire::Resource.log_queue_metrics is enabled, and the HTTP_X_REQUEST_START
21
21
  # header has been injected at the Heroku Router layer, queue time information will be
22
- # logged to STDOUT. This data can be used by the HireFire Logdrain with the
22
+ # logged to $stdout. This data can be used by the HireFire Logdrain with the
23
23
  # Web.Logplex.QueueTime autoscaling strategy.
24
24
  #
25
25
  # Important: Don't set/update instance variables within this- or any underlying methods.
@@ -103,7 +103,7 @@ module HireFire
103
103
  [status, headers, [body]]
104
104
  end
105
105
 
106
- # Writes the Heroku Router queue time to STDOUT if a String was provided.
106
+ # Writes the Heroku Router queue time to $stdout if a String was provided.
107
107
  #
108
108
  # @param [String] the timestamp from HTTP_X_REQUEST_START.
109
109
  #
@@ -111,12 +111,12 @@ module HireFire
111
111
  HireFire::Resource.log_queue_metrics && value && log_queue(value)
112
112
  end
113
113
 
114
- # Writes the Heroku Router queue time to STDOUT.
114
+ # Writes the Heroku Router queue time to $stdout.
115
115
  #
116
116
  # @param [String] the timestamp from HTTP_X_REQUEST_START.
117
117
  #
118
118
  def log_queue(value)
119
- STDOUT.puts("[hirefire:router] queue=#{get_queue(value)}ms")
119
+ puts("[hirefire:router] queue=#{get_queue(value)}ms")
120
120
  end
121
121
 
122
122
  # Calculates the difference, in milliseconds, between the
@@ -4,7 +4,7 @@ module HireFire
4
4
  module Resource
5
5
  extend self
6
6
 
7
- # This option, when enabled, will write queue metrics to STDOUT,
7
+ # This option, when enabled, will write queue metrics to $stdout,
8
8
  # and is only required when using the Web.Logplex.QueueTime strategy.
9
9
  #
10
10
  # @param [Boolean] Whether or not the queue metrics should be logged.
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: 0.7.2
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael van Rooijen
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-13 00:00:00.000000000 Z
11
+ date: 2020-09-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Load- and schedule-based scaling for web- and worker dynos
14
14
  email: michael@hirefire.io
@@ -19,6 +19,7 @@ extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
21
  - ".gitignore"
22
+ - CHANGELOG.md
22
23
  - LICENSE
23
24
  - README.md
24
25
  - Rakefile
@@ -29,6 +30,7 @@ files:
29
30
  - lib/hirefire/cli.rb
30
31
  - lib/hirefire/macro/bunny.rb
31
32
  - lib/hirefire/macro/delayed_job.rb
33
+ - lib/hirefire/macro/good_job.rb
32
34
  - lib/hirefire/macro/qc.rb
33
35
  - lib/hirefire/macro/qu.rb
34
36
  - lib/hirefire/macro/que.rb
@@ -40,8 +42,12 @@ files:
40
42
  homepage: https://www.hirefire.io
41
43
  licenses:
42
44
  - Apache License
43
- metadata: {}
44
- post_install_message:
45
+ metadata:
46
+ homepage_uri: https://www.hirefire.io
47
+ changelog_uri: https://github.com/hirefire/hirefire-resource/blob/master/CHANGELOG.md
48
+ source_code_uri: https://github.com/hirefire/hirefire-resource/
49
+ bug_tracker_uri: https://github.com/hirefire/hirefire-resource/issues
50
+ post_install_message:
45
51
  rdoc_options: []
46
52
  require_paths:
47
53
  - lib
@@ -56,8 +62,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
62
  - !ruby/object:Gem::Version
57
63
  version: '0'
58
64
  requirements: []
59
- rubygems_version: 3.0.3
60
- signing_key:
65
+ rubygems_version: 3.1.2
66
+ signing_key:
61
67
  specification_version: 4
62
68
  summary: Autoscaling for your Heroku dynos
63
69
  test_files: []