View Source Unleash.Strategy.Utils (Unleash v1.10.0)
Utilities that might help you create your own strategies.
Automatically alias
ed when use
ing Unleash.Strategy
Summary
Functions
Given a comma-separated list and a member, check to see if the member is in the list. An optional transformation function can be passed in to apply to the items in the list.
Given an ID and group ID, normalize them using a Murmur
hash. Used in all
strategies that provide "stickiness".
Parse a string to a non-negative integer, returning only the number or 0 if it isn't just a number.
Functions
Given a comma-separated list and a member, check to see if the member is in the list. An optional transformation function can be passed in to apply to the items in the list.
Examples
iex> in_list?("a,B,c,D", "b", &String.downcase/1)
true
iex> in_list?("a,B,c,D", "b")
false
Given an ID and group ID, normalize them using a Murmur
hash. Used in all
strategies that provide "stickiness".
See the
gradualRolloutUserId
strategy.
@spec parse_int(x :: String.t()) :: non_neg_integer()
Parse a string to a non-negative integer, returning only the number or 0 if it isn't just a number.
Examples
iex> parse_int("5")
5
iex> parse_int("5ab23a")
0
iex> parse_int(5)
5