From aa5c2a7a2c4be7348c4989fc72a34454be59d310 Mon Sep 17 00:00:00 2001 From: artem Date: Sat, 18 May 2024 16:31:28 +0200 Subject: [PATCH] Update subscriber signature for Router and FastAPI integration --- faststream/nats/fastapi/fastapi.py | 12 +++++++++++- faststream/nats/router.py | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/faststream/nats/fastapi/fastapi.py b/faststream/nats/fastapi/fastapi.py index 4da5f51889..6d8a1af3fe 100644 --- a/faststream/nats/fastapi/fastapi.py +++ b/faststream/nats/fastapi/fastapi.py @@ -66,7 +66,7 @@ SubscriberMiddleware, ) from faststream.nats.message import NatsBatchMessage, NatsMessage - from faststream.nats.schemas import JStream, PullSub + from faststream.nats.schemas import JStream, PullSub, KvWatch, ObjWatch from faststream.security import BaseSecurity from faststream.types import AnyDict, LoggerProto @@ -651,6 +651,14 @@ def subscriber( # type: ignore[override] "Should be used with `stream` only." ), ] = None, + kv_watch: Annotated[ + Union[str, "KvWatch", None], + Doc("KeyValue watch parameters container."), + ] = None, + obj_watch: Annotated[ + Union[bool, "ObjWatch"], + Doc("ObjecStore watch parameters container."), + ] = False, inbox_prefix: Annotated[ bytes, Doc( @@ -866,6 +874,8 @@ def subscriber( # type: ignore[override] deliver_policy=deliver_policy, headers_only=headers_only, pull_sub=pull_sub, + kv_watch=kv_watch, + obj_watch=obj_watch, inbox_prefix=inbox_prefix, ack_first=ack_first, stream=stream, diff --git a/faststream/nats/router.py b/faststream/nats/router.py index 942e148cd4..3f29af056d 100644 --- a/faststream/nats/router.py +++ b/faststream/nats/router.py @@ -19,7 +19,7 @@ SubscriberMiddleware, ) from faststream.nats.message import NatsBatchMessage, NatsMessage - from faststream.nats.schemas import JStream, PullSub + from faststream.nats.schemas import JStream, PullSub, KvWatch, ObjWatch from faststream.types import SendableMessage @@ -193,6 +193,14 @@ def __init__( "Should be used with `stream` only." ), ] = None, + kv_watch: Annotated[ + Union[str, "KvWatch", None], + Doc("KeyValue watch parameters container."), + ] = None, + obj_watch: Annotated[ + Union[bool, "ObjWatch"], + Doc("ObjecStore watch parameters container."), + ] = False, inbox_prefix: Annotated[ bytes, Doc( @@ -283,6 +291,8 @@ def __init__( deliver_policy=deliver_policy, headers_only=headers_only, pull_sub=pull_sub, + kv_watch=kv_watch, + obj_watch=obj_watch, inbox_prefix=inbox_prefix, ack_first=ack_first, stream=stream,