Skip to content

Commit

Permalink
refactor: use correct defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
Lancetnik committed Nov 8, 2024
1 parent c68aa45 commit 6f3c10c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions faststream/nats/fastapi/fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,9 @@ def subscriber( # type: ignore[override]
Doc("Enable Heartbeats for a consumer to detect failures."),
] = None,
flow_control: Annotated[
bool,
Optional[bool],
Doc("Enable Flow Control for a consumer."),
] = False,
] = None,
deliver_policy: Annotated[
Optional["api.DeliverPolicy"],
Doc("Deliver Policy to be used for subscription."),
Expand Down
4 changes: 2 additions & 2 deletions faststream/nats/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ def __init__(
Doc("Enable Heartbeats for a consumer to detect failures."),
] = None,
flow_control: Annotated[
bool,
Optional[bool],
Doc("Enable Flow Control for a consumer."),
] = False,
] = None,
deliver_policy: Annotated[
Optional["api.DeliverPolicy"],
Doc("Deliver Policy to be used for subscription."),
Expand Down
10 changes: 6 additions & 4 deletions faststream/nats/subscriber/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def _validate_input_for_misconfigure(
config: Optional["api.ConsumerConfig"],
ordered_consumer: bool,
idle_heartbeat: Optional[float],
flow_control: bool,
flow_control: Optional[bool],
deliver_policy: Optional["api.DeliverPolicy"],
headers_only: Optional[bool],
pull_sub: Optional["PullSub"],
Expand Down Expand Up @@ -358,6 +358,7 @@ def _validate_input_for_misconfigure(
pass

if obj_watch is not None:
# KeyStorage watch
if max_workers > 1:
warnings.warn(
message="`max_workers` has no effect for ObjectValue subscriber. It can be used with JetStream (Pull/Push) or Core Subscription - only.",
Expand All @@ -380,6 +381,7 @@ def _validate_input_for_misconfigure(
)

elif kv_watch is not None:
# KeyValue watch
if max_workers > 1:
warnings.warn(
message="`max_workers` has no effect for KeyValue subscriber. It can be used with JetStream (Pull/Push) or Core Subscription - only.",
Expand All @@ -405,21 +407,21 @@ def _validate_input_for_misconfigure(
# JetStream subscribers
if pull_sub is not None:
# JS PullSub
if queue is not None:
if queue: # default ""
warnings.warn(
"`queue` option has no effect with JetStream Pull Subscription. Probably, you wanted to use durable instead.",
RuntimeWarning,
stacklevel=4,
)

if ordered_consumer is not None:
if ordered_consumer: # default False
warnings.warn(
"`ordered_consumer` option has no effect with JetStream Pull Subscription. It can be used with JetStream Push Subscription - only.",
RuntimeWarning,
stacklevel=4,
)

if ack_first is not None:
if ack_first: # default False
warnings.warn(
message="`ack_first` option has no effect with JetStream Pull Subscription. It can be used with JetStream Push Subscription - only.",
category=RuntimeWarning,
Expand Down

0 comments on commit 6f3c10c

Please sign in to comment.