featuremanagement.aio package
Module contents
Async feature management support.
- class featuremanagement.aio.FeatureFilter
Bases:
ABCParent class for all async feature filters.
- static alias(alias: str) Callable[[...], Any]
Decorator to set the alias for the filter.
- Parameters:
alias (str) – Alias for the filter.
- Returns:
Decorator
- Return type:
Callable
- abstractmethod async evaluate(context: Mapping[Any, Any], **kwargs: Any) bool
Determine if the feature flag is enabled for the given context.
- Parameters:
context (Mapping) – Context for the feature flag.
- property name: str
Get the name of the filter.
- Returns:
Name of the filter, or alias if it exists.
- Return type:
str
- class featuremanagement.aio.FeatureManager(configuration: Mapping[str, Any], **kwargs: Any)
Bases:
FeatureManagerBaseFeature Manager that determines if a feature flag is enabled for the given context.
- Parameters:
configuration (Mapping) – Configuration object.
- Keyword Arguments:
feature_filters (list[FeatureFilter]) – Custom filters to be used for evaluating feature flags.
on_feature_evaluated (Callable[EvaluationEvent]) – Callback function to be called when a feature flag is evaluated.
targeting_context_accessor (Callable[[], TargetingContext]) – Callback function to get the current targeting context if one isn’t provided.
- async get_variant(feature_flag_id: str, **kwargs: Any) Variant | None
- async get_variant(feature_flag_id: str, user_id: str | TargetingContext, **kwargs: Any) Variant | None
Determine the variant for the given context.
- Parameters:
feature_flag_id (str) – Name of the feature flag
args – Optional positional user identifier or TargetingContext.
- Returns:
Variant instance.
- Return type:
- async is_enabled(feature_flag_id: str, **kwargs: Any) bool
- async is_enabled(feature_flag_id: str, user_id: str | TargetingContext, **kwargs: Any) bool
Determine if the feature flag is enabled for the given context.
- Parameters:
feature_flag_id (str) – Name of the feature flag.
args – Optional positional user identifier or TargetingContext.
- Returns:
True if the feature flag is enabled for the given context.
- Return type:
bool
- class featuremanagement.aio.TargetingFilter
Bases:
FeatureFilterFeature Filter that determines if the user is targeted for the feature flag.
- async evaluate(context: Mapping[Any, Any], **kwargs: Any) bool
Determine if the feature flag is enabled for the given context.
- Keyword Arguments:
context (Mapping) – Context for evaluating the user/group.
- Returns:
True if the user is targeted for the feature flag.
- Return type:
bool
- class featuremanagement.aio.TimeWindowFilter
Bases:
FeatureFilterFeature Filter that determines if the current time is within the time window.
- async evaluate(context: Mapping[Any, Any], **kwargs: Any) bool
Determine if the feature flag is enabled for the given context.
- Keyword Arguments:
context (Mapping) – Mapping with the Start and End time for the feature flag.
- Returns:
True if the current time is within the time window.
- Return type:
bool