Handler
faststream.rabbit.asyncapi.Handler #
Handler(
queue: RabbitQueue,
log_context_builder: Callable[
[StreamMessage[Any]], Dict[str, str]
],
graceful_timeout: Optional[float] = None,
exchange: Optional[RabbitExchange] = None,
consume_args: Optional[AnyDict] = None,
description: Optional[str] = None,
title: Optional[str] = None,
include_in_schema: bool = True,
virtual_host: str = "/",
)
Bases: LogicHandler
A class that serves as a handler for RMQAsyncAPIChannel and LogicHandler.
METHOD | DESCRIPTION |
---|---|
- name | Returns the name of the handler. |
- get_payloads | Returns a list of payloads. |
Initialize a RabbitMQ consumer.
PARAMETER | DESCRIPTION |
---|---|
queue | RabbitQueue object representing the queue to consume from TYPE: |
log_context_builder | Callable that returns a dictionary with log context information |
graceful_timeout | Optional float representing the graceful timeout |
exchange | RabbitExchange object representing the exchange to bind the queue to (optional) TYPE: |
consume_args | Additional arguments for consuming from the queue (optional) TYPE: |
description | Description of the consumer (optional) |
title | Title of the consumer (optional) |
include_in_schema | Whether to include the consumer in the API specification (optional) TYPE: |
virtual_host | Virtual host to connect to (optional) TYPE: |
Source code in faststream/rabbit/handler.py
calls instance-attribute
#
calls: List[
Tuple[
HandlerCallWrapper[MsgType, Any, SendableMessage],
Callable[[StreamMessage[MsgType]], Awaitable[bool]],
AsyncParser[MsgType, Any],
AsyncDecoder[StreamMessage[MsgType]],
Sequence[Callable[[Any], BaseMiddleware]],
CallModel[Any, SendableMessage],
]
]
global_middlewares instance-attribute
#
global_middlewares: Sequence[
Callable[[Any], BaseMiddleware]
] = []
add_call #
add_call(
*,
handler: HandlerCallWrapper[
IncomingMessage, P_HandlerParams, T_HandlerReturn
],
dependant: CallModel[P_HandlerParams, T_HandlerReturn],
parser: Optional[
CustomParser[IncomingMessage, RabbitMessage]
],
decoder: Optional[CustomDecoder[RabbitMessage]],
filter: Filter[RabbitMessage],
middlewares: Optional[
Sequence[
Callable[[IncomingMessage], BaseMiddleware]
]
]
) -> None
Add a call to the handler.
PARAMETER | DESCRIPTION |
---|---|
handler | The handler for the call. TYPE: |
dependant | The dependant for the call. TYPE: |
parser | Optional custom parser for the call. TYPE: |
decoder | Optional custom decoder for the call. TYPE: |
filter | The filter for the call. TYPE: |
middlewares | Optional sequence of middlewares for the call. TYPE: |
RETURNS | DESCRIPTION |
---|---|
None | None |
Source code in faststream/rabbit/handler.py
close async
#
Source code in faststream/rabbit/handler.py
consume async
#
Consume a message asynchronously.
PARAMETER | DESCRIPTION |
---|---|
msg | The message to be consumed. TYPE: |
RETURNS | DESCRIPTION |
---|---|
SendableMessage | The sendable message. |
RAISES | DESCRIPTION |
---|---|
StopConsume | If the consumption needs to be stopped. |
RAISES | DESCRIPTION |
---|---|
Exception | If an error occurs during consumption. |
Source code in faststream/broker/handler.py
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
|
get_payloads #
Get the payloads of the handler.
Source code in faststream/broker/handler.py
schema #
Source code in faststream/rabbit/asyncapi.py
start async
#
start(declarer: RabbitDeclarer) -> None
Starts the consumer for the RabbitMQ queue.
PARAMETER | DESCRIPTION |
---|---|
declarer | RabbitDeclarer object used to declare the queue and exchange TYPE: |
RETURNS | DESCRIPTION |
---|---|
None | None |