judoscale-ruby 1.13.2 → 1.13.3

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: e31c011abdc246927a3708a982069e0709d12d8b8a46d9c4b2c5cbc25f440ea2
4
- data.tar.gz: 8f0d36db33954653851d9919e5061b947238a39181103754cc81281147d39fc2
3
+ metadata.gz: 6caa0ab33b7a1b3619b550e988eac92727046cf876aabcd3cb9a6c936c13a44c
4
+ data.tar.gz: bb5928ffa44bd5c2becf32672f310ec128eb90d20fed6dee870cae5d37113d4e
5
5
  SHA512:
6
- metadata.gz: 619b623a687755a189cfba56296ab2060fd65befffa1c665fbcad4a91be96626506f3ebf9ca831b016349c3ac03ecee3fd28edd54f05542ad47197e8b1685b1d
7
- data.tar.gz: 0d901557ad3122cf36392c18a665e518277db83beb06c2fec834da5aa38c41cbbfbc3d5aa1f8c7cbb4f907127f4a977f67963456092fb0e712b4628f1fae4299
6
+ metadata.gz: 836a7c518ea2c42148c2698a847fe1b3a5c7cb48131f06c0686fa764ce590010a517ae1dc4934cd2017a9d9c4097416487965e068320c15426ffe6dc58d0e9da
7
+ data.tar.gz: 7152b6fbf6a409307363516da0635c540d16e2f52b489c8e259ec3a3b60994c70340ae6aa75e6cfa68c678a95ee0a961517506aad768a037f0cefcc4950fa933
@@ -9,7 +9,7 @@ module Judoscale
9
9
  class AdapterApi
10
10
  include Logger
11
11
 
12
- SUCCESS = "success"
12
+ MAX_RETRIES = 3
13
13
  TRANSIENT_ERRORS = [
14
14
  Errno::ECONNREFUSED,
15
15
  Errno::ECONNRESET,
@@ -51,7 +51,7 @@ module Judoscale
51
51
  else FailureResponse.new([response.code, response.message].join(" - "))
52
52
  end
53
53
  rescue *TRANSIENT_ERRORS => ex
54
- if attempts < 3
54
+ if attempts < MAX_RETRIES
55
55
  # TCP timeouts happen sometimes, but they can usually be successfully retried in a moment
56
56
  sleep 0.25 * (2**(attempts - 1))
57
57
  attempts += 1
@@ -6,13 +6,14 @@ require "logger"
6
6
  module Judoscale
7
7
  class Config
8
8
  class RuntimeContainer < String
9
- # Since Heroku exposes ordinal dyno 'numbers', we can tell if the current
10
- # instance is redundant (and thus skip collecting some metrics sometimes)
11
- # We don't have a means of determining that on Render though — so every
12
- # instance must be considered non-redundant
9
+ # Job metrics are collected from a single container per process type when we
10
+ # can identify the ordinal instance (Heroku "web.2", Scalingo "web-2").
11
+ # Opaque IDs (Render, ECS, Railway, etc.) are always non-redundant.
12
+ ORDINAL_CONTAINER = /\A[a-z_]+[.-](\d{1,3})\z/
13
+
13
14
  def redundant_instance?
14
- instance_number = split(".")[1].to_i
15
- instance_number > 1
15
+ match = match(ORDINAL_CONTAINER)
16
+ match ? match[1].to_i > 1 : false
16
17
  end
17
18
  end
18
19
 
@@ -125,6 +126,9 @@ module Judoscale
125
126
  RuntimeContainer.new ENV["FLY_MACHINE_ID"]
126
127
  elsif ENV.include?("RAILWAY_REPLICA_ID")
127
128
  RuntimeContainer.new ENV["RAILWAY_REPLICA_ID"]
129
+ elsif ENV.include?("CONTAINER")
130
+ # Scalingo exposes the container type and index (e.g. "web-1") via CONTAINER.
131
+ RuntimeContainer.new ENV["CONTAINER"]
128
132
  else
129
133
  # Unsupported platform...
130
134
  RuntimeContainer.new("")
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Judoscale
4
- VERSION = "1.13.2"
4
+ VERSION = "1.13.3"
5
5
  end
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.13.2
4
+ version: 1.13.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam McCrea