rails-autoscale-core 1.4.1 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 858deb71031ca2f69317d6117a9deb1336851a671aa5c2de5067ce52f9bdaa81
4
- data.tar.gz: f057b846ef8a46e770f4cb4a2718e2569fc99f28a1a8c971366ea9d9d418dfd2
3
+ metadata.gz: 3a22cddac1042235674c4791e42efaefc877d395b1f30d1be5cd41eea9f305e8
4
+ data.tar.gz: 40881260d060de8799c14ce08142eb6e3d524bc5f91f36157d3a5e4879e32e47
5
5
  SHA512:
6
- metadata.gz: be79605f4d962debdfc3027b634d320ff4ad9f7b0d17d8bd77d296f5ecd5b9fad834cc7356e8cefbf1d4fd4697fd9cc6ddcfc41ef51209681de2d9c21dd393b8
7
- data.tar.gz: 6a61c37727c32d6902e1ac604af7dcd8169d24eb8950413874e55d170852e30f706bbf7d37d4ec32948eb1cdc9f945229bc1f36ba1f04b3a105ca03ab515ac52
6
+ metadata.gz: 8cc88cc9824d09c1b4066d02ebf0dd8c8af4605e3d2fa2949523248494064f3f70fdf25e151674b85b6a71b3badeb7a8ddeb93c4cf00cb2d74db136f53817d49
7
+ data.tar.gz: ab01d857a7a2b9c244cced61071ac265e2a07929cba1042108f01b40af9fba182f5817bd877ef727ff6c6123528a28a1170ce559495f4d9fb3bd4630efcabde0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- judoscale-ruby (1.4.1)
4
+ judoscale-ruby (1.5.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -31,6 +31,7 @@ GEM
31
31
  PLATFORMS
32
32
  arm64-darwin-20
33
33
  arm64-darwin-21
34
+ arm64-darwin-22
34
35
  x86_64-darwin-21
35
36
  x86_64-linux
36
37
 
@@ -5,35 +5,14 @@ require "logger"
5
5
 
6
6
  module Judoscale
7
7
  class Config
8
- class RuntimeContainer
9
- # E.g.:
10
- # (Heroku) => "worker_fast", "3"
11
- # (Render) => "srv-cfa1es5a49987h4vcvfg", "5497f74465-m5wwr", "web" (or "worker", "pserv", "cron", "static")
12
- def initialize(service_name = nil, instance = nil, service_type = nil)
13
- @service_name = service_name
14
- @instance = instance
15
- @service_type = service_type
16
- end
17
-
18
- def to_s
19
- # heroku: 'worker_fast.5'
20
- # render: 'srv-cfa1es5a49987h4vcvfg.5497f74465-m5wwr'
21
- "#{@service_name}.#{@instance}"
22
- end
23
-
24
- def web?
25
- # NOTE: Heroku isolates 'web' as the required _name_ for its web process
26
- # type, Render exposes the actual service type more explicitly
27
- @service_name == "web" || @service_type == "web"
28
- end
29
-
8
+ class RuntimeContainer < String
30
9
  # Since Heroku exposes ordinal dyno 'numbers', we can tell if the current
31
10
  # instance is redundant (and thus skip collecting some metrics sometimes)
32
11
  # We don't have a means of determining that on Render though — so every
33
12
  # instance must be considered non-redundant
34
13
  def redundant_instance?
35
- instance_is_number = Integer(@instance, exception: false)
36
- instance_is_number && instance_is_number != 1
14
+ instance_number = split(".")[1].to_i
15
+ instance_number > 1
37
16
  end
38
17
  end
39
18
 
@@ -106,14 +85,15 @@ module Judoscale
106
85
 
107
86
  if ENV["RENDER_INSTANCE_ID"]
108
87
  instance = ENV["RENDER_INSTANCE_ID"].delete_prefix(ENV["RENDER_SERVICE_ID"]).delete_prefix("-")
109
- @current_runtime_container = RuntimeContainer.new ENV["RENDER_SERVICE_ID"], instance, ENV["RENDER_SERVICE_TYPE"]
88
+ @current_runtime_container = RuntimeContainer.new instance
110
89
  @api_base_url ||= "https://adapter.judoscale.com/api/#{ENV["RENDER_SERVICE_ID"]}"
111
90
  elsif ENV["DYNO"]
112
- service_name, instance = ENV["DYNO"].split "."
113
- @current_runtime_container = RuntimeContainer.new service_name, instance
91
+ @current_runtime_container = RuntimeContainer.new ENV["DYNO"]
92
+ elsif (metadata_uri = ENV["ECS_CONTAINER_METADATA_URI"])
93
+ @current_runtime_container = RuntimeContainer.new(metadata_uri.split("/").last)
114
94
  else
115
95
  # unsupported platform? Don't want to leave @current_runtime_container nil though
116
- @current_runtime_container = RuntimeContainer.new
96
+ @current_runtime_container = RuntimeContainer.new("")
117
97
  end
118
98
  end
119
99
 
@@ -12,6 +12,12 @@ module Judoscale
12
12
  sql
13
13
  end
14
14
 
15
+ def self.table_exists?(table_name)
16
+ ::ActiveRecord::Base.connection.table_exists?(table_name)
17
+ rescue ActiveRecord::NoDatabaseError
18
+ false
19
+ end
20
+
15
21
  private
16
22
 
17
23
  def run_silently(&block)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Judoscale
4
- VERSION = "1.4.1"
4
+ VERSION = "1.5.0"
5
5
  end
@@ -5,12 +5,6 @@ require "judoscale/metrics_store"
5
5
 
6
6
  module Judoscale
7
7
  class WebMetricsCollector < MetricsCollector
8
- # NOTE: We collect metrics on all running web processes since they
9
- # all receive and handle requests independently
10
- def self.collect?(config)
11
- config.current_runtime_container.web?
12
- end
13
-
14
8
  def collect
15
9
  MetricsStore.instance.flush
16
10
  end
metadata CHANGED
@@ -1,18 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-autoscale-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam McCrea
8
8
  - Carlos Antonio da Silva
9
9
  - Jon Sullivan
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-05-04 00:00:00.000000000 Z
13
+ date: 2023-07-21 00:00:00.000000000 Z
14
14
  dependencies: []
15
- description:
15
+ description:
16
16
  email:
17
17
  - hello@judoscale.com
18
18
  executables: []
@@ -49,7 +49,7 @@ metadata:
49
49
  documentation_uri: https://judoscale.com/docs
50
50
  changelog_uri: https://github.com/judoscale/judoscale-ruby/blob/main/CHANGELOG.md
51
51
  source_code_uri: https://github.com/judoscale/judoscale-ruby
52
- post_install_message:
52
+ post_install_message:
53
53
  rdoc_options: []
54
54
  require_paths:
55
55
  - lib
@@ -64,8 +64,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  - !ruby/object:Gem::Version
65
65
  version: '0'
66
66
  requirements: []
67
- rubygems_version: 3.2.32
68
- signing_key:
67
+ rubygems_version: 3.4.10
68
+ signing_key:
69
69
  specification_version: 4
70
70
  summary: This gem works with the Judoscale Heroku add-on to automatically scale your
71
71
  web and worker dynos.