Split.RPC.Message (split v0.2.0-rc.0)
Summary
Functions
Represents an RPC message to be sent to splitd.
Builds a message to get the treatment for a specific feature flag.
Builds a message to get the treatment for a specific feature flag with configuration.
Builds a message to get the treatments for multiple feature flags.
Builds a message to get the treatments for a flag set.
Builds a message to get the treatments for multiple flag sets.
Builds a message to get the treatments for multiple feature flags with configuration.
Builds a message to get the treatments for a flag set with configuration.
Builds a message to get the treatments for multiple flag sets with configuration.
Converts an opcode to the corresponding RPC call name.
Builds a message to register a client in splitd.
Builds a message to return information about an specific split (feature flag).
Builds a message to return the names of all the splits (feature flags) currently available in splitd.
Builds a message to return information about all the splits (feature flags) currently available in splitd.
Message that creates and event and sends it to splitd so that it’s queued and submitted to Split.io.
Types
get_treatment_args()
@type get_treatment_args() :: {:key, Split.split_key()} | {:feature_name, String.t()} | {:attributes, map() | nil}
get_treatments_args()
@type get_treatments_args() :: {:key, Split.split_key()} | {:feature_names, [String.t()]} | {:attributes, map() | nil}
opcode()
@type opcode() :: 128 | 160 | 162 | 161 | 24 | 23 | 22 | 21 | 20 | 18 | 19 | 17 | 0
protocol_version()
@type protocol_version() :: 1
@type t() :: %Split.RPC.Message{a: list(), o: opcode(), v: protocol_version()}
Functions
Represents an RPC message to be sent to splitd.
get_treatment(opts)
@spec get_treatment([get_treatment_args()]) :: t()
Builds a message to get the treatment for a specific feature flag.
Examples
iex> Message.get_treatment(
...> key: %{:matching_key => "user_key", :bucketing_key => "bucketing_key"},
...> feature_name: "feature_name"
...> )
%Message{a: ["user_key", "bucketing_key", "feature_name", %{}], o: 17, v: 1}
iex> Message.get_treatment(key: "user_key", feature_name: "feature_name")
%Message{a: ["user_key", nil, "feature_name", %{}], o: 17, v: 1}
get_treatment_with_config(opts)
@spec get_treatment_with_config([get_treatment_args()]) :: t()
Builds a message to get the treatment for a specific feature flag with configuration.
Examples
iex> Message.get_treatment_with_config(
...> key: %{:matching_key => "user_key", :bucketing_key => "bucketing_key"},
...> feature_name: "feature_name"
...> )
%Message{a: ["user_key", "bucketing_key", "feature_name", %{}], o: 19, v: 1}
iex> Message.get_treatment_with_config(
...> key: "user_key",
...> feature_name: "feature_name"
...> )
%Message{a: ["user_key", nil, "feature_name", %{}], o: 19, v: 1}
get_treatments(opts)
@spec get_treatments([get_treatments_args()]) :: t()
Builds a message to get the treatments for multiple feature flags.
Examples
iex> Message.get_treatments(
...> key: %{:matching_key => "user_key", :bucketing_key => "bucketing_key"},
...> feature_names: ["feature_name1", "feature_name2"]
...> )
%Message{
a: ["user_key", "bucketing_key", ["feature_name1", "feature_name2"], %{}],
o: 18,
v: 1
}
iex> Message.get_treatments(
...> key: "user_key",
...> feature_names: ["feature_name1", "feature_name2"]
...> )
%Message{a: ["user_key", nil, ["feature_name1", "feature_name2"], %{}], o: 18, v: 1}
get_treatments_by_flag_set(opts)
@spec get_treatments_by_flag_set([get_treatment_args()]) :: t()
Builds a message to get the treatments for a flag set.
Examples
iex> Message.get_treatments_by_flag_set(
...> key: %{:matching_key => "user_key", :bucketing_key => "bucketing_key"},
...> feature_name: "flag_set_name"
...> )
%Message{
a: ["user_key", "bucketing_key", "flag_set_name", %{}],
o: 21,
v: 1
}
iex> Message.get_treatments_by_flag_set(
...> key: "user_key",
...> feature_name: "flag_set_name"
...> )
%Message{a: ["user_key", nil, "flag_set_name", %{}], o: 21, v: 1}
get_treatments_by_flag_sets(opts)
@spec get_treatments_by_flag_sets([get_treatments_args()]) :: t()
Builds a message to get the treatments for multiple flag sets.
Examples
iex> Message.get_treatments_by_flag_sets(
...> key: %{:matching_key => "user_key", :bucketing_key => "bucketing_key"},
...> feature_names: ["flag_set_name1", "flag_set_name2"]
...> )
%Message{
a: ["user_key", "bucketing_key", ["flag_set_name1", "flag_set_name2"], %{}],
o: 23,
v: 1
}
iex> Message.get_treatments_by_flag_sets(
...> key: "user_key",
...> feature_names: ["flag_set_name1", "flag_set_name2"]
...> )
%Message{a: ["user_key", nil, ["flag_set_name1", "flag_set_name2"], %{}], o: 23, v: 1}
get_treatments_with_config(opts)
@spec get_treatments_with_config([get_treatments_args()]) :: t()
Builds a message to get the treatments for multiple feature flags with configuration.
Examples
iex> Message.get_treatments_with_config(
...> key: %{:matching_key => "user_key", :bucketing_key => "bucketing_key"},
...> feature_names: ["feature_name1", "feature_name2"]
...> )
%Message{
a: ["user_key", "bucketing_key", ["feature_name1", "feature_name2"], %{}],
o: 20,
v: 1
}
iex> Message.get_treatments_with_config(
...> key: "user_key",
...> feature_names: ["feature_name1", "feature_name2"]
...> )
%Message{
a: ["user_key", nil, ["feature_name1", "feature_name2"], %{}],
o: 20,
v: 1
}
get_treatments_with_config_by_flag_set(opts)
@spec get_treatments_with_config_by_flag_set([get_treatment_args()]) :: t()
Builds a message to get the treatments for a flag set with configuration.
Examples
iex> Message.get_treatments_with_config_by_flag_set(
...> key: %{:matching_key => "user_key", :bucketing_key => "bucketing_key"},
...> feature_name: "flag_set_name"
...> )
%Message{
a: ["user_key", "bucketing_key", "flag_set_name", %{}],
o: 22,
v: 1
}
iex> Message.get_treatments_with_config_by_flag_set(
...> key: "user_key",
...> feature_name: "flag_set_name"
...> )
%Message{
a: ["user_key", nil, "flag_set_name", %{}],
o: 22,
v: 1
}
get_treatments_with_config_by_flag_sets(opts)
@spec get_treatments_with_config_by_flag_sets([get_treatments_args()]) :: t()
Builds a message to get the treatments for multiple flag sets with configuration.
Examples
iex> Message.get_treatments_with_config_by_flag_sets(
...> key: %{:matching_key => "user_key", :bucketing_key => "bucketing_key"},
...> feature_names: ["flag_set_name1", "flag_set_name2"]
...> )
%Message{
a: ["user_key", "bucketing_key", ["flag_set_name1", "flag_set_name2"], %{}],
o: 24,
v: 1
}
iex> Message.get_treatments_with_config_by_flag_sets(
...> key: "user_key",
...> feature_names: ["flag_set_name1", "flag_set_name2"]
...> )
%Message{
a: ["user_key", nil, ["flag_set_name1", "flag_set_name2"], %{}],
o: 24,
v: 1
}
opcode_to_rpc_name(int)
Converts an opcode to the corresponding RPC call name.
Examples
iex> Message.opcode_to_rpc_name(@get_treatment_opcode) :get_treatment
iex> Message.opcode_to_rpc_name(@get_treatment_with_config_opcode) :get_treatment_with_config
iex> Message.opcode_to_rpc_name(@get_treatments_opcode) :get_treatments
iex> Message.opcode_to_rpc_name(@get_treatments_with_config_opcode) :get_treatments_with_config
iex> Message.opcode_to_rpc_name(@split_opcode) :split
iex> Message.opcode_to_rpc_name(@splits_opcode) :splits
iex> Message.opcode_to_rpc_name(@split_names_opcode) :split_names
iex> Message.opcode_to_rpc_name(@track_opcode) :track
register()
@spec register() :: t()
Builds a message to register a client in splitd.
Examples
iex> Message.register()
%Message{v: 1, o: 0, a: ["123", "Splitd_Elixir-", 1]}
split(split_name)
Builds a message to return information about an specific split (feature flag).
Examples
iex> Message.split("my_feature")
%Message{v: 1, o: 161, a: ["my_feature"]}
split_names()
@spec split_names() :: t()
Builds a message to return the names of all the splits (feature flags) currently available in splitd.
Examples
iex> Message.split_names()
%Message{v: 1, o: 160, a: []}
splits()
@spec splits() :: t()
Builds a message to return information about all the splits (feature flags) currently available in splitd.
Examples
iex> Message.splits()
%Message{v: 1, o: 162, a: []}
track(key, traffic_type, event_type, value \\ nil, properties \\ %{})
Message that creates and event and sends it to splitd so that it’s queued and submitted to Split.io.
Examples
iex> Message.track("user_key", "traffic_type", "my_event", 1.5, %{foo: "bar"})
%Message{
v: 1,
o: 128,
a: ["user_key", "traffic_type", "my_event", 1.5, %{foo: "bar"}]
}
iex> Message.track("user_key", "traffic_type", "my_event")
%Message{v: 1, o: 128, a: ["user_key", "traffic_type", "my_event", nil, %{}]}