hirefire-resource 0.8.0 → 0.10.0

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: bf1b333fe0b454c20c681c25fcc71f0f848f241421ceedde11e30ba5f29a467f
4
- data.tar.gz: 76cd10b7c38c130405db1988267cb861c9b0a4ca69a38b8e30404dbc92d576f1
3
+ metadata.gz: affa2055a22d9ebc019b20ddace8e5fe042bd7c04115735d88fac5710458eb1d
4
+ data.tar.gz: d5b2aa9fade2670ca74f1af8e3ed3ba76cfb0b520d0794077f1e0e0bc5e8459b
5
5
  SHA512:
6
- metadata.gz: cab33d00cef820b5f895638e5b905c2ae30fcda10de6d890a168bfa4635643fdb6a2a074ebe1863476d8086c8615974dc0123e0b890e4dd147aea2c135107db7
7
- data.tar.gz: df331cea509df6b7c1f58c8d65471479157dd4ce43179d5150b9cfe61144d2d9f1dd7da50cdd455ad28245dafbe748b671a1af72cdccf85846ce304ee25657d7
6
+ metadata.gz: 5f3455375d6259f6d1142056af6c3285fcbfe6aafeac6e0d92778b49e9a2818378edebe6d68f6cecf74522e11b78932361f69c5fe4328ca3768937a42a7541ed
7
+ data.tar.gz: aad73cc64b02064a4b8d4bd451f578415939300dcaeed6345315bcff99268943c70d774c820d591b7deaa6afd60edeee1c2fd64928847078111f4ccd8c6fafb9
@@ -0,0 +1,16 @@
1
+ name: Ruby
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 3.0.2
14
+ bundler-cache: true
15
+ - name: Run standardrb
16
+ run: bundle exec rake standard
data/CHANGELOG.md CHANGED
@@ -1,4 +1,24 @@
1
- ## v0.8.0/Master
1
+ ## v0.10.0
2
+
3
+ * Support Latency (Sidekiq)
4
+ * Rename the "quantity" property to "value" in JSON response ("quantity" is still supported)
5
+
6
+ ## v0.9.1
7
+
8
+ * Support GoodJob > 2.2 where Job class is renamed to Execution
9
+
10
+ ## v0.9.0
11
+
12
+ * Add `skip_working` to Sidekiq macro
13
+ * Use separate queries for Que 0.x and 1.x
14
+ * Remove `# encoding: utf-8` magic comments
15
+ * Add `# frozen_string_literal: true` magic comments
16
+
17
+ ## v0.8.1
18
+
19
+ * Correct GoodJob macro to not count finished jobs.
20
+
21
+ ## v0.8.0
2
22
 
3
23
  * Add GoodJob macro for `good_job` adapter. https://github.com/bensheldon/good_job
