View Source Unleash.Strategy.Utils (Unleash v1.10.0)

Utilities that might help you create your own strategies.

Automatically aliased when useing 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

Link to this function

in_list?(list, member, transform \\ &noop/1)

View Source

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
Link to this function

normalize(id, group_id, normalizer \\ 100)

View Source

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