LogicSubscriber
faststream.nats.subscriber.usecases.basic.LogicSubscriber #
LogicSubscriber(
config: NatsSubscriberConfig,
specification: SubscriberSpecification[Any, Any],
calls: CallsCollection[MsgType],
)
Bases: SubscriberUsecase[MsgType]
Basic class for all NATS Subscriber types (KeyValue, ObjectStorage, Core & JetStream).
Unslotted on purpose: ConcurrentCoreSubscriber mixes ConcurrentMixin into this, and TasksMixin under it already extends SubscriberUsecase's lay-out. NATS is the one broker whose subscribers do not inherit TasksMixin in a straight line.
Source code in faststream/nats/subscriber/usecases/basic.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
subject property #
subject: Address
The subject this Subscriber was declared with, and its Broker address.
start async #
start() -> None
Create NATS subscription and start consume tasks.
Source code in faststream/nats/subscriber/usecases/basic.py
78 79 80 81 82 83 84 85 | |
stop async #
stop() -> None
Clean up handler subscription, cancel consume task in graceful mode.
Source code in faststream/nats/subscriber/usecases/basic.py
87 88 89 90 91 92 93 94 95 96 97 | |
build_log_context staticmethod #
build_log_context(
message: Optional[StreamMessage[MsgType]],
subject: str,
*,
queue: str = "",
stream: str = "",
) -> dict[str, str]
Static method to build log context out of self.consume scope.
Source code in faststream/nats/subscriber/usecases/basic.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
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 abstractmethod async #
get_one(
*, timeout: float = 5
) -> Optional[StreamMessage[MsgType]]
Source code in faststream/_internal/endpoint/subscriber/usecase.py
490 491 492 | |
get_log_context #
get_log_context(
message: Optional[StreamMessage[MsgType]],
) -> dict[str, str]
Generate log context.
Source code in faststream/_internal/endpoint/subscriber/usecase.py
502 503 504 505 506 507 508 509 | |
schema #
schema() -> dict[str, SubscriberSpec]
Source code in faststream/_internal/endpoint/subscriber/usecase.py
525 526 527 | |