Skip to content

Server

FastAPI server implementation for the aspyx service framework.

FastAPIServer(fast_api, service_manager, component_registry, protobuf_manager)

Bases: Server

A server utilizing fastapi framework.

add_routes()

add everything that looks like an http endpoint

boot(module, host='0.0.0.0', port=8000, start_thread=True) classmethod

boot the DI infrastructure of the supplied module and optionally start a fastapi thread given the url Args: module: the module to initialize the environment host: listen address port: the port

Returns:

Type Description
Environment

the created environment

start_server(host)

start the fastapi server in a thread

RequestContext(app)

A request context is used to remember the current http request in the current thread

get_request() classmethod

Return the current http request

Returns:

Type Description
Request

the current http request

health checks

HealthCheckManager()

The health manager is able to run all registered health checks and is able to return an overall status.

check() async

run all registered health checks and return an overall result. Returns: the overall result.

HealthStatus

Bases: Enum

A enum specifying the health status of a service. The values are:

  • OK service is healthy
  • WARNING service has some problems
  • CRITICAL service is unhealthy

health_check(name='', cache=0, fail_if_slower_than=0)

Methods annotated with @health_check specify health checks that will be executed.

health_checks()

Instances of classes that are annotated with @health_checks contain healt mehtods.