Shapt (Shapt v0.1.0) View Source

Use this to create your own feature toggle worker as in the example:

defmodule TestModule do
  use Shapt,
    adapter: {Shapt.Adapters.Env, []},
    toggles: [
      feature_x?: %{
        key: "MYAPP_FEATURE_X",
        deadline: ~D[2019-12-31]
        },
      feature_y?: %{
        deadline: ~D[2009-12-31]
        }
      ]
end

Link to this section Summary

Types

A module that implements the Shapt.Adapter behaviour.

Options to configure the adapter. Check the adapter documentation for more details.

Defines a deadline for using the toggle. It's used by Mix.Tasks.Shapt.Expired task and the functions expired?/1 and expired_toggles/0.

The name of a toggle. This name gonna become a function on your module and gonna be name used to identify this toggle on all Shapt mix tasks.

It's a map with options to configure the individual toggle. The only option that Shapt defines is the :deadline. More options can be defined and used by the adapter.

A keywordlist with the toggles names and its configuration.

Options to be passed when using Shapt. It's a keywordlist with the required keys :adapter and :toggles.

Link to this section Types

Specs

adapter() :: module()

A module that implements the Shapt.Adapter behaviour.

Specs

adapter_opts() :: keyword()

Options to configure the adapter. Check the adapter documentation for more details.

Specs

deadline() :: Date.t()

Defines a deadline for using the toggle. It's used by Mix.Tasks.Shapt.Expired task and the functions expired?/1 and expired_toggles/0.

Specs

toggle_name() :: atom()

The name of a toggle. This name gonna become a function on your module and gonna be name used to identify this toggle on all Shapt mix tasks.

Specs

toggle_opts() :: %{deadline: deadline()}

It's a map with options to configure the individual toggle. The only option that Shapt defines is the :deadline. More options can be defined and used by the adapter.

Specs

toggles() :: [{toggle_name(), toggle_opts()}]

A keywordlist with the toggles names and its configuration.

Specs

use_opts() :: [adapter: {adapter(), adapter_opts()}, toggles: toggles()]

Options to be passed when using Shapt. It's a keywordlist with the required keys :adapter and :toggles.