CriticalLogMiddleware
faststream.broker.middlewares.CriticalLogMiddleware #
Bases: BaseMiddleware
A middleware class for logging critical errors.
PARAMETER | DESCRIPTION |
---|---|
logger | The logger object to use for logging |
METHOD | DESCRIPTION |
---|---|
__call__ | Any) -> Self: Returns the middleware instance |
after_processed | Optional[Type[BaseException]] = None, exc_val: Optional[BaseException] = None, exec_tb: Optional[TracebackType] = None) -> bool: Logs critical errors if they occur and returns True |
Initialize the class.
PARAMETER | DESCRIPTION |
---|---|
logger | an instance of the logging.Logger class |
log_level | the log level to use for logging TYPE: |
RETURNS | DESCRIPTION |
---|---|
None | None |
Source code in faststream/broker/middlewares.py
after_consume async
#
A function to handle the result of consuming a resource asynchronously.
PARAMETER | DESCRIPTION |
---|---|
err | Optional exception that occurred during consumption
|
RAISES | DESCRIPTION |
---|---|
err | If an exception occurred during consumption |
Source code in faststream/broker/middlewares.py
after_processed async
#
after_processed(exc_type: Optional[Type[BaseException]] = None, exc_val: Optional[BaseException] = None, exec_tb: Optional[TracebackType] = None) -> bool
Asynchronously called after processing.
PARAMETER | DESCRIPTION |
---|---|
exc_type | Type of the exception raised during processing. TYPE: |
exc_val | Value of the exception raised during processing. TYPE: |
exec_tb | Traceback of the exception raised during processing. TYPE: |
RETURNS | DESCRIPTION |
---|---|
bool | True if the method is successfully executed. TYPE: |
Source code in faststream/broker/middlewares.py
after_publish async
#
Asynchronous function to handle the after publish event.
PARAMETER | DESCRIPTION |
---|---|
err | Optional exception that occurred during the publish |
RETURNS | DESCRIPTION |
---|---|
None | None |
RAISES | DESCRIPTION |
---|---|
Exception | If an error occurred during the publish |
Source code in faststream/broker/middlewares.py
consume_scope async
#
consume_scope(msg: DecodedMessage) -> AsyncIterator[DecodedMessage]
Asynchronously consumes a message and returns an asynchronous iterator of decoded messages.
PARAMETER | DESCRIPTION |
---|---|
msg | The decoded message to consume. TYPE: |
YIELDS | DESCRIPTION |
---|---|
AsyncIterator[DecodedMessage] | An asynchronous iterator of decoded messages. |
RETURNS | DESCRIPTION |
---|---|
AsyncIterator[DecodedMessage] | An asynchronous iterator of decoded messages. |
RAISES | DESCRIPTION |
---|---|
Exception | If an error occurs while consuming the message. |
AsyncIterator
An asynchronous iterator that yields decoded messages.
Note
This function is an async function.
Source code in faststream/broker/middlewares.py
on_consume async
#
on_publish async
#
Asynchronously handle a publish event.
PARAMETER | DESCRIPTION |
---|---|
msg | The message to be published. TYPE: |
RETURNS | DESCRIPTION |
---|---|
SendableMessage | The published message. |
on_receive async
#
publish_scope async
#
publish_scope(msg: SendableMessage) -> AsyncIterator[SendableMessage]
Publish a message and return an async iterator.
PARAMETER | DESCRIPTION |
---|---|
msg | The message to be published. TYPE: |
YIELDS | DESCRIPTION |
---|---|
AsyncIterator[SendableMessage] | A sendable message. |
RETURNS | DESCRIPTION |
---|---|
AsyncIterator[SendableMessage] | An async iterator of sendable messages. |
RAISES | DESCRIPTION |
---|---|
Exception | If an error occurs during publishing. |