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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config |
PluginConfig
|
Provide a config object to customize the behavior of the plugin. |
PluginConfig()
|
__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_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 ¶
Adds the health check controller.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_config |
AppConfig
|
The Starlite application config object. |
required |
configure_logging ¶
Configures application logging if it has not already been configured.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_config |
AppConfig
|
The Starlite application config object. |
required |
configure_openapi ¶
Configures the OpenAPI docs if they have not already been configured.
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_response_class ¶
Add the custom response class.
No-op if the AppConfig.response_class
is not None.
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_static_files ¶
Configure static files for the application.
No-op if
AppConfig.static_files_config is not
None.
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
¶
Add the hook handler to
AppConfig.after_exception.
do_cache
class-attribute
¶
Add configuration for the redis-backed cache to
AppConfig.cache_config.
do_collection_dependencies
class-attribute
¶
Add the Provide's for collection route dependencies to
AppConfig.dependencies.
do_compression
class-attribute
¶
Add configuration for gzip compression to
AppConfig.compression_config.
do_exception_handlers
class-attribute
¶
Add the repository/service exception http translation handlers to
AppConfig.exception_handlers.
do_health_check
class-attribute
¶
Add the health check controller to
AppConfig.route_handlers.
do_logging
class-attribute
¶
Set the logging configuration object to
AppConfig.logging_config.
do_openapi
class-attribute
¶
Set the OpenAPI config object to
AppConfig.openapi_config.
do_response_class
class-attribute
¶
Set the custom response class to
AppConfig.response_class.
do_sentry
class-attribute
¶
Configure the application to initialize Sentry on startup. Adds a handler to
AppConfig.on_startup.
do_sqlalchemy_plugin
class-attribute
¶
Set the SQLAlchemy plugin on the application. Adds the plugin to
AppConfig.plugins.
do_static_files
class-attribute
¶
Set the static files config object to
AppConfig.static_files_config.
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.
worker_functions
class-attribute
¶
Queue worker functions.