From 770864f690731b5cf9188ead5e2e81ce6bb83e41 Mon Sep 17 00:00:00 2001 From: sheldy Date: Fri, 8 Nov 2024 21:08:38 +0100 Subject: [PATCH] Moreeeee warnings --- faststream/nats/subscriber/factory.py | 87 ++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 2 deletions(-) diff --git a/faststream/nats/subscriber/factory.py b/faststream/nats/subscriber/factory.py index 6cf9e21679..f4e5fb3211 100644 --- a/faststream/nats/subscriber/factory.py +++ b/faststream/nats/subscriber/factory.py @@ -354,8 +354,91 @@ def _validate_input_for_misconfigure( ) if not stream: - # TODO: add shared warnings for Core / ObjWatch / KvWatch cases - pass + if obj_watch is not None: + if idle_heartbeat is not None: + warnings.warn( + "`idle_heartbeat` has no effect for ObjectValue subscriber. It can be used with JetStream (Pull/Push) - only.", + RuntimeWarning, + stacklevel=4, + ) + + if flow_control is not None: + warnings.warn( + "`flow_control` has no effect for ObjectValue subscriber. It can be used with JetStream (Pull/Push) - only.", + RuntimeWarning, + stacklevel=4, + ) + + if deliver_policy is not None: + warnings.warn( + "`deliver_policy` has no effect for ObjectValue subscriber. It can be used with JetStream (Pull/Push) - only.", + RuntimeWarning, + stacklevel=4, + ) + + if headers_only is not None: + warnings.warn( + "`headers_only` has no effect for ObjectValue subscriber. It can be used with JetStream (Pull/Push) - only.", + RuntimeWarning, + stacklevel=4, + ) + + elif kv_watch is not None: + if idle_heartbeat is not None: + warnings.warn( + "`idle_heartbeat` has no effect for KeyValue subscriber. It can be used with JetStream (Pull/Push) - only.", + RuntimeWarning, + stacklevel=4, + ) + + if flow_control is not None: + warnings.warn( + "`flow_control` has no effect for KeyValue subscriber. It can be used with JetStream (Pull/Push) - only.", + RuntimeWarning, + stacklevel=4, + ) + + if deliver_policy is not None: + warnings.warn( + "`deliver_policy` has no effect for KeyValue subscriber. It can be used with JetStream (Pull/Push) - only.", + RuntimeWarning, + stacklevel=4, + ) + + if headers_only is not None: + warnings.warn( + "`headers_only` has no effect for KeyValue subscriber. It can be used with JetStream (Pull/Push) - only.", + RuntimeWarning, + stacklevel=4, + ) + else: + if idle_heartbeat is not None: + warnings.warn( + "`idle_heartbeat` has no effect for Core subscriber. It can be used with JetStream (Pull/Push) - only.", + RuntimeWarning, + stacklevel=4, + ) + + if flow_control is not None: + warnings.warn( + "`flow_control` has no effect for Core subscriber. It can be used with JetStream (Pull/Push) - only.", + RuntimeWarning, + stacklevel=4, + ) + + if deliver_policy is not None: + warnings.warn( + "`deliver_policy` has no effect for Core subscriber. It can be used with JetStream (Pull/Push) - only.", + RuntimeWarning, + stacklevel=4, + ) + + if headers_only is not None: + warnings.warn( + "`headers_only` has no effect for Core subscriber. It can be used with JetStream (Pull/Push) - only.", + RuntimeWarning, + stacklevel=4, + ) if obj_watch is not None: # KeyStorage watch