View Source Flagsmith.Engine (flagsmith_engine v0.1.1)
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
Specs
evaluate_identity_in_segment( Flagsmith.Schemas.Identity.t(), Flagsmith.Schemas.Segments.Segment.t(), [Flagsmith.Schemas.Traits.Trait.t()] ) :: boolean()
True if an identity is deemed matching a segment conditions & rules, false otherwise.
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()
.
Specs
get_environment_feature_states(Flagsmith.Schemas.Environment.t()) :: [ Flagsmith.Schemas.Environment.FeatureState.t() ]
Get the feature states of an Environment.t()
.
get_identity_feature_state(env, identity, name, override_traits \\ [])
View SourceSpecs
get_identity_feature_state( Flagsmith.Schemas.Environment.t(), Flagsmith.Schemas.Identity.t(), name :: String.t(), override_traits :: [Flagsmith.Schemas.Traits.Trait.t()] ) :: Flagsmith.Schemas.Environment.FeatureState.t() | nil
Get feature state with a given feature_name for a given Identity.t()
and
Environment.t()
.
Specs
get_identity_feature_states( Flagsmith.Schemas.Environment.t(), Flagsmith.Schemas.Identity.t(), override_traits :: [Flagsmith.Schemas.Traits.Trait.t()] ) :: [Flagsmith.Schemas.Environment.FeatureState.t()]
Get list of feature states for a given Identity.t()
in a given Environment.t()
.
Specs
get_segment_features( segments :: [Flagsmith.Schemas.Segments.Segment.t()], Flagsmith.Schemas.Identity.t(), override_traits :: [Flagsmith.Schemas.Traits.Trait.t()] ) :: [Flagsmith.Schemas.Segments.Segment.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)
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.
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
Specs
replace_identity_features( original :: [Flagsmith.Schemas.Environment.FeatureState.t()], to_replace :: [Flagsmith.Schemas.Features.FeatureState.t()] ) :: [ Flagsmith.Schemas.Environment.FeatureState.t() | Flagsmith.Schemas.Features.FeatureState.t() ]
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.
Specs
replace_segment_features( original :: [Flagsmith.Schemas.Environment.FeatureState.t()], to_replace :: [Flagsmith.Schemas.Segments.Segment.t()] ) :: [Flagsmith.Schemas.Environment.FeatureState.t()]
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).
Specs
trait_match( condition :: Flagsmith.Schemas.Types.Operator.t(), segment_value :: String.t() | Flagsmith.Schemas.Traits.Trait.Value.t(), trait :: Flagsmith.Schemas.Traits.Trait.Value.t() ) :: boolean()
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.
traits_match_segment_condition(traits, condition, segment_id, identifier)
View SourceSpecs
traits_match_segment_condition( [Flagsmith.Schemas.Traits.Trait.t()], Flagsmith.Schemas.Segments.Segment.Condition.t(), non_neg_integer(), String.t() ) :: boolean()
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.
Specs
traits_match_segment_rule( [Flagsmith.Schemas.Traits.Trait.t()], Flagsmith.Schemas.Segments.Segment.Rule.t(), non_neg_integer(), String.t() ) :: boolean()
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.