Skip to content

Commit 2a4a99b

Browse files
clean up
Signed-off-by: Elena Kolevska <elena@kolevska.com>
1 parent 9d67b78 commit 2a4a99b

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

dapr/clients/grpc/client.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,18 @@ def publish_event(
483483
return DaprResponse(call.initial_metadata())
484484

485485
def subscribe(self, pubsub_name, topic, metadata=None, dead_letter_topic=None):
486+
"""
487+
Subscribe to a topic with a bidirectional stream
488+
489+
Args:
490+
pubsub_name (str): The name of the pubsub component.
491+
topic (str): The name of the topic.
492+
metadata (Optional[Dict]): Additional metadata for the subscription.
493+
dead_letter_topic (Optional[str]): Name of the dead-letter topic.
494+
495+
Returns:
496+
Subscription: The Subscription object managing the stream.
497+
"""
486498
subscription = Subscription(self._stub, pubsub_name, topic, metadata, dead_letter_topic)
487499
subscription.start()
488500
return subscription

tests/clients/fake_dapr_server.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,6 @@ def SubscribeTopicEventsAlpha1(self, request_iterator, context):
205205
spec_version='1.0',
206206
)
207207
yield api_v1.SubscribeTopicEventsResponseAlpha1(event_message=msg3)
208-
# Simulate the stream being closed with an error
209-
context.abort(grpc.StatusCode.CANCELLED, 'Stream closed by server')
210208

211209
def SaveState(self, request, context):
212210
self.check_for_exception(context)

tests/clients/test_dapr_grpc_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def test_subscribe_topic(self):
266266
dapr = DaprGrpcClient(f'{self.scheme}localhost:{self.grpc_port}')
267267
subscription = dapr.subscribe(pubsub_name='pubsub', topic='example')
268268

269-
# First message
269+
# First message - text
270270
message1 = subscription.next_message()
271271
subscription.respond_success(message1)
272272

@@ -281,7 +281,7 @@ def test_subscribe_topic(self):
281281
self.assertEqual('text/plain', message1.data_content_type())
282282
self.assertEqual('hello2', message1.data())
283283

284-
# Second message
284+
# Second message - json
285285
message2 = subscription.next_message()
286286
subscription.respond_success(message2)
287287

0 commit comments

Comments
 (0)