Class: CongregaPlenum::Configuration
- Inherits:
-
Object
- Object
- CongregaPlenum::Configuration
- Defined in:
- lib/congrega_plenum.rb,
sig/congrega_plenum.rbs
Overview
Shared configuration used by the client and services to tweak base URL, timeouts and retry policies. Defaults focus on the public APIs hosted by the Câmara so a regular application can simply call configure and override what differs (timeouts, logger, etc.).
Instance Attribute Summary collapse
-
#base_url ⇒ String
Base endpoint for all requests.
-
#logger ⇒ Logger
Logger used across adapters/services.
-
#rate_limit_delay ⇒ Float
Delay between paginated calls to respect rate limits.
-
#retries ⇒ Integer
How many times requests are retried on transient errors.
-
#retry_delay ⇒ Float
Initial backoff delay in seconds.
-
#timeout ⇒ Integer
Timeout (seconds) applied to open/read operations.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
Builds a configuration instance with safe defaults tuned for the Câmara APIs.
Constructor Details
#initialize ⇒ Configuration
Builds a configuration instance with safe defaults tuned for the Câmara APIs. Those endpoints are known to be HTTPS-only, relatively slow, and rate-limited, so the defaults try to smooth that out.
59 60 61 62 63 64 65 66 |
# File 'lib/congrega_plenum.rb', line 59 def initialize @base_url = 'https://dadosabertos.camara.leg.br/api/v2' @timeout = 30 @retries = 3 @retry_delay = 1.0 @rate_limit_delay = 0.1 @logger = Logger.new($stdout) end |
Instance Attribute Details
#base_url ⇒ String
Returns Base endpoint for all requests.
44 45 46 |
# File 'lib/congrega_plenum.rb', line 44 def base_url @base_url end |
#logger ⇒ Logger
Returns Logger used across adapters/services.
54 55 56 |
# File 'lib/congrega_plenum.rb', line 54 def logger @logger end |
#rate_limit_delay ⇒ Float
Returns Delay between paginated calls to respect rate limits.
52 53 54 |
# File 'lib/congrega_plenum.rb', line 52 def rate_limit_delay @rate_limit_delay end |
#retries ⇒ Integer
Returns How many times requests are retried on transient errors.
48 49 50 |
# File 'lib/congrega_plenum.rb', line 48 def retries @retries end |
#retry_delay ⇒ Float
Returns Initial backoff delay in seconds.
50 51 52 |
# File 'lib/congrega_plenum.rb', line 50 def retry_delay @retry_delay end |
#timeout ⇒ Integer
Returns Timeout (seconds) applied to open/read operations.
46 47 48 |
# File 'lib/congrega_plenum.rb', line 46 def timeout @timeout end |