goth v0.8.2 Goth.Config behaviour

Goth.Config is a GenServer that holds the current configuration. This configuration is loaded from one of four places:

  1. a JSON string passed in via your application’s config
  2. a ENV variable passed in via your application’s config
  3. The Application Default Credentials, as defined by https://developers.google.com/identity/protocols/application-default-credentials
  4. an init/1 callback on a custom config module. This init function is passed the current config and must return an {:ok, config} tuple

The Goth.Config server exists mostly for other parts of your application (or other libraries) to pull the current configuration state, via Goth.Config.get/1. If necessary, you can also set config values via Goth.Config.set/2

Summary

Functions

Retrieve a value from the config

Set a value in the config

Callbacks

A callback executed when the Goth.Config server starts

Functions

get(key)

Specs

get(String.t | atom) :: {:ok, any} | :error

Retrieve a value from the config.

init(atom)
set(key, value)

Specs

set(String.t | atom, any) :: :ok

Set a value in the config.

start_link()

Callbacks

init(config)

Specs

init(config :: Keyword.t) :: {:ok, Keyword.t}

A callback executed when the Goth.Config server starts.

The sole argument is the :goth configuration as stored in the application environment. It must return {:ok, keyword} with the updated list of configuration.

To have your module’s init/1 callback called at startup, add your module as the :config_module in the application environment:

config :goth, config_module: MyConfig