Class: Equipoise::Configuration
- Inherits:
-
Object
- Object
- Equipoise::Configuration
- Defined in:
- lib/equipoise/configuration.rb
Constant Summary collapse
- DEFAULT_BASE_URL =
"https://app.equipoi.se/api/v1"- DEFAULT_OPEN_TIMEOUT =
5- DEFAULT_READ_TIMEOUT =
15- DEFAULT_MAX_RETRIES =
2- LOOPBACK_HOSTS =
%w[localhost 127.0.0.1 ::1 [::1]].freeze
- PRODUCTION_HOST =
"app.equipoi.se"
URI.parse(DEFAULT_BASE_URL).host
Instance Attribute Summary collapse
-
#allow_insecure_http ⇒ Object
Returns the value of attribute allow_insecure_http.
-
#api_key ⇒ Object
— Claude authored — explicit assignment wins; otherwise read ENV each call (rotation-aware).
- #base_url ⇒ Object
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#max_retries ⇒ Object
Returns the value of attribute max_retries.
-
#max_retry_backoff ⇒ Object
Returns the value of attribute max_retry_backoff.
-
#open_timeout ⇒ Object
Returns the value of attribute open_timeout.
-
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
-
#retry_backoff_base ⇒ Object
Returns the value of attribute retry_backoff_base.
- #source ⇒ Object
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
Instance Method Summary collapse
-
#disabled? ⇒ Boolean
— Claude authored — test-mode kill switch (#5).
-
#initialize(env: ENV) ⇒ Configuration
constructor
A new instance of Configuration.
- #validate! ⇒ Object
Constructor Details
#initialize(env: ENV) ⇒ Configuration
Returns a new instance of Configuration.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/equipoise/configuration.rb', line 46 def initialize(env: ENV) @env = env @api_key = nil @base_url = nil @source = nil @open_timeout = DEFAULT_OPEN_TIMEOUT @read_timeout = DEFAULT_READ_TIMEOUT @max_retries = DEFAULT_MAX_RETRIES @retry_backoff_base = 0.5 @max_retry_backoff = 30 @allow_insecure_http = false @enabled = true @logger = nil @user_agent = "equipoise-ruby/#{Equipoise::VERSION}" end |
Instance Attribute Details
#allow_insecure_http ⇒ Object
Returns the value of attribute allow_insecure_http.
33 34 35 |
# File 'lib/equipoise/configuration.rb', line 33 def allow_insecure_http @allow_insecure_http end |
#api_key ⇒ Object
— Claude authored — explicit assignment wins; otherwise read ENV each call (rotation-aware).
71 72 73 |
# File 'lib/equipoise/configuration.rb', line 71 def api_key resolve(@api_key, "EQUIPOISE_API_KEY") end |
#base_url ⇒ Object
75 76 77 |
# File 'lib/equipoise/configuration.rb', line 75 def base_url resolve(@base_url, "EQUIPOISE_API_URL") || DEFAULT_BASE_URL end |
#enabled ⇒ Object
Returns the value of attribute enabled.
33 34 35 |
# File 'lib/equipoise/configuration.rb', line 33 def enabled @enabled end |
#logger ⇒ Object
Returns the value of attribute logger.
33 34 35 |
# File 'lib/equipoise/configuration.rb', line 33 def logger @logger end |
#max_retries ⇒ Object
Returns the value of attribute max_retries.
33 34 35 |
# File 'lib/equipoise/configuration.rb', line 33 def max_retries @max_retries end |
#max_retry_backoff ⇒ Object
Returns the value of attribute max_retry_backoff.
33 34 35 |
# File 'lib/equipoise/configuration.rb', line 33 def max_retry_backoff @max_retry_backoff end |
#open_timeout ⇒ Object
Returns the value of attribute open_timeout.
33 34 35 |
# File 'lib/equipoise/configuration.rb', line 33 def open_timeout @open_timeout end |
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
33 34 35 |
# File 'lib/equipoise/configuration.rb', line 33 def read_timeout @read_timeout end |
#retry_backoff_base ⇒ Object
Returns the value of attribute retry_backoff_base.
33 34 35 |
# File 'lib/equipoise/configuration.rb', line 33 def retry_backoff_base @retry_backoff_base end |
#source ⇒ Object
79 80 81 |
# File 'lib/equipoise/configuration.rb', line 79 def source resolve(@source, "EQUIPOISE_SOURCE") end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
33 34 35 |
# File 'lib/equipoise/configuration.rb', line 33 def user_agent @user_agent end |
Instance Method Details
#disabled? ⇒ Boolean
— Claude authored — test-mode kill switch (#5). When disabled the client short-circuits to a no-op before any network call OR validation, so a stray EQUIPOISE_API_KEY in a producer's test env can never make a live call.
65 66 67 |
# File 'lib/equipoise/configuration.rb', line 65 def disabled? !enabled end |
#validate! ⇒ Object
83 84 85 86 87 88 89 90 |
# File 'lib/equipoise/configuration.rb', line 83 def validate! raise ConfigurationError, "api_key is required (set EQUIPOISE_API_KEY or Equipoise.configure)" if api_key.to_s.empty? raise ConfigurationError, "base_url is required" if base_url.to_s.empty? ensure_secure_transport! ensure_environment_match! true end |