Skip to content

Commit

Permalink
Warning in NatsSubscriber factory (#1894)
Browse files Browse the repository at this point in the history
* Warnings in nats subscriber factory

* add category and stacklavel to warnings

* ruff
  • Loading branch information
sheldygg authored Nov 6, 2024
1 parent b9bcb80 commit fc61e91
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions faststream/nats/subscriber/factory.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import warnings
from typing import TYPE_CHECKING, Any, Iterable, Optional, Union

from nats.aio.subscription import (
Expand Down Expand Up @@ -123,6 +124,13 @@ def create_subscriber(
}

if obj_watch is not None:
if max_workers > 1:
warnings.warn(
"`max_workers` has no effect for ObjectValue subscriber.",
RuntimeWarning,
stacklevel=3,
)

return AsyncAPIObjStoreWatchSubscriber(
subject=subject,
config=config,
Expand All @@ -135,6 +143,13 @@ def create_subscriber(
)

if kv_watch is not None:
if max_workers > 1:
warnings.warn(
"`max_workers` has no effect for KeyValue subscriber.",
RuntimeWarning,
stacklevel=3,
)

return AsyncAPIKeyValueWatchSubscriber(
subject=subject,
config=config,
Expand Down

0 comments on commit fc61e91

Please sign in to comment.