Ligare.platform.feature_flag.feature_flag_router

Classes

FeatureFlag(name, enabled)

FeatureFlagChange(name, old_value, new_value)

FeatureFlagRouter()

The base feature flag router.

class Ligare.platform.feature_flag.feature_flag_router.FeatureFlag(name, enabled)[source]
__init__(name, enabled)
enabled: bool
name: str
class Ligare.platform.feature_flag.feature_flag_router.FeatureFlagChange(name, old_value, new_value)[source]
__init__(name, old_value, new_value)
name: str
new_value: bool | None
old_value: bool | None
class Ligare.platform.feature_flag.feature_flag_router.FeatureFlagRouter[source]

The base feature flag router. All feature flag routers should extend this class.

abstract feature_is_enabled(name, default=False)[source]

Determine whether a feature flag is enabled or disabled.

Parameters:
  • name (str) – The name of the feature flag.

  • default (bool) – A default value to return for cases where a feature flag may not exist. Defaults to False.

Return bool:

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

Return type:

bool

abstract get_feature_flags(names=None)[source]

Get all feature flags and whether they are enabled. If names is not None, this only returns the enabled state of the flags in the list. :rtype: Sequence[TypeVar(TFeatureFlag, bound= FeatureFlag, covariant=True)]

Parameters:

names (list[str] | None) – 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. Otherwise, the list is filtered.

abstract set_feature_is_enabled(name, is_enabled)[source]

Enable or disable a feature flag.

Parameters:
  • name (str) – The name of the feature flag.

  • is_enabled (bool) – If True, the feature is enabled. If False, the feature is disabled.

Return FeatureFlagChange:

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

Return type:

FeatureFlagChange