Aurinko.Application (Aurinko v0.2.1)

Copy Markdown View Source

OTP Application entry point for Aurinko.

Starts and supervises all library processes in dependency order:

Aurinko.Supervisor (one_for_one)
 Aurinko.Cache           ETS-backed TTL response cache
 Aurinko.RateLimiter     Token-bucket rate limiter (per-token + global)
 Aurinko.CircuitBreaker  Per-endpoint circuit breaker state machine
 Client     Req-based HTTP client (depends on above three)
 Aurinko.Telemetry       Telemetry event handler / reporter setup

Startup sequence

  1. Validate config (fail fast with a clear error if credentials are missing).
  2. Start ETS-owning GenServers (Cache, RateLimiter, CircuitBreaker) first.
  3. Start the HTTP client, which reads config and builds the Req base request.
  4. Start Telemetry and optionally attach the default Logger handler.
  5. Log a structured startup summary.

Shutdown

OTP sends :shutdown to children in reverse start order (Telemetry → HTTP Client → CircuitBreaker → RateLimiter → Cache). Each GenServer has a 5 s shutdown timeout to flush in-flight state. The ETS tables owned by Cache, RateLimiter, and CircuitBreaker are automatically deleted when their owning process exits.