API Docs
Wheke
Wheke(settings=None)
The Wheke class is the entry point to build an application.
settings_cls
instance-attribute
settings_cls
The loaded settings class.
settings
instance-attribute
settings
The loaded settings object.
pods
instance-attribute
pods = []
The list of pods plugged to Wheke.
setup_registry
async
setup_registry(registry)
Populates the registry with all redistered pods services.
add_pod
add_pod(pod_to_add)
Programatically plug a Pod into Wheke.
create_app
create_app()
Create a FastAPI app with all plugged pods.
create_cli
create_cli()
Create a Typer cli with all plugged pods.
WhekeSettings
Bases: BaseSettings
FeatureSettings
Bases: BaseModel
Base model to declare custom feature settings.
When inheriting from this method make sure to override
the __feature_name__ with an unique feature name
preferentially snake_case lower case (e.g. my_custom_feature).
The feature name will be used as namespace to the settings values defined in the model:
class CustomSettings(FeatureSettings):
__feature_name__ == "my_feature"
custom_parameter: str = "test"
Can be set like this in the .env file:
WHEKE_FEATURES='{"my_feature": {"custom_parameter": "custom_value"}}'
__feature_name__
class-attribute
__feature_name__
The namespace of the feature in the app settings.
Pod
Pod(
name,
*,
router=None,
static_url=None,
static_path=None,
services=None,
cli=None,
)
A Pod is the base unity that controls a funcionality.
name
instance-attribute
name = name
The name of the Pod.
router
instance-attribute
router = router
The router from fastapi.APIRouter that contains
all the routes for the Pod.
static_url
instance-attribute
static_url = static_url
The url prefix for the Pod static files.
static_path
instance-attribute
static_path
The path to the Pod static files.
services
instance-attribute
services = services or []
The list of services provided by the Pod.
It consists of a tuple of the service class and the service factory callable.
cli
instance-attribute
cli = cli
The Typer cli of the Pod
ServiceConfig
dataclass
ServiceConfig(
service_type,
service_factory,
health_check=None,
is_singleton=False,
singleton_cleanup_method="",
)
aget_service
async
aget_service(container, service_type)
get_container
get_container(ctx)
get_service
get_service(container, service_type)
get_settings
get_settings(container, cls)