Daraja.Supervisor (daraja v0.1.0)

Copy Markdown View Source

Optional supervisor that starts Daraja.TokenCache. Add it to your application's supervision tree to enable token caching across all API calls:

children = [
  {Daraja.Supervisor, []}
]

The library is process-free by default; caching is opt-in.

Custom names (umbrella apps)

Use name: to name the supervisor and cache_name: to name the cache process and its ETS table. They must be distinct atoms:

{Daraja.Supervisor, name: :billing_sup, cache_name: :billing_cache}

Then point Daraja.Auth.get_token/1 at the custom cache via config:

# config/config.exs (or the appropriate umbrella child config)
config :daraja, token_cache: :billing_cache

Each BEAM node can only register one ETS named table per atom. Starting two supervisors with the same cache_name: (or both using the default) will fail at startup.

Summary

Functions

Returns a specification to start this module under a supervisor.

Callback implementation for Supervisor.init/1.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

init(opts)

Callback implementation for Supervisor.init/1.

start_link(opts \\ [])