Shapt.Adapter behaviour (Shapt v0.1.0) View Source

A behaviour that defines the basic callbacks that a Shapt Adapter needs to implement. This callbacks are just the very basic behavior that an adapter might have.

Link to this section Summary

Types

A map containing all Shapt.toggle_name/0 with the value being the current state of the toggle.

Callbacks

Invoked by the task that generates the template for the adapter. It should return a string that can be used as a template, in case a template is not applyable for the adapter returns an empty string.

Invoked at the start of the worker and everytime a reload takes place to populate the current state of the toggles. It should always return a map with all Shapt.toggle_name/0.

Invoked at the Shapt.Worker.init/1 callback of the worker. Returning :ok means the configuration is valid and the adapter will be able to load the toggle state for the given configuration.

Link to this section Types

Specs

loaded_toggles() :: %{required(Shapt.toggle_name()) => boolean()}

A map containing all Shapt.toggle_name/0 with the value being the current state of the toggle.

Link to this section Callbacks

Link to this callback

create_template(arg1, arg2)

View Source

Specs

create_template(Shapt.adapter_opts(), Shapt.toggles()) :: String.t()

Invoked by the task that generates the template for the adapter. It should return a string that can be used as a template, in case a template is not applyable for the adapter returns an empty string.

Specs

Invoked at the start of the worker and everytime a reload takes place to populate the current state of the toggles. It should always return a map with all Shapt.toggle_name/0.

Link to this callback

validate_configuration(arg1)

View Source

Specs

validate_configuration(Shapt.adapter_opts()) :: :ok | String.t()

Invoked at the Shapt.Worker.init/1 callback of the worker. Returning :ok means the configuration is valid and the adapter will be able to load the toggle state for the given configuration.