Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion judoscale-ruby/lib/judoscale/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ def reset
self.class.adapter_configs.each(&:reset)

@current_runtime_container =
if ENV.include?("DYNO")
if ENV.include?("JUDOSCALE_CONTAINER")
RuntimeContainer.new ENV["JUDOSCALE_CONTAINER"]
elsif ENV.include?("DYNO")
RuntimeContainer.new ENV["DYNO"]
elsif ENV.include?("RENDER_INSTANCE_ID")
# Deprecated API url using the service ID for legacy render services not using `JUDOSCALE_URL`.
Expand Down
26 changes: 26 additions & 0 deletions judoscale-ruby/test/config_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,32 @@ module Judoscale
end
end

it "initializes the config from JUDOSCALE_CONTAINER ENV var" do
env = {
"JUDOSCALE_CONTAINER" => "custom-container-123",
"JUDOSCALE_URL" => "https://adapter.judoscale.com/api/1234567890"
}

use_env env do
config = Config.instance
_(config.api_base_url).must_equal "https://adapter.judoscale.com/api/1234567890"
_(config.current_runtime_container).must_equal "custom-container-123"
end
end

it "prioritizes JUDOSCALE_CONTAINER over platform-specific ENV vars" do
env = {
"JUDOSCALE_CONTAINER" => "custom-container-123",
"DYNO" => "web.1",
"JUDOSCALE_URL" => "https://adapter.judoscale.com/api/1234567890"
}

use_env env do
config = Config.instance
_(config.current_runtime_container).must_equal "custom-container-123"
end
end

it "allows ENV vars config overrides for the debug and URL" do
env = {
"DYNO" => "web.2",
Expand Down