Ligare.web.middleware.feature_flags

Ligare.web’s integration with Ligare.platform.feature_flag.

Functions

_get_feature_flag_blueprint(app, config, log)

Create and return a Flask Blueprint with API endpoints for querying and managing Feature Flags.

Classes

CachingFeatureFlagRouterModule()

An Injector module to work with Feature Flags in-memory.

Config(**data)

DBFeatureFlagRouterModule(feature_flag_table)

FeatureFlagConfig(**data)

FeatureFlagMiddlewareModule(...)

Enable the use of Feature Flags and a Feature Flag management API.

FeatureFlagPatch(name, enabled)

FeatureFlagPatchRequest

FeatureFlagRouterModule([t_feature_flag])

An Injector module to provide an instance of a Feature Flag Router.

class Ligare.web.middleware.feature_flags.CachingFeatureFlagRouterModule[source]

An Injector module to work with Feature Flags in-memory.

__init__()[source]

Get an instance of the generic FeatureFlagRouterModule.

Parameters:

t_feature_flag (type[FeatureFlagRouter[TFeatureFlag]] | None) – The type of Feature Flag Router this Injector module provides, defaults to None

class Ligare.web.middleware.feature_flags.Config(**data)[source]
feature_flag: FeatureFlagConfig
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

post_load()[source]

This method is called by load_config after TOML data has been loaded into the pluggable config type instance.

Return type:

None

class Ligare.web.middleware.feature_flags.DBFeatureFlagRouterModule(feature_flag_table: type[FeatureFlagTableBase[MetaBase]], bases: list[MetaBase | type[MetaBase]] | None = None)[source]
static __new__(cls, feature_flag_table, bases=None)[source]

An Injector module to work with Feature Flags stored in a database.

Parameters:
  • feature_flag_table (type[FeatureFlagTableBase]) – The base table type representing columns the database table contains, and other aspects of SQLAlchemy Table object

  • bases (list[MetaBase | type[MetaBase]] | None) – All MetaBase types an SQLAlchemy ScopedSession instance is responsible for, defaults to None

Return _type_:

_description_

class Ligare.web.middleware.feature_flags.FeatureFlagConfig(**data)[source]
access_role_name: str | bool | None
api_base_url: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class Ligare.web.middleware.feature_flags.FeatureFlagMiddlewareModule(feature_flag_router_module_type)[source]

Enable the use of Feature Flags and a Feature Flag management API.

class FeatureFlagMiddleware(app)[source]

ASGI middleware for Feature Flags.

This middleware create a Flask blueprint the enables a Feature Flag management API.

__init__(app)[source]
__init__(feature_flag_router_module_type)[source]

Create the Injector module.

Parameters:

feature_flag_router_module_type (type[FeatureFlagRouterModule[TFeatureFlag]])

configure(binder)[source]

Override to configure bindings.

Return type:

None

register_middleware(app)[source]
class Ligare.web.middleware.feature_flags.FeatureFlagPatch(name, enabled)[source]
__init__(name, enabled)
enabled: bool
name: str
class Ligare.web.middleware.feature_flags.FeatureFlagPatchRequest[source]
enabled: bool
name: str
class Ligare.web.middleware.feature_flags.FeatureFlagRouterModule(t_feature_flag=None)[source]

An Injector module to provide an instance of a Feature Flag Router.

__init__(t_feature_flag=None)[source]

Get an instance of the generic FeatureFlagRouterModule.

Parameters:

t_feature_flag (type[FeatureFlagRouter[TFeatureFlag]] | None) – The type of Feature Flag Router this Injector module provides, defaults to None

static get_config_type()[source]

Get the Feature Flag Router Module configuration type.

Return type[Ligare.web.middleware.feature_flags.Config]:

Return type:

type[AbstractConfig]