judoscale-ruby 1.0.0.rc1 → 1.0.0.rc2

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: 26e9809db642f08b7291edeae004fb8619f04bbff3130dc6f34043be85a768df
4
- data.tar.gz: a2ff6a031395e860a238db874212d4d82e106b8bdb91c2b3d948bb94a7c7a312
3
+ metadata.gz: 6ec3b89458d553902b60287bec9c3d5a86db77bc17d525264733e35da6bc4447
4
+ data.tar.gz: ce7fa95c5d69b38f84afe75bb24ab51f07687299eadd112945d2eed75d7c2607
5
5
  SHA512:
6
- metadata.gz: 66423294a4021d1da21f77823d1ede3fbf4204da0ec61c9e90c33fbda2e34a21b77a7d06fcf95e711912ad38ed8d17875c74a8f5b98caefcaaac82b8d26a93e1
7
- data.tar.gz: 948b94b9b8000c7af821a0bf3cbfe1f28317ca70a052b11d46b512b01a718d7e7816fc7e2ec4a7f2a545645401585d2baba6a8927f39448c6d11321c376800ae
6
+ metadata.gz: 01bc6d8713dec20c578fdcbf3dd91cbcf3cf6c1894e7431773d26b4f1fc63fd8b45d5170e8ad47a43b905d0a56f53e0c1f8ab7192056ac10f1bcd11b9d809b44
7
+ data.tar.gz: 227e0a5a91a4f7389d72a0b34fb8b19627616c3f8e772bf05c921f2ed761233e1ff0ff4d4cc937993c35fa92fff660252bd743202a690a4460050df34277c142
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- judoscale-ruby (1.0.0.rc1)
4
+ judoscale-ruby (1.0.0.rc2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["Adam McCrea", "Carlos Antonio da Silva"]
9
9
  spec.email = ["adam@adamlogic.com"]
10
10
 
11
- spec.summary = "This gem works with the Judoscale Heroku add-on to automatically scale your web and worker dynos."
11
+ spec.summary = "This gem is deprecated. See https://github.com/rails-autoscale/rails-autoscale-gems to integrate your Ruby app with the Judoscale Heroku add-on."
12
12
  spec.homepage = "https://judoscale.com"
13
13
  spec.license = "MIT"
14
14
 
@@ -24,4 +24,9 @@ Gem::Specification.new do |spec|
24
24
  spec.require_paths = ["lib"]
25
25
 
26
26
  spec.required_ruby_version = ">= 2.6.0"
27
+
28
+ spec.post_install_message = <<~EOS
29
+ `judoscale-ruby` is deprecated! Please migrate to `rails-autoscale-core`.
30
+ See https://github.com/rails-autoscale/rails-autoscale-gems for the installation guide.
31
+ EOS
27
32
  end
@@ -16,7 +16,7 @@ module Judoscale
16
16
  end
17
17
 
18
18
  def report_metrics(report_json)
19
- post_json "/v1/metrics", report_json
19
+ post_json "/v3/reports", report_json
20
20
  end
21
21
 
22
22
  private
@@ -22,9 +22,14 @@ module Judoscale
22
22
  UUID_REGEXP = /[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/
23
23
  DEFAULT_QUEUE_FILTER = ->(queue_name) { !UUID_REGEXP.match?(queue_name) }
24
24
 
25
- attr_accessor :enabled, :max_queues, :queues, :queue_filter, :track_busy_jobs
25
+ attr_accessor :identifier, :enabled, :max_queues, :queues, :queue_filter, :track_busy_jobs
26
26
 
27
- def initialize
27
+ def initialize(identifier)
28
+ @identifier = identifier
29
+ reset
30
+ end
31
+
32
+ def reset
28
33
  @enabled = true
29
34
  @max_queues = 20
30
35
  @queues = []
@@ -34,24 +39,29 @@ module Judoscale
34
39
 
35
40
  def as_json
36
41
  {
37
- max_queues: max_queues,
38
- queues: queues,
39
- queue_filter: queue_filter != DEFAULT_QUEUE_FILTER,
40
- track_busy_jobs: track_busy_jobs
42
+ identifier => {
43
+ max_queues: max_queues,
44
+ queues: queues,
45
+ queue_filter: queue_filter != DEFAULT_QUEUE_FILTER,
46
+ track_busy_jobs: track_busy_jobs
47
+ }
41
48
  }
42
49
  end
43
50
  end
44
51
 
45
52
  include Singleton
46
53
 
47
- @adapter_configs = {}
54
+ @adapter_configs = []
48
55
  class << self
49
56
  attr_reader :adapter_configs
50
57
  end
51
58
 
52
- def self.add_adapter_config(identifier, config_class)
53
- @adapter_configs[identifier] = config_class
54
- attr_reader identifier
59
+ def self.expose_adapter_config(config_instance)
60
+ adapter_configs << config_instance
61
+
62
+ define_method(config_instance.identifier) do
63
+ config_instance
64
+ end
55
65
  end
56
66
 
57
67
  attr_accessor :api_base_url, :report_interval_seconds, :max_request_size_bytes, :logger
@@ -70,9 +80,7 @@ module Judoscale
70
80
  self.log_level = ENV["JUDOSCALE_LOG_LEVEL"]
71
81
  @logger = ::Logger.new($stdout)
72
82
 
73
- self.class.adapter_configs.each do |identifier, config_class|
74
- instance_variable_set(:"@#{identifier}", config_class.new)
75
- end
83
+ self.class.adapter_configs.each(&:reset)
76
84
  end
77
85
 
78
86
  def dyno=(dyno_string)
@@ -84,9 +92,7 @@ module Judoscale
84
92
  end
85
93
 
86
94
  def as_json
87
- adapter_configs_json = self.class.adapter_configs.each_key.with_object({}) do |identifier, hash|
88
- hash[identifier] = public_send(identifier).as_json
89
- end
95
+ adapter_configs_json = self.class.adapter_configs.reduce({}) { |hash, config| hash.merge!(config.as_json) }
90
96
 
91
97
  {
92
98
  log_level: log_level,
@@ -18,11 +18,11 @@ module Judoscale
18
18
  end
19
19
 
20
20
  def self.adapter_identifier
21
- raise "Implement `self.adapter_identifier` in individual job metrics collectors."
21
+ adapter_config.identifier
22
22
  end
23
23
 
24
24
  def self.adapter_config
25
- Config.instance.public_send(adapter_identifier)
25
+ raise "Implement `self.adapter_config` in individual job metrics collectors."
26
26
  end
27
27
 
28
28
  def initialize
@@ -15,9 +15,7 @@ module Judoscale
15
15
  dyno: config.dyno,
16
16
  pid: Process.pid,
17
17
  config: config.as_json,
18
- adapters: adapters.each_with_object({}) { |adapter, hash|
19
- hash.merge!(adapter.as_json)
20
- },
18
+ adapters: adapters.reduce({}) { |hash, adapter| hash.merge!(adapter.as_json) },
21
19
  metrics: metrics.map { |metric|
22
20
  [
23
21
  metric.time.to_i,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Judoscale
4
- VERSION = "1.0.0.rc1"
4
+ VERSION = "1.0.0.rc2"
5
5
  end
@@ -26,7 +26,8 @@ module Judoscale
26
26
  end
27
27
  end
28
28
 
29
- def self.add_adapter(identifier, adapter_info, metrics_collector: nil)
29
+ def self.add_adapter(identifier, adapter_info, metrics_collector: nil, expose_config: nil)
30
+ Config.expose_adapter_config(expose_config) if expose_config
30
31
  @adapters << Adapter.new(identifier, adapter_info, metrics_collector)
31
32
  end
32
33
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: judoscale-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc1
4
+ version: 1.0.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam McCrea
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-04-12 00:00:00.000000000 Z
12
+ date: 2022-09-07 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email:
@@ -46,7 +46,9 @@ metadata:
46
46
  documentation_uri: https://judoscale.com/docs
47
47
  changelog_uri: https://github.com/judoscale/judoscale-ruby/blob/main/CHANGELOG.md
48
48
  source_code_uri: https://github.com/judoscale/judoscale-ruby
49
- post_install_message:
49
+ post_install_message: |
50
+ `judoscale-ruby` is deprecated! Please migrate to `rails-autoscale-core`.
51
+ See https://github.com/rails-autoscale/rails-autoscale-gems for the installation guide.
50
52
  rdoc_options: []
51
53
  require_paths:
52
54
  - lib
@@ -64,6 +66,6 @@ requirements: []
64
66
  rubygems_version: 3.2.32
65
67
  signing_key:
66
68
  specification_version: 4
67
- summary: This gem works with the Judoscale Heroku add-on to automatically scale your
68
- web and worker dynos.
69
+ summary: This gem is deprecated. See https://github.com/rails-autoscale/rails-autoscale-gems
70
+ to integrate your Ruby app with the Judoscale Heroku add-on.
69
71
  test_files: []