Ligare.platform.feature_flag.caching_feature_flag_router

Classes

CachingFeatureFlagRouter(logger)

FeatureFlag(name, enabled)

class Ligare.platform.feature_flag.caching_feature_flag_router.CachingFeatureFlagRouter(logger)[source]
__init__(logger)[source]
feature_is_cached(name)[source]
feature_is_enabled(name, default=False)[source]

Determine whether a feature flag is enabled or disabled.

Subclasses should call this method to validate parameters and use cached values.

Parameters:
  • name (str) – The feature flag to check.

  • default (bool) – If the feature flag is not in the in-memory dictionary of flags, this is the default value to return. The default parameter value when not specified is False.

Return bool:

If True, the feature is enabled. If False, the feature is disabled.

Return type:

bool

get_feature_flags(names=None)[source]

Get all feature flags and their status.

Return type:

Sequence[TypeVar(TFeatureFlag, bound= FeatureFlag, covariant=True)]

Params list[str] | None names:

Get only the flags contained in this list.

Return tuple[TFeatureFlag]:

An immutable sequence (a tuple) of feature flags.

If names is None this sequence contains _all_ feature flags in the cache. Otherwise, the list is filtered.

set_feature_is_enabled(name, is_enabled)[source]

Enables or disables a feature flag in the in-memory dictionary of feature flags.

Subclasses should call this method to validate parameters and cache values.

Parameters:
  • name (str) – The feature flag to check.

  • is_enabled (bool) – Whether the feature flag is to be enabled or disabled.

Return FeatureFlagChange:

An object representing the previous and new values of the changed feature flag.

Return type:

FeatureFlagChange

class Ligare.platform.feature_flag.caching_feature_flag_router.FeatureFlag(name, enabled)[source]