FastStream
faststream.app.FastStream #
FastStream(
broker: Optional[BrokerAsyncUsecase[Any, Any]] = None,
logger: Optional[logging.Logger] = logger,
title: str = "FastStream",
version: str = "0.1.0",
description: str = "",
terms_of_service: Optional[AnyHttpUrl] = None,
license: Optional[
Union[License, LicenseDict, AnyDict]
] = None,
contact: Optional[
Union[Contact, ContactDict, AnyDict]
] = None,
identifier: Optional[str] = None,
tags: Optional[
Sequence[Union[Tag, TagDict, AnyDict]]
] = None,
external_docs: Optional[
Union[ExternalDocs, ExternalDocsDict, AnyDict]
] = None,
)
Bases: ABCApp
A class representing a FastStream application.
METHOD | DESCRIPTION |
---|---|
__init__ | initializes the FastStream application |
on_startup | adds a hook to run before the broker is connected |
on_shutdown | adds a hook to run before the broker is disconnected |
after_startup | adds a hook to run after the broker is connected |
after_shutdown | adds a hook to run after the broker is disconnected |
run | runs the FastStream application |
_init_async_cycle | initializes the async cycle |
_start | starts the FastStream application |
_stop | stops the FastStream application |
_startup | runs the startup hooks |
_shutdown | runs the shutdown hooks |
__exit | exits the FastStream application |
Note
The above docstring is autogenerated by docstring-gen library (https://docstring-gen.airt.ai)
Asyncronous FastStream Application class
stores and run broker, control hooks
PARAMETER | DESCRIPTION |
---|---|
broker | async broker to run (may be TYPE: |
logger | logger object to log startup/shutdown messages ( |
title | application title - for AsyncAPI docs TYPE: |
version | application version - for AsyncAPI docs TYPE: |
description | application description - for AsyncAPI docs TYPE: |
Source code in faststream/app.py
after_shutdown #
after_shutdown(
func: Callable[P_HookParams, T_HookReturn]
) -> Callable[P_HookParams, T_HookReturn]
Add hook running AFTER broker disconnected
PARAMETER | DESCRIPTION |
---|---|
func | async or sync func to call as a hook TYPE: |
RETURNS | DESCRIPTION |
---|---|
Callable[P_HookParams, T_HookReturn] | Async version of the func argument |
Source code in faststream/app.py
after_startup #
Add hook running AFTER broker connected
PARAMETER | DESCRIPTION |
---|---|
func | async or sync func to call as a hook TYPE: |
RETURNS | DESCRIPTION |
---|---|
Callable[P_HookParams, T_HookReturn] | Async version of the func argument |
Source code in faststream/app.py
on_shutdown #
Add hook running BEFORE broker disconnected
PARAMETER | DESCRIPTION |
---|---|
func | async or sync func to call as a hook TYPE: |
RETURNS | DESCRIPTION |
---|---|
Callable[P_HookParams, T_HookReturn] | Async version of the func argument |
Source code in faststream/app.py
on_startup #
Add hook running BEFORE broker connected
This hook also takes an extra CLI options as a kwargs
PARAMETER | DESCRIPTION |
---|---|
func | async or sync func to call as a hook TYPE: |
RETURNS | DESCRIPTION |
---|---|
Callable[P_HookParams, T_HookReturn] | Async version of the func argument |
Source code in faststream/app.py
run async
#
run(
log_level: int = logging.INFO,
run_extra_options: Optional[
Dict[str, SettingField]
] = None,
) -> None
Run FastStream Application
PARAMETER | DESCRIPTION |
---|---|
log_level | force application log level |
RETURNS | DESCRIPTION |
---|---|
None | Block an event loop until stopped |
Source code in faststream/app.py
set_broker #
Set already existed App object broker Usefull then you create/init broker in on_startup
hook