HandlerCallWrapper
faststream.broker.wrapper.HandlerCallWrapper #
HandlerCallWrapper(
call: Callable[P_HandlerParams, T_HandlerReturn]
)
Bases: Generic[MsgType, P_HandlerParams, T_HandlerReturn]
A generic class to wrap handler calls.
METHOD | DESCRIPTION |
---|---|
__new__ | Create a new instance of the class |
__init__ | Initialize the instance |
__call__ | Call the wrapped handler |
set_wrapped | Set the wrapped handler call |
call_wrapped | Call the wrapped handler |
wait_call | Wait for the handler call to complete |
Initialize a handler.
PARAMETER | DESCRIPTION |
---|---|
call | A callable object that represents the handler function. TYPE: |
Source code in faststream/broker/wrapper.py
call_wrapped #
call_wrapped(
message: StreamMessage[MsgType],
) -> Union[
Optional[WrappedReturn[T_HandlerReturn]],
Awaitable[Optional[WrappedReturn[T_HandlerReturn]]],
]
Calls the wrapped function with the given message.
PARAMETER | DESCRIPTION |
---|---|
message | The message to be passed to the wrapped function. TYPE: |
RETURNS | DESCRIPTION |
---|---|
Union[Optional[WrappedReturn[T_HandlerReturn]], Awaitable[Optional[WrappedReturn[T_HandlerReturn]]]] | The result of the wrapped function call. |
RAISES | DESCRIPTION |
---|---|
AssertionError | If |
AssertionError | If the broker has not been started before calling this function. |
Source code in faststream/broker/wrapper.py
reset_test #
set_test #
set_wrapped #
Set the wrapped handler call.
PARAMETER | DESCRIPTION |
---|---|
wrapped | The wrapped handler call to set TYPE: |
trigger #
trigger(
result: Any = None,
error: Optional[BaseException] = None,
) -> None
Source code in faststream/broker/wrapper.py
wait_call async
#
Waits for a call with an optional timeout.
PARAMETER | DESCRIPTION |
---|---|
timeout | Optional timeout in seconds |
RAISES | DESCRIPTION |
---|---|
AssertionError | If the broker is not started |
RETURNS | DESCRIPTION |
---|---|
None | None |