View Source Flagsmith.Engine (flagsmith_engine v0.1.0)

Documentation for Flagsmith.Engine.

Link to this section Summary

Functions

True if an identity is deemed matching a segment conditions & rules, false otherwise.

Get a specific feature state for a given feature_name in a given Environment.t().

Get the feature states of an Environment.t().

Get feature state with a given feature_name for a given Identity.t() and Environment.t().

Get list of feature states for a given Identity.t() in a given Environment.t().

Filters a list of segments accordingly to if they match an identity and traits (optionally using a list of traits to override those in the identity)

Generate a valid environment struct from a json string or map.

Given a list of ids in either and optionally a number of to duplicate them n times, compute a value representing a percentage to which those ids when hashed match. Refer to https://github.com/Flagsmith/flagsmith-engine/blob/c34b4baeea06d31d221433053b64c1e855fd8d4d/flag_engine/utils/hashing.py#L5

Returns a list with elements of any of Environment.FeatureState.t() or Features.FeatureState.t() where any that has the same name as in any of the identity Features.FeatureState.t() provided is replaced by that feature.

Returns a list of Environment.FeatureState.t() where any that has the same name as in the segments provided is replaced by the feature state there specified (if any).

Given an Types.Operator.t(), a cast or uncast segment value, and a cast trait value, evaluate if the trait value matches to the segment value.

True if according to the type of condition operator the co mparison is true, false otherwise. With exception for PERCENTAGE_SPLIT operator all others are matched against the traits passed in.

True if the segment rule conditions all match (or there's no conditions) and all nested rules too (or there's no rules), false otherwise.

Link to this section Functions

Link to this function

evaluate_identity_in_segment(identity, segment, override_traits)

View Source

Specs

True if an identity is deemed matching a segment conditions & rules, false otherwise.

Link to this function

get_environment_feature_state(environment, name)

View Source

Specs

get_environment_feature_state(
  Flagsmith.Schemas.Environment.t(),
  name :: String.t()
) :: Flagsmith.Schemas.Environment.FeatureState.t() | nil

Get a specific feature state for a given feature_name in a given Environment.t().

Link to this function

get_environment_feature_states(environment)

View Source

Specs

Get the feature states of an Environment.t().

Link to this function

get_identity_feature_state(env, identity, name, override_traits \\ [])

View Source

Specs

Get feature state with a given feature_name for a given Identity.t() and Environment.t().

Link to this function

get_identity_feature_states(env, identity, override_traits \\ [])

View Source

Specs

Get list of feature states for a given Identity.t() in a given Environment.t().

Link to this function

get_segment_features(segments, identity, override_traits)

View Source

Specs

Filters a list of segments accordingly to if they match an identity and traits (optionally using a list of traits to override those in the identity)

Specs

parse_environment(data :: map() | String.t()) ::
  {:ok, Flagsmith.Schemas.Environment.t()}
  | {:error, Ecto.Changeset.t()}
  | {:error, term()}

Generate a valid environment struct from a json string or map.

Link to this function

percentage_from_ids(original_ids, iterations \\ 1)

View Source

Specs

percentage_from_ids([String.t() | non_neg_integer()], non_neg_integer()) ::
  float()

Given a list of ids in either and optionally a number of to duplicate them n times, compute a value representing a percentage to which those ids when hashed match. Refer to https://github.com/Flagsmith/flagsmith-engine/blob/c34b4baeea06d31d221433053b64c1e855fd8d4d/flag_engine/utils/hashing.py#L5

Link to this function

replace_identity_features(original, to_replace)

View Source

Returns a list with elements of any of Environment.FeatureState.t() or Features.FeatureState.t() where any that has the same name as in any of the identity Features.FeatureState.t() provided is replaced by that feature.

Link to this function

replace_segment_features(original, to_replace)

View Source

Specs

Returns a list of Environment.FeatureState.t() where any that has the same name as in the segments provided is replaced by the feature state there specified (if any).

Link to this function

trait_match(condition, not_cast, t_value_struct)

View Source

Specs

Given an Types.Operator.t(), a cast or uncast segment value, and a cast trait value, evaluate if the trait value matches to the segment value.

Link to this function

traits_match_segment_condition(traits, condition, segment_id, identifier)

View Source

Specs

True if according to the type of condition operator the co mparison is true, false otherwise. With exception for PERCENTAGE_SPLIT operator all others are matched against the traits passed in.

Link to this function

traits_match_segment_rule(traits, rule, segment_id, identifier)

View Source

Specs

True if the segment rule conditions all match (or there's no conditions) and all nested rules too (or there's no rules), false otherwise.