Services stand for portability and scalability, so the deployment
and configuration of these service should be as easy as possible.
To achieve this a service based on fastapi-serviceutils is configured using
These settings can be overwritten using environment-variables.
Dependency management for these services is generalized using a combination of
Dephell and Poetry.
For monitoring and chaining of service-calls some default endpoints should
always be defined.
For example an endpoint to check if the service is alive (
an endpoint to access the config of the service (
These endpoints are automatically added in services using fastapi-serviceutils
if defined in the
config.yml of the service.
Because a service should focus on only one task it may be required to create
multiple small services in a short time.
As always time matters.
For this fastapi-serviceutils allows ** fast creation of new services** with
If an error occurs during a service-call it is important to have detailed
logs with a good traceback.
To achieve this the default logging of fastapi is optimized in
Fastapi allows easily created swagger-documentation for service-endpoints. This is optimal for clients wanting to integrate these endpoints. For developers of the service an additional apidoc-documentation of the service and the source-code is required (most popular are documentations created using Sphinx or MKDocs). Fastapi-serviceutils based services serve sphinx-based documentations using google-documentation style in the code and rst-files inside the docs-folder.
The development of these services should be as much generalized as possible for easy workflows, as less manual steps as possible for the developer and short onboarding times. For this fastapi-serviceutils includes a Makefile for most common tasks during development. There is also a Tmuxp-config file to create a tmux-session for development.
optimized logging using Loguru
optimized exception handling by additional exception handler
usage of a config.yml-file to configure the service
usage of environment-variables (Environment variable overwrites config-value) to configure the service
easily serve the apidoc with the service
fast creation of new service with create_service
Fastapi-serviceutils contains three subpackages:
fastapi_serviceutils.app contains functions and classes for
app-configuration (like config.yml file, logger, etc.), handlers and endpoint
fastapi_serviceutils.cli contains executables for easier development like
create_service to use the fastapi_serviceutils_template.
fastapi_serviceutils.utils contain utils to interact with external
resources like databases and services, testutils and other utilities.
To see detailed usage of these functions and classes, and also recommended service-structure, see exampleservice.