BatchSubscriber
faststream.kafka.subscriber.usecase.BatchSubscriber #
BatchSubscriber(
config: KafkaSubscriberConfig,
specification: SubscriberSpecification[Any, Any],
calls: CallsCollection[tuple[ConsumerRecord, ...]],
batch_timeout_ms: int,
max_records: int | None,
)
Bases: LogicSubscriber[tuple['ConsumerRecord', ...]]
Source code in faststream/kafka/subscriber/usecase.py
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 | |
parser instance-attribute #
parser = AioKafkaBatchParser(
msg_class=KafkaMessage
if config.ack_first
else KafkaAckableMessage,
regex=reg,
)
pattern property #
pattern: Address | None
The pattern this Subscriber was declared with, and its Broker address.
partitions property #
partitions: list[TopicPartition]
The assignment as the consumer receives it: the client library's tuples, prefixed.
Declared with faststream.kafka.TopicPartition; handed to aiokafka as its own.
get_msg async #
get_msg(
consumer: AIOKafkaConsumer,
) -> tuple[ConsumerRecord, ...]
Source code in faststream/kafka/subscriber/usecase.py
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 | |
get_log_context #
get_log_context(
message: Optional[
StreamMessage[tuple[ConsumerRecord, ...]]
],
) -> dict[str, str]
Source code in faststream/kafka/subscriber/usecase.py
500 501 502 503 504 505 506 507 508 509 510 511 512 513 | |
start async #
start() -> None
Start the consumer.
Source code in faststream/kafka/subscriber/usecase.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | |
stop async #
stop() -> None
Source code in faststream/kafka/subscriber/usecase.py
263 264 265 266 267 268 | |
add_call #
add_call(
*,
parser_: Optional[CustomCallable],
decoder_: Optional[CustomCallable],
dependencies_: Sequence[Dependant],
codec_: Optional[CodecProto] = None,
) -> Self
Source code in faststream/_internal/endpoint/subscriber/usecase.py
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | |
consume async #
consume(msg: MsgType) -> Any
Consume a message asynchronously.
Source code in faststream/_internal/endpoint/subscriber/usecase.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 | |
process_message async #
process_message(msg: MsgType) -> Response
Execute all message processing stages.
Source code in faststream/_internal/endpoint/subscriber/usecase.py
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 | |
get_one async #
get_one(*, timeout: float = 5.0) -> KafkaMessage | None
Source code in faststream/kafka/subscriber/usecase.py
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 | |
schema #
schema() -> dict[str, SubscriberSpec]
Source code in faststream/_internal/endpoint/subscriber/usecase.py
525 526 527 | |
add_task #
add_task(
func: Callable[..., Coroutine[Any, Any, Any]],
func_args: tuple[Any, ...] | None = None,
func_kwargs: dict[str, Any] | None = None,
*,
restart_on_failure: bool = True,
) -> None
Source code in faststream/_internal/endpoint/subscriber/mixins.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
consume_one async #
consume_one(msg: MsgType) -> None
Source code in faststream/kafka/subscriber/usecase.py
378 379 | |
build_log_context staticmethod #
build_log_context(
message: Optional[StreamMessage[Any]],
topic: str,
group_id: str | None = None,
) -> dict[str, str]
Source code in faststream/kafka/subscriber/usecase.py
394 395 396 397 398 399 400 401 402 403 404 | |