Class: GeneratorLabs::Config
- Inherits:
-
Object
- Object
- GeneratorLabs::Config
- Defined in:
- lib/generatorlabs/config.rb
Overview
Configuration options for the Generator Labs API client.
All fields are optional. If not provided, default values are used. Create a custom config to override timeouts, retry behavior, or API endpoint.
Instance Attribute Summary collapse
-
#base_url ⇒ String
Custom API base URL (default: “api.generatorlabs.com/4.0/”).
-
#connect_timeout ⇒ Integer
Connection timeout in seconds (default: 5).
-
#max_retries ⇒ Integer
Maximum number of retry attempts (default: 3).
-
#retry_backoff ⇒ Float
Exponential backoff multiplier for retries (default: 1.0).
-
#timeout ⇒ Integer
Request timeout in seconds (default: 30).
Class Method Summary collapse
-
.default ⇒ Config
Create a default configuration with standard values.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Config
constructor
Initialize a new configuration.
Constructor Details
#initialize(options = {}) ⇒ Config
Initialize a new configuration.
60 61 62 63 64 65 66 |
# File 'lib/generatorlabs/config.rb', line 60 def initialize( = {}) @timeout = .fetch(:timeout, 30) @connect_timeout = .fetch(:connect_timeout, 5) @max_retries = .fetch(:max_retries, 3) @retry_backoff = .fetch(:retry_backoff, 1.0) @base_url = .fetch(:base_url, 'https://api.generatorlabs.com/4.0/') end |
Instance Attribute Details
#base_url ⇒ String
Returns Custom API base URL (default: “api.generatorlabs.com/4.0/”). Override this for testing or if using a proxy.
47 48 49 |
# File 'lib/generatorlabs/config.rb', line 47 def base_url @base_url end |
#connect_timeout ⇒ Integer
Returns Connection timeout in seconds (default: 5).
33 34 35 |
# File 'lib/generatorlabs/config.rb', line 33 def connect_timeout @connect_timeout end |
#max_retries ⇒ Integer
Returns Maximum number of retry attempts (default: 3). The SDK automatically retries on connection errors, 5xx server errors, and 429 rate limit errors.
38 39 40 |
# File 'lib/generatorlabs/config.rb', line 38 def max_retries @max_retries end |
#retry_backoff ⇒ Float
Returns Exponential backoff multiplier for retries (default: 1.0). Each retry waits retry_backoff^attemptNum seconds. Set to 2.0 for exponential backoff (1s, 2s, 4s, 8s, etc.).
43 44 45 |
# File 'lib/generatorlabs/config.rb', line 43 def retry_backoff @retry_backoff end |
#timeout ⇒ Integer
Returns Request timeout in seconds (default: 30).
30 31 32 |
# File 'lib/generatorlabs/config.rb', line 30 def timeout @timeout end |
Class Method Details
.default ⇒ Config
Create a default configuration with standard values.
Returns a Config with:
-
timeout: 30 seconds
-
connect_timeout: 5 seconds
-
max_retries: 3
-
retry_backoff: 1.0
-
base_url: “api.generatorlabs.com/4.0/”
81 82 83 |
# File 'lib/generatorlabs/config.rb', line 81 def self.default new end |