Skip to content

Commit cb4b65b

Browse files
Removes async client
Signed-off-by: Elena Kolevska <[email protected]>
1 parent b04615f commit cb4b65b

File tree

8 files changed

+5
-569
lines changed

8 files changed

+5
-569
lines changed

dapr/aio/clients/grpc/client.py

Lines changed: 1 addition & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
from warnings import warn
2626

27-
from typing import Callable, Dict, Optional, Text, Union, Sequence, List, Any, Awaitable
27+
from typing import Callable, Dict, Optional, Text, Union, Sequence, List, Any
2828
from typing_extensions import Self
2929

3030
from google.protobuf.message import Message as GrpcMessage
@@ -39,14 +39,12 @@
3939
AioRpcError,
4040
)
4141

42-
from dapr.aio.clients.grpc.subscription import Subscription
4342
from dapr.clients.exceptions import DaprInternalError, DaprGrpcError
4443
from dapr.clients.grpc._crypto import EncryptOptions, DecryptOptions
4544
from dapr.clients.grpc._state import StateOptions, StateItem
4645
from dapr.clients.grpc._helpers import getWorkflowRuntimeStatus
4746
from dapr.clients.health import DaprHealth
4847
from dapr.clients.retry import RetryPolicy
49-
from dapr.common.pubsub.subscription import StreamInactiveError
5048
from dapr.conf.helpers import GrpcEndpoint
5149
from dapr.conf import settings
5250
from dapr.proto import api_v1, api_service_v1, common_v1
@@ -96,7 +94,6 @@
9694
UnlockResponse,
9795
GetWorkflowResponse,
9896
StartWorkflowResponse,
99-
TopicEventResponse,
10097
)
10198

10299

@@ -485,72 +482,6 @@ async def publish_event(
485482

486483
return DaprResponse(await call.initial_metadata())
487484

488-
async def subscribe(
489-
self,
490-
pubsub_name: str,
491-
topic: str,
492-
metadata: Optional[dict] = None,
493-
dead_letter_topic: Optional[str] = None,
494-
) -> Subscription:
495-
"""
496-
Subscribe to a topic with a bidirectional stream
497-
498-
Args:
499-
pubsub_name (str): The name of the pubsub component.
500-
topic (str): The name of the topic.
501-
metadata (Optional[dict]): Additional metadata for the subscription.
502-
dead_letter_topic (Optional[str]): Name of the dead-letter topic.
503-
504-
Returns:
505-
Subscription: The Subscription object managing the stream.
506-
"""
507-
subscription = Subscription(self._stub, pubsub_name, topic, metadata, dead_letter_topic)
508-
await subscription.start()
509-
return subscription
510-
511-
async def subscribe_with_handler(
512-
self,
513-
pubsub_name: str,
514-
topic: str,
515-
handler_fn: Callable[..., TopicEventResponse],
516-
metadata: Optional[dict] = None,
517-
dead_letter_topic: Optional[str] = None,
518-
) -> Callable[[], Awaitable[None]]:
519-
"""
520-
Subscribe to a topic with a bidirectional stream and a message handler function
521-
522-
Args:
523-
pubsub_name (str): The name of the pubsub component.
524-
topic (str): The name of the topic.
525-
handler_fn (Callable[..., TopicEventResponse]): The function to call when a message is received.
526-
metadata (Optional[dict]): Additional metadata for the subscription.
527-
dead_letter_topic (Optional[str]): Name of the dead-letter topic.
528-
529-
Returns:
530-
Callable[[], Awaitable[None]]: An async function to close the subscription.
531-
"""
532-
subscription = await self.subscribe(pubsub_name, topic, metadata, dead_letter_topic)
533-
534-
async def stream_messages(sub: Subscription):
535-
while True:
536-
try:
537-
message = await sub.next_message()
538-
if message:
539-
response = await handler_fn(message)
540-
if response:
541-
await subscription.respond(message, response.status)
542-
else:
543-
continue
544-
except StreamInactiveError:
545-
break
546-
547-
async def close_subscription():
548-
await subscription.close()
549-
550-
asyncio.create_task(stream_messages(subscription))
551-
552-
return close_subscription
553-
554485
async def get_state(
555486
self,
556487
store_name: str,

dapr/aio/clients/grpc/subscription.py

Lines changed: 0 additions & 110 deletions
This file was deleted.

daprdocs/content/en/python-sdk-docs/python-client.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,10 @@ You can create a streaming subscription to a PubSub topic using either the `subs
261261
or `subscribe_handler` methods.
262262

263263
The `subscribe` method returns a `Subscription` object, which allows you to pull messages from the
264-
stream by
265-
calling the `next_message` method. This will block on the main thread while waiting for messages.
266-
When done, you should call the close method to terminate the
267-
subscription and stop receiving messages.
264+
stream by calling the `next_message` method. This will block on the main thread while waiting for
265+
messages.
266+
When done, you should call the close method to terminate the subscription and stop receiving
267+
messages.
268268

269269
The `subscribe_with_handler` method accepts a callback function that is executed for each message
270270
received from the stream.

examples/pubsub-streaming-async/README.md

Lines changed: 0 additions & 122 deletions
This file was deleted.

examples/pubsub-streaming-async/publisher.py

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)