Split (split v0.2.0-rc.0)
The Split.io Elixir thin client.
This module provides a simple API to interact with the Split.io service via the Split Daemon (splitd).
Adding Split to Your Supervision Tree
The most basic approach is to add Split as a child of your application's
top-most supervisor, i.e. lib/my_app/application.ex.
defmodule MyApp.Application do
use Application
def start(_type, _args) do
children = [
# ... other children ...
{Split, [socket_path: "/var/run/split.sock"]}
]
opts = [strategy: :one_for_one, name: MyApp.Supervisor]
Supervisor.start_link(children, opts)
end
endYou can also start Split dynamically by calling Split.Supervisor.start_link/1:
Split.Supervisor.start_link(opts)Options
Split takes a number of keyword arguments as options when starting. The following options are available:
:socket_path: REQUIRED The path to the splitd socket file. For example/var/run/splitd.sock.:pool_size: OPTIONAL The size of the pool of connections to the splitd daemon. Default is the number of online schedulers in the Erlang VM (See: https://www.erlang.org/doc/apps/erts/erl_cmd.html).:connect_timeout: OPTIONAL The timeout in milliseconds to connect to the splitd daemon. Default is1000.
Using the API
Once you have started Split, you are ready to start interacting with the Split.io splitd's daemon to access feature flags and configurations.
Split.get_treatment("user_key", "feature_name")
Summary
Functions
Builds a child specification to use in a Supervisor.
Types
option()
@type option() :: {:socket_path, String.t()} | {:pool_size, non_neg_integer()} | {:connect_timeout, non_neg_integer()}
An option that can be provided when starting Split.
options()
@type options() :: [option()]
split_key()
Functions
child_spec(options)
@spec child_spec(options()) :: Supervisor.child_spec()
Builds a child specification to use in a Supervisor.
Normally not called directly by your code. Instead, it will be
called by your application's Supervisor once you add Split
to its supervision tree.
get_treatment(key, feature_name, attributes \\ %{})
get_treatment_with_config(key, feature_name, attributes \\ %{})
@spec get_treatment_with_config(split_key(), String.t(), map() | nil) :: Split.TreatmentWithConfig.t()
get_treatments(key, feature_names, attributes \\ %{})
get_treatments_by_flag_set(key, flag_set_name, attributes \\ %{})
get_treatments_by_flag_sets(key, flag_set_names, attributes \\ %{})
get_treatments_with_config(key, feature_names, attributes \\ %{})
@spec get_treatments_with_config(split_key(), [String.t()], map() | nil) :: %{ required(String.t()) => Split.TreatmentWithConfig.t() }
get_treatments_with_config_by_flag_set(key, flag_set_name, attributes \\ %{})
@spec get_treatments_with_config_by_flag_set( split_key(), String.t(), map() | nil ) :: %{required(String.t()) => Split.TreatmentWithConfig.t()}
get_treatments_with_config_by_flag_sets(key, flag_set_names, attributes \\ %{})
@spec get_treatments_with_config_by_flag_sets( split_key(), [String.t()], map() | nil ) :: %{required(String.t()) => Split.TreatmentWithConfig.t()}
split(name)
@spec split(String.t()) :: Split.SplitView.t() | nil
split_names()
@spec split_names() :: [String.t()]
splits()
@spec splits() :: [Split.SplitView.t()]