BaseHandler
faststream.broker.handler.BaseHandler #
BaseHandler(*, log_context_builder: Callable[[StreamMessage[Any]], Dict[str, str]], description: Optional[str] = None, title: Optional[str] = None, include_in_schema: bool = True)
Bases: AsyncAPIOperation
, Generic[MsgType]
A base handler class for asynchronous API operations.
METHOD | DESCRIPTION |
---|---|
__init__ | Initializes the BaseHandler object. |
name | Returns the name of the handler. |
call_name | Returns the name of the handler call. |
description | Returns the description of the handler. |
consume | Abstract method to consume a message. |
Note: This class inherits from AsyncAPIOperation and is a generic class with type parameter MsgType.
Initialize a new instance of the class.
PARAMETER | DESCRIPTION |
---|---|
log_context_builder | A callable that builds the log context. |
description | Optional description of the instance. |
title | Optional title of the instance. |
include_in_schema | Whether to include the instance in the schema. TYPE: |
Source code in faststream/broker/handler.py
calls instance-attribute
#
calls: Union[List[Tuple[HandlerCallWrapper[MsgType, Any, SendableMessage], Callable[[StreamMessage[MsgType]], bool], SyncParser[MsgType, StreamMessage[MsgType]], SyncDecoder[StreamMessage[MsgType]], Sequence[Callable[[Any], BaseMiddleware]], CallModel[Any, SendableMessage]]], List[Tuple[HandlerCallWrapper[MsgType, Any, SendableMessage], Callable[[StreamMessage[MsgType]], Awaitable[bool]], AsyncParser[MsgType, StreamMessage[MsgType]], AsyncDecoder[StreamMessage[MsgType]], Sequence[Callable[[Any], BaseMiddleware]], CallModel[Any, SendableMessage]]]] = []
global_middlewares instance-attribute
#
global_middlewares: Sequence[Callable[[Any], BaseMiddleware]] = []
consume abstractmethod
#
Consume a message.
PARAMETER | DESCRIPTION |
---|---|
msg | The message to be consumed. TYPE: |
RETURNS | DESCRIPTION |
---|---|
SendableMessage | The sendable message. |
RAISES | DESCRIPTION |
---|---|
NotImplementedError | If the method is not implemented. |
Source code in faststream/broker/handler.py
get_payloads #
Get the payloads of the handler.
Source code in faststream/broker/handler.py
schema #
Returns the schema of the API operation as a dictionary of channel names and channel objects.