4
24
 
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ gemspec
8
+
9
+ gem "rake"
10
+ gem "standardrb"
data/Gemfile.lock ADDED
@@ -0,0 +1,49 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ hirefire-resource (0.9.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ parallel (1.21.0)
11
+ parser (3.0.3.2)
12
+ ast (~> 2.4.1)
13
+ rainbow (3.0.0)
14
+ rake (13.0.6)
15
+ regexp_parser (2.2.0)
16
+ rexml (3.2.5)
17
+ rubocop (1.23.0)
18
+ parallel (~> 1.10)
19
+ parser (>= 3.0.0.0)
20
+ rainbow (>= 2.2.2, < 4.0)
21
+ regexp_parser (>= 1.8, < 3.0)
22
+ rexml
23
+ rubocop-ast (>= 1.12.0, < 2.0)
24
+ ruby-progressbar (~> 1.7)
25
+ unicode-display_width (>= 1.4.0, < 3.0)
26
+ rubocop-ast (1.15.0)
27
+ parser (>= 3.0.1.1)
28
+ rubocop-performance (1.12.0)
29
+ rubocop (>= 1.7.0, < 2.0)
30
+ rubocop-ast (>= 0.4.0)
31
+ ruby-progressbar (1.11.0)
32
+ standard (1.5.0)
33
+ rubocop (= 1.23.0)
34
+ rubocop-performance (= 1.12.0)
35
+ standardrb (1.0.0)
36
+ standard
37
+ unicode-display_width (2.1.0)
38
+
39
+ PLATFORMS
40
+ x86_64-darwin-20
41
+ x86_64-linux
42
+
43
+ DEPENDENCIES
44
+ hirefire-resource!
45
+ rake
46
+ standardrb
47
+
48
+ BUNDLED WITH
49
+ 2.2.24
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- ## [HireFire](https://www.hirefire.io/) - Autoscaling for your Heroku dynos
1
+ ## [HireFire] - Autoscaling for [Heroku]
2
2
 
3
- Load-based scaling, schedule-based scaling, dyno crash recovery, for [Heroku](https://www.heroku.com/) web- and worker dynos.
3
+ Response times, queue times, job queues, load and schedule-based autoscaling for web and worker dynos on [Heroku].
4
4
 
5
5
  ---
6
6
 
@@ -84,8 +84,12 @@ dj_worker: QUEUES=encode,compress bundle exec rake jobs:work
84
84
 
85
85
  Now that HireFire will scale both of the these dyno types based on their individual queue sizes. To customize how they scale, log in to the HireFire web interface.
86
86
 
87
- Visit the [official website](https://www.hirefire.io/) for more information!
87
+ Visit the [official website] for more information!
88
88
 
89
89
  ### License
90
90
 
91
91
  hirefire-resource is released under the Apache 2.0 license. See LICENSE.
92
+
93
+ [HireFire]: https://www.hirefire.io/
94
+ [official website]: https://www.hirefire.io/
95
+ [Heroku]: https://www.heroku.com/
data/Rakefile CHANGED
@@ -1 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
4
+ require "standard/rake"
@@ -1,23 +1,19 @@
1
- # encoding: utf-8
2
-
3
- Gem::Specification.new do |gem|
4
- gem.name = "hirefire-resource"
5
- gem.version = "0.8.0"
6
- gem.platform = Gem::Platform::RUBY
7
- gem.authors = "Michael van Rooijen"
8
- gem.email = "michael@hirefire.io"
9
- gem.homepage = "https://www.hirefire.io"
10
- gem.summary = "Autoscaling for your Heroku dynos"
11
- gem.description = "Load- and schedule-based scaling for web- and worker dynos"
12
- gem.licenses = ["Apache License"]
13
- gem.metadata = {
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "hirefire-resource"
3
+ spec.version = "0.10.0"
4
+ spec.platform = Gem::Platform::RUBY
5
+ spec.authors = "Michael van Rooijen"
6
+ spec.email = "michael@hirefire.io"
7
+ spec.homepage = "https://www.hirefire.io"
8
+ spec.summary = "Autoscaling for your Heroku dynos"
9
+ spec.description = "Load- and schedule-based scaling for web- and worker dynos"
10
+ spec.licenses = ["Apache License"]
11
+ spec.metadata = {
14
12
  "homepage_uri" => "https://www.hirefire.io",
15
13
  "changelog_uri" => "https://github.com/hirefire/hirefire-resource/blob/master/CHANGELOG.md",
16
14
  "source_code_uri" => "https://github.com/hirefire/hirefire-resource/",
17
- "bug_tracker_uri" => "https://github.com/hirefire/hirefire-resource/issues",
15
+ "bug_tracker_uri" => "https://github.com/hirefire/hirefire-resource/issues"
18
16
  }
19
-
20
- gem.files = %x[git ls-files].split("\n")
21
- gem.executables = ["hirefire", "hirefireapp"]
22
- gem.require_path = "lib"
17
+ spec.files = `git ls-files`.split("\n")
18
+ spec.require_path = "lib"
23
19
  end
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  module HireFire
4
4
  module Macro
@@ -27,10 +27,10 @@ module HireFire
27
27
 
28
28
  queues.flatten!
29
29
 
30
- if queues.last.is_a?(Hash)
31
- options = queues.pop
30
+ options = if queues.last.is_a?(Hash)
31
+ queues.pop
32
32
  else
33
- options = {}
33
+ {}
34
34
  end
35
35
 
36
36
  if options[:durable].nil?
@@ -43,38 +43,33 @@ module HireFire
43
43
  channel = nil
44
44
  begin
45
45
  channel = connection.create_channel
46
- return count_messages(channel, queues, options)
46
+ count_messages(channel, queues, options)
47
47
  ensure
48
- if channel
49
- channel.close
50
- end
48
+ channel&.close
51
49
  end
52
50
  elsif options[:amqp_url]
53
51
  connection = ::Bunny.new(options[:amqp_url])
54
52
  begin
55
53
  connection.start
56
54
  channel = connection.create_channel
57
- return count_messages(channel, queues, options)
55
+ count_messages(channel, queues, options)
58
56
  ensure
59
- if channel
60
- channel.close
61
- end
62
-
57
+ channel&.close
63
58
  connection.close
64
59
  end
65
60
  else
66
- raise %{Must pass in :connection => rabbitmq_connection or :amqp_url => url\n} +
67
- %{For example: HireFire::Macro::Bunny.queue("queue1", :connection => rabbitmq_connection}
61
+ raise %(Must pass in :connection => rabbitmq_connection or :amqp_url => url\n) +
62
+ %{For example: HireFire::Macro::Bunny.queue("queue1", :connection => rabbitmq_connection}
68
63
  end
69
64
  end
70
65
 
71
66
  def count_messages(channel, queue_names, options)
72
67
  queue_names.inject(0) do |sum, queue_name|
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']})
68
+ queue = if options.key?(:'x-max-priority')
69
+ channel.queue(queue_name, durable: options[:durable],
70
+ arguments: {"x-max-priority" => options[:'x-max-priority']})
76
71
  else
77
- queue = channel.queue(queue_name, :durable => options[:durable])
72
+ channel.queue(queue_name, durable: options[:durable])
78
73
  end
79
74
  sum + queue.message_count
80
75
  end
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  module HireFire
4
4
  module Macro
@@ -35,26 +35,26 @@ module HireFire
35
35
  def queue(*queues)
36
36
  queues.flatten!
37
37
 
38
- if queues.last.is_a?(Hash)
39
- options = queues.pop
38
+ options = if queues.last.is_a?(Hash)
39
+ queues.pop
40
40
  else
41
- options = {}
41
+ {}
42
42
  end
43
43
 
44
44
  case options[:mapper]
45
45
  when :active_record
46
46
  c = ::Delayed::Job
47
- c = c.where(:failed_at => nil)
47
+ c = c.where(failed_at: nil)
48
48
  c = c.where("run_at <= ?", Time.now.utc)
49
49
  c = c.where("priority >= ?", options[:min_priority]) if options.key?(:min_priority)
50
50
  c = c.where("priority <= ?", options[:max_priority]) if options.key?(:max_priority)
51
- c = c.where(:queue => queues) unless queues.empty?
51
+ c = c.where(queue: queues) unless queues.empty?
52
52
  c.count.tap { ActiveRecord::Base.clear_active_connections! }
53
53
  when :active_record_2
54
54
  c = ::Delayed::Job
55
- c = c.scoped(:conditions => ["run_at <= ? AND failed_at is NULL", Time.now.utc])
56
- c = c.scoped(:conditions => ["priority >= ?", options[:min_priority]]) if options.key?(:min_priority)
57
- c = c.scoped(:conditions => ["priority <= ?", options[:max_priority]]) if options.key?(:max_priority)
55
+ c = c.scoped(conditions: ["run_at <= ? AND failed_at is NULL", Time.now.utc])
56
+ c = c.scoped(conditions: ["priority >= ?", options[:min_priority]]) if options.key?(:min_priority)
57
+ c = c.scoped(conditions: ["priority <= ?", options[:max_priority]]) if options.key?(:max_priority)
58
58
  # There is no queue column in delayed_job <= 2.x
59
59
  c.count.tap do
60
60
  if ActiveRecord::Base.respond_to?(:clear_active_connections!)
@@ -63,14 +63,14 @@ module HireFire
63
63
  end
64
64
  when :mongoid
65
65
  c = ::Delayed::Job
66
- c = c.where(:failed_at => nil)
66
+ c = c.where(failed_at: nil)
67
67
  c = c.where(:run_at.lte => Time.now.utc)
68
68
  c = c.where(:priority.gte => options[:min_priority]) if options.key?(:min_priority)
69
69
  c = c.where(:priority.lte => options[:max_priority]) if options.key?(:max_priority)
70
70
  c = c.where(:queue.in => queues) unless queues.empty?
71
71
  c.count
72
72
  else
73
- raise %{Must pass in :mapper => :active_record or :mapper => :mongoid\n} +
73
+ raise %(Must pass in :mapper => :active_record or :mapper => :mongoid\n) +
74
74
  %{For example: HireFire::Macro::Delayed::Job.queue("worker", :mapper => :active_record)}
75
75
  end
76
76
  end
@@ -78,4 +78,3 @@ module HireFire
78
78
  end
79
79
  end
80
80
  end
81
-
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  module HireFire
4
4
  module Macro
@@ -16,7 +16,8 @@ module HireFire
16
16
  # @return [Integer] the number of jobs in the queue(s).
17
17
  #
18
18
  def queue(*queues)
19
- scope = ::GoodJob::Job.only_scheduled
19
+ base_class = defined?(::GoodJob::Execution) ? ::GoodJob::Execution : ::GoodJob::Job
20
+ scope = base_class.only_scheduled.unfinished
20
21
  scope = scope.where(queue_name: queues) if queues.any?
21
22
  scope.count
22
23
  end
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  module HireFire
4
4
  module Macro
@@ -21,4 +21,3 @@ module HireFire
21
21
  end
22
22
  end
23
23
  end
24
-
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  module HireFire
4
4
  module Macro
@@ -17,9 +17,11 @@ module HireFire
17
17
  #
18
18
  def queue(*queues)
19
19
  queues = ::Qu.backend.queues if queues.empty?
20
- queues.flatten.inject(0) { |memo, queue| memo += ::Qu.backend.length(queue); memo }
20
+ queues.flatten.inject(0) { |memo, queue|
21
+ memo += ::Qu.backend.length(queue)
22
+ memo
23
+ }
21
24
  end
22
25
  end
23
26
  end
24
27
  end
25
-
@@ -1,12 +1,8 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  module HireFire
4
4
  module Macro
5
5
  module Que
6
- QUERY = %{
7
- SELECT count(*) AS total
8
- FROM que_jobs WHERE run_at < now() }.freeze
9
-
10
6
  extend self
11
7
 
12
8
  # Queries the PostgreSQL database through Que in order to
@@ -20,17 +16,40 @@ FROM que_jobs WHERE run_at < now() }.freeze
20
16
  # @return [Integer] the number of jobs in the queue(s).
21
17
  #
22
18
  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
-
19
+ query = queues.empty? && base_query || base_query + " AND queue IN (#{names(queues)})"
31
20
  results = ::Que.execute(query).first
32
21
  (results[:total] || results["total"]).to_i
33
22
  end
23
+
24
+ private
25
+
26
+ def base_query
27
+ return QUE_V0_QUERY if defined?(::Que::Version)
28
+ return QUE_V1_QUERY if defined?(::Que::VERSION)
29
+ raise "Couldn't find Que version"
30
+ end
31
+
32
+ def names(queues)
33
+ queues.map { |queue| "'#{queue}'" }.join(",")
34
+ end
35
+
36
+ def query_const(query)
37
+ query.gsub(/\s+/, " ").strip.freeze
38
+ end
39
+
40
+ QUE_V0_QUERY = query_const(<<-QUERY)
41
+ SELECT COUNT(*) AS total
42
+ FROM que_jobs
43
+ WHERE run_at < NOW()
44
+ QUERY
45
+
46
+ QUE_V1_QUERY = query_const(<<-QUERY)
47
+ SELECT COUNT(*) AS total
48
+ FROM que_jobs
49
+ WHERE finished_at IS NULL
50
+ AND expired_at IS NULL
51
+ AND run_at <= NOW()
52
+ QUERY
34
53
  end
35
54
  end
36
55
  end
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  module HireFire
4
4
  module Macro
@@ -1,18 +1,29 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  module HireFire
4
4
  module Macro
5
5
  module Sidekiq
6
6
  extend self
7
7
 
8
+ # The latency in seconds for the provided queue.
9
+ #
10
+ # @example Sidekiq Queue Latency Macro Usage
11
+ # HireFire::Macro::Sidekiq.queue # default queue
12
+ # HireFire::Macro::Sidekiq.queue("email") # email queue
13
+ #
14
+ def latency(queue = "default")
15
+ ::Sidekiq::Queue.new(queue).latency
16
+ end
17
+
8
18
  # Counts the amount of jobs in the (provided) Sidekiq queue(s).
9
19
  #
10
- # @example Sidekiq Macro Usage
20
+ # @example Sidekiq Queue Size Macro Usage
11
21
  # HireFire::Macro::Sidekiq.queue # all queues
12
22
  # HireFire::Macro::Sidekiq.queue("email") # only email queue
13
23
  # HireFire::Macro::Sidekiq.queue("audio", "video") # audio and video queues
14
24
  # HireFire::Macro::Sidekiq.queue("email", skip_scheduled: true) # only email, will not count scheduled queue
15
25
  # HireFire::Macro::Sidekiq.queue("audio", skip_retries: true) # only audio, will not count the retries queue
26
+ # HireFire::Macro::Sidekiq.queue("audio", skip_working: true) # only audio, will not count already queued
16
27
  #
17
28
  # @param [Array] queues provide one or more queue names, or none for "all".
18
29
  # @return [Integer] the number of jobs in the queue(s).
@@ -22,10 +33,10 @@ module HireFire
22
33
 
23
34
  queues.flatten!
24
35
 
25
- if queues.last.is_a?(Hash)
26
- options = queues.pop
36
+ options = if queues.last.is_a?(Hash)
37
+ queues.pop
27
38
  else
28
- options = {}
39
+ {}
29
40
  end
30
41
 
31
42
  queues.map!(&:to_s)
@@ -53,14 +64,16 @@ module HireFire
53
64
  in_queues = stats.enqueued
54
65
 
55
66
  if !options[:skip_scheduled]
56
- in_schedule = ::Sidekiq.redis { |c| c.zcount('schedule', '-inf', Time.now.to_f) }
67
+ in_schedule = ::Sidekiq.redis { |c| c.zcount("schedule", "-inf", Time.now.to_f) }
57
68
  end
58
69
 
59
70
  if !options[:skip_retries]
60
- in_retry = ::Sidekiq.redis { |c| c.zcount('retry', '-inf', Time.now.to_f) }
71
+ in_retry = ::Sidekiq.redis { |c| c.zcount("retry", "-inf", Time.now.to_f) }
61
72
  end
62
73
 
63
- in_progress = stats.workers_size
74
+ if !options[:skip_working]
75
+ in_progress = stats.workers_size
76
+ end
64
77
 
65
78
  [in_queues, in_schedule, in_retry, in_progress].compact.inject(&:+)
66
79
  end
@@ -96,15 +109,16 @@ module HireFire
96
109
 
97
110
  now = Time.now.to_i
98
111
 
99
- # Objects yielded to Workers#each:
100
- # https://github.com/mperham/sidekiq/blob/305ab8eedc362325da2e218b2a0e20e510668a42/lib/sidekiq/api.rb#L912
101
- in_progress = ::Sidekiq::Workers.new.select do |key, tid, job|
102
- queues.include?(job['queue']) && job['run_at'] <= now
103
- end.size
112
+ if !options[:skip_working]
113
+ # Objects yielded to Workers#each:
114
+ # https://github.com/mperham/sidekiq/blob/305ab8eedc362325da2e218b2a0e20e510668a42/lib/sidekiq/api.rb#L912
115
+ in_progress = ::Sidekiq::Workers.new.count do |key, tid, job|
116
+ queues.include?(job["queue"]) && job["run_at"] <= now
117
+ end
118
+ end
104
119
 
105
120
  [in_queues, in_schedule, in_retry, in_progress].compact.inject(&:+)
106
121
  end
107
122
  end
108
123
  end
109
124
  end
110
-
@@ -1,15 +1,14 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  module HireFire
4
4
  class Middleware
5
-
6
5
  # Initializes HireFire::Middleware.
7
6
  #
8
7
  # @param [Proc] app call with `env` to continue down the middleware stack.
9
8
  #
10
9
  def initialize(app)
11
- @app = app
12
- @token = ENV["HIREFIRE_TOKEN"]
10
+ @app = app
11
+ @token = ENV["HIREFIRE_TOKEN"]
13
12
  @path_prefix = get_path_prefix
14
13
  end
15
14
 
@@ -77,9 +76,9 @@ module HireFire
77
76
  # @return [String] in text/html format.
78
77
  #
79
78
  def build_test_response
80
- status = 200
79
+ status = 200
81
80
  headers = {"Content-Type" => "text/html"}
82
- body = "HireFire Middleware Found!"
81
+ body = "HireFire Middleware Found!"
83
82
 
84
83
  [status, headers, [body]]
85
84
  end
@@ -91,14 +90,14 @@ module HireFire
91
90
  #
92
91
  def build_info_response
93
92
  entries = HireFire::Resource.dynos.map do |config|
94
- %({"name":"#{config[:name]}","quantity":#{config[:quantity].call || "null"}})
93
+ %({"name":"#{config[:name]}","value":#{config[:value].call || "null"}})
95
94
  end
96
95
 
97
- status = 200
98
- headers = Hash.new
99
- headers["Content-Type"] = "application/json"
96
+ status = 200
97
+ headers = {}
98
+ headers["Content-Type"] = "application/json"
100
99
  headers["Cache-Control"] = "must-revalidate, private, max-age=0"
101
- body = "[" + entries.join(",") + "]"
100
+ body = "[" + entries.join(",") + "]"
102
101
 
103
102
  [status, headers, [body]]
104
103
  end
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  module HireFire
4
4
  class Railtie < ::Rails::Railtie
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  module HireFire
4
4
  module Resource
@@ -42,10 +42,10 @@ module HireFire
42
42
  # Will be used through block-style configuration with the `configure` method.
43
43
  #
44
44
  # @param [Symbol, String] name the name of the dyno as defined in the Procfile.
45
- # @param [Proc] block an Integer containing the quantity calculation logic.
45
+ # @param [Proc] block an Integer containing the value calculation logic.
46
46
  #
47
47
  def dyno(name, &block)
48
- dynos << { :name => name, :quantity => block }
48
+ dynos << {name: name, value: block}
49
49
  end
50
50
  end
51
51
  end
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  HIREFIRE_PATH = File.expand_path("../hirefire", __FILE__)
4
4
 
metadata CHANGED
@@ -1,33 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hirefire-resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.10.0
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: 2020-09-10 00:00:00.000000000 Z
11
+ date: 2021-12-14 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
15
- executables:
16
- - hirefire
17
- - hirefireapp
15
+ executables: []
18
16
  extensions: []
19
17
  extra_rdoc_files: []
20
18
  files:
19
+ - ".github/workflows/main.yml"
21
20
  - ".gitignore"
22
21
  - CHANGELOG.md
22
+ - Gemfile
23
+ - Gemfile.lock
23
24
  - LICENSE
24
25
  - README.md
25
26
  - Rakefile
26
- - bin/hirefire
27
- - bin/hirefireapp
28
27
  - hirefire-resource.gemspec
29
28
  - lib/hirefire-resource.rb
30
- - lib/hirefire/cli.rb
31
29
  - lib/hirefire/macro/bunny.rb
32
30
  - lib/hirefire/macro/delayed_job.rb
33
31
  - lib/hirefire/macro/good_job.rb
@@ -62,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
60
  - !ruby/object:Gem::Version
63
61
  version: '0'
64
62
  requirements: []
65
- rubygems_version: 3.1.2
63
+ rubygems_version: 3.2.22
66
64
  signing_key:
67
65
  specification_version: 4
68
66
  summary: Autoscaling for your Heroku dynos
data/bin/hirefire DELETED
@@ -1,4 +0,0 @@
1
- #! /usr/bin/env ruby
2
-
3
- require File.expand_path("../../lib/hirefire/cli", __FILE__)
4
-
data/bin/hirefireapp DELETED
@@ -1,5 +0,0 @@
1
- #! /usr/bin/env ruby
2
-
3
- puts "Please use the `hirefire` utility instead of the `hirefireapp` utility."
4
- exit 1
5
-
data/lib/hirefire/cli.rb DELETED
@@ -1,48 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require "open-uri"
4
- require "openssl"
5
-
6
- OpenSSL::SSL.send(:remove_const, :VERIFY_PEER)
7
- OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
8
-
9
- def usage
10
- puts(<<-EOS)
11
-
12
- Usage:
13
-
14
- hirefire http://mydomain.com/
15
-
16
- Or locally:
17
-
18
- gem install thin
19
- [bundle exec] thin start -p 3000
20
- hirefire http://127.0.0.1:3000/
21
-
22
- SSL Enabled URLs:
23
-
24
- hirefire https://mydomain.com/
25
-
26
- EOS
27
- end
28
-
29
- if (url = ARGV[0]).nil?
30
- usage
31
- else
32
- begin
33
- response = open(File.join(url, "hirefire", "test")).read
34
- rescue
35
- puts
36
- puts "Error: Could not connect to: #{url}"
37
- usage
38
- exit 1
39
- end
40
-
41
- if response =~ /HireFire/
42
- puts response
43
- else
44
- puts "Error: Could not find HireFire at #{url}."
45
- exit 1
46
- end
47
- end
48
-