Featurevisor
See all posts

Announcing Featurevisor Elixir SDK

By Fahad Heylaal on

With the introduction of Featurevisor Elixir SDK, you can now use Featurevisor in Elixir and Erlang applications. Not just flags alone, but also gradual rollouts, A/B testing, variables, and more.

Elixir SDK

Head over to the Elixir SDK documentation to get started with Featurevisor in your applications.

The package is published on Hex.pm:

def deps do
[
{:featurevisor, "~> 0.1"}
]
end

Using the SDK

Create an instance with a Featurevisor datafile and evaluate features using ordinary Elixir maps:

f = Featurevisor.create_featurevisor(%{
datafile: datafile,
context: %{
"userId" => "user-123",
"country" => "nl"
}
})
enabled = Featurevisor.enabled?(f, "mobile_experience")
variation = Featurevisor.get_variation(f, "mobile_experience")
welcome_message =
Featurevisor.get_variable_string(
f,
"mobile_experience",
"welcome_message"
)
Featurevisor.close(f)

The same datafiles and evaluation behaviour are shared across all Featurevisor SDKs. A user assigned to a variation by your browser application receives the same variation from an Elixir service when evaluated with the same context.

Built for Elixir and OTP

The SDK follows Elixir and OTP conventions while staying aligned with Featurevisor SDKs in other languages:

  • Concurrent evaluation uses immutable ETS snapshots. Evaluations do not queue through the instance process, making one long lived instance suitable for sharing across application processes.
  • OTP supervision is supported. Applications can use Featurevisor.start_link/1, Featurevisor.child_spec/1, and a registered name under their existing supervision tree.
  • The public API is idiomatic. Datafiles and contexts use ordinary maps, option names use snake case, and flag evaluation uses Featurevisor.enabled?/2.
  • Diagnostics, modules, events, and child instances are included. Applications can observe and extend evaluations using the same concepts available in the other Featurevisor SDKs.
  • Project tests run through the Elixir SDK. The command line runner can execute Featurevisor test specs, benchmarks, and distribution assessments against the Elixir implementation.

Supervised applications

Long running OTP applications can place Featurevisor in a supervision tree:

children = [
{Featurevisor,
name: MyApp.Featurevisor,
datafile: datafile}
]
Supervisor.start_link(
children,
strategy: :one_for_one,
name: MyApp.Supervisor
)

Resolve the evaluation handle wherever it is needed:

f = Featurevisor.instance(MyApp.Featurevisor)
Featurevisor.enabled?(f, "my_feature", %{"userId" => "user-123"})

The supervisor owns restart and shutdown behaviour, including module cleanup.

Repositories

You may find these GitHub repositories useful:

Reach out

If you would like to contribute to the Elixir SDK or have any questions, feel free to reach out on GitHub.