starlite_saqlalchemy
starlite-saqlalchemy¶
An implementation of a Starlite
application configuration plugin.
Example:
from starlite import Starlite, get
from starlite_saqlalchemy import ConfigureApp
@get("/example")
def example_handler() -> dict:
return {"hello": "world"}
app = Starlite(route_handlers=[example_handler], on_app_init=[ConfigureApp()])
ConfigureApp ¶
Starlite application configuration.
__call__ ¶
configure_after_exception ¶
Add the logging after exception hook handler.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
app_config |
AppConfig
|
The Starlite application config object. |
required |
configure_cache ¶
Configure the application cache.
We only overwrite if DEFAULT_CACHE_CONFIG
is the
standing configuration object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
app_config |
AppConfig
|
The Starlite application config object. |
required |
configure_collection_dependencies ¶
configure_compression ¶
Configure application compression.
No-op if AppConfig.compression_config
has already been set.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
app_config |
AppConfig
|
The Starlite application config object. |
required |
configure_debug ¶
Set the Starlite debug
parameter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
app_config |
AppConfig
|
The Starlite application config object. |
required |
configure_exception_handlers ¶
Add the handlers that translate service and repository exceptions into HTTP exceptions.
Does not overwrite handlers that may already exist for the exception types.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
app_config |
AppConfig
|
The Starlite application config object. |
required |
configure_health_check ¶
Add health check controller.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
app_config |
AppConfig
|
The Starlite application config object. |
required |
configure_logging ¶
Configure application logging.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
app_config |
AppConfig
|
The Starlite application config object. |
required |
configure_openapi ¶
Configure the OpenAPI docs.
We only overwrite if DEFAULT_OPENAPI_CONFIG
is the standing configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
app_config |
AppConfig
|
The Starlite application config object. |
required |
configure_sentry ¶
Add handler to configure Sentry integration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
app_config |
AppConfig
|
The Starlite application config object. |
required |
configure_sqlalchemy_plugin ¶
Configure SQLAlchemy
for the application.
Adds a configured SQLAlchemyPlugin
to
AppConfig.plugins
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
app_config |
AppConfig
|
The Starlite application config object. |
required |
configure_type_encoders ¶
Set mapping of type encoders on the application config.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
app_config |
AppConfig
|
The Starlite application config object. |
required |
configure_worker ¶
Configure the SAQ
async worker.
No-op if there are no worker functions set on
PluginConfig
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
app_config |
AppConfig
|
The Starlite application config object. |
required |
PluginConfig ¶
Bases: BaseModel
Configure behavior of the ConfigureApp
object.
Each feature that the plugin enables can be toggled with the
do_<behavior>
switch, e.g.,
PluginConfig(do_after_exception=False)
will tell ConfigureApp
not to add the after exception logging hook handler to the
application.
do_after_exception
class-attribute
¶
Configure after exception handler.
Add the hook handler to
AppConfig.after_exception
.
do_cache
class-attribute
¶
Configure redis cache backend.
Add configuration for the redis-backed cache to
AppConfig.cache_config
.
do_collection_dependencies
class-attribute
¶
Add collection route dependencies.
Add the Provide
's for collection route dependencies to
AppConfig.dependencies
.
do_compression
class-attribute
¶
Confiture compression backend.
Add configuration for gzip compression to
AppConfig.compression_config
.
do_exception_handlers
class-attribute
¶
Configure exception handlers.
Add the repository/service exception http translation handlers to
AppConfig.exception_handlers
.
do_health_check
class-attribute
¶
Configure a health check.
Add the health check controller to
AppConfig.route_handlers
.
do_logging
class-attribute
¶
Configure logging.
Set the logging configuration object to
AppConfig.logging_config
.
do_openapi
class-attribute
¶
Configure OpenAPI.
Set the OpenAPI config object to
AppConfig.openapi_config
.
do_sentry
class-attribute
¶
Configure sentry.
Configure the application to initialize Sentry on startup. Adds a handler to
AppConfig.on_startup
.
do_set_debug
class-attribute
¶
Configure Starlite debug mode.
Allow the plugin to set the starlite debug
parameter. Parameter set to value of
AppConfig.debug
.
do_sqlalchemy_plugin
class-attribute
¶
Configure SQLAlchemy plugin.
Set the SQLAlchemy plugin on the application. Adds the plugin to
AppConfig.plugins
.
do_type_encoders
class-attribute
¶
Configure custom type encoders on the app.
do_worker
class-attribute
¶
Configure the async worker on the application.
This action instantiates a worker instance and sets handlers for
AppConfig.on_startup
and
AppConfig.on_shutdown
that manage the lifecycle
of the SAQ
worker.
log_processors
class-attribute
¶
Chain of structlog log processors.
type_encoders
class-attribute
¶
Map of type to serializer callable.
worker_functions
class-attribute
¶
worker_functions: list[Callable[..., Any] | tuple[str, Callable[..., Any]]] = [
(make_service_callback.__qualname__, make_service_callback)
]
Queue worker functions.