Shapt.Adapters.Env (Shapt v0.1.0) View Source

An adapter to load toggle state from environment variables or an env file.

Link to this section Summary

Types

Configuration for this adapter.

Path to a file that must exist when starting the Shapt worker. The content of the file must be a pair ENVVAR=true per line. This gonna be loaded and used as the state of the toggles.

Additional option to configure the toggle. Elixir.Shapt.Adapters.Env only defines one additional option that is :key. The key is the name of the environment variable to get the toggle state.

Link to this section Types

Specs

adapter_opts() :: [from: :file | :env, file: filename()]

Configuration for this adapter.

  • from: source of the state of the toggles. The only options are :file and :env. If the from is set to :file, the option file is required.

  • file: Required when from is set to :file. It gonna be envinroment variable file used to load the toggles state.

Specs

filename() :: Path.t()

Path to a file that must exist when starting the Shapt worker. The content of the file must be a pair ENVVAR=true per line. This gonna be loaded and used as the state of the toggles.

Specs

toggle_opts() :: %{key: String.t()}

Additional option to configure the toggle. Elixir.Shapt.Adapters.Env only defines one additional option that is :key. The key is the name of the environment variable to get the toggle state.

If there is no :key set for a toggle, the adapter gonna abstract an environment variable from the Shapt.toggle_name(). The environment variable for that case gonna be the Shapt.toggle_name/0 upcased and stripped from a question mark, if there is any.