Class: CongregaPlenum::Configuration

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

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_urlString

Returns Base endpoint for all requests.

Returns:

  • (String)

    Base endpoint for all requests.



44
45
46
# File 'lib/congrega_plenum.rb', line 44

def base_url
  @base_url
end

#loggerLogger

Returns Logger used across adapters/services.

Returns:

  • (Logger)

    Logger used across adapters/services.



54
55
56
# File 'lib/congrega_plenum.rb', line 54

def logger
  @logger
end

#rate_limit_delayFloat

Returns Delay between paginated calls to respect rate limits.

Returns:

  • (Float)

    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

#retriesInteger

Returns How many times requests are retried on transient errors.

Returns:

  • (Integer)

    How many times requests are retried on transient errors.



48
49
50
# File 'lib/congrega_plenum.rb', line 48

def retries
  @retries
end

#retry_delayFloat

Returns Initial backoff delay in seconds.

Returns:

  • (Float)

    Initial backoff delay in seconds.



50
51
52
# File 'lib/congrega_plenum.rb', line 50

def retry_delay
  @retry_delay
end

#timeoutInteger

Returns Timeout (seconds) applied to open/read operations.

Returns:

  • (Integer)

    Timeout (seconds) applied to open/read operations.



46
47
48
# File 'lib/congrega_plenum.rb', line 46

def timeout
  @timeout
end