Skip to content

Commit d4c0227

Browse files
chore: Rename wait_until_ready to wait_for_sidecar (#843)
Signed-off-by: Albert Callarisa <[email protected]> Co-authored-by: Elena Kolevska <[email protected]>
1 parent d005a15 commit d4c0227

File tree

7 files changed

+23
-13
lines changed

7 files changed

+23
-13
lines changed

dapr/aio/clients/grpc/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def __init__(
153153
max_grpc_message_length (int, optional): The maximum grpc send and receive
154154
message length in bytes.
155155
"""
156-
DaprHealth.wait_until_ready()
156+
DaprHealth.wait_for_sidecar()
157157
self.retry_policy = retry_policy or RetryPolicy()
158158

159159
useragent = f'dapr-sdk-python/{__version__}'

dapr/aio/clients/grpc/subscription.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ async def outgoing_request_iterator():
5151

5252
async def reconnect_stream(self):
5353
await self.close()
54-
DaprHealth.wait_until_ready()
54+
DaprHealth.wait_for_sidecar()
5555
print('Attempting to reconnect...')
5656
await self.start()
5757

dapr/clients/grpc/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def __init__(
145145
message length in bytes.
146146
retry_policy (RetryPolicy optional): Specifies retry behaviour
147147
"""
148-
DaprHealth.wait_until_ready()
148+
DaprHealth.wait_for_sidecar()
149149
self.retry_policy = retry_policy or RetryPolicy()
150150

151151
useragent = f'dapr-sdk-python/{__version__}'

dapr/clients/grpc/subscription.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def outgoing_request_iterator():
6565

6666
def reconnect_stream(self):
6767
self.close()
68-
DaprHealth.wait_until_ready()
68+
DaprHealth.wait_for_sidecar()
6969
print('Attempting to reconnect...')
7070
self.start()
7171

dapr/clients/health.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import urllib.request
1616
import urllib.error
1717
import time
18+
from warnings import warn
1819

1920
from dapr.clients.http.conf import DAPR_API_TOKEN_HEADER, USER_AGENT_HEADER, DAPR_USER_AGENT
2021
from dapr.clients.http.helpers import get_api_url
@@ -24,6 +25,15 @@
2425
class DaprHealth:
2526
@staticmethod
2627
def wait_until_ready():
28+
warn(
29+
'This method is deprecated. Use DaprHealth.wait_for_sidecar instead.',
30+
DeprecationWarning,
31+
stacklevel=2,
32+
)
33+
DaprHealth.wait_for_sidecar()
34+
35+
@staticmethod
36+
def wait_for_sidecar():
2737
health_url = f'{get_api_url()}/healthz/outbound'
2838
headers = {USER_AGENT_HEADER: DAPR_USER_AGENT}
2939
if settings.DAPR_API_TOKEN is not None:

dapr/clients/http/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def __init__(
5151
timeout (int, optional): Timeout in seconds, defaults to 60.
5252
headers_callback (lambda: Dict[str, str]], optional): Generates header for each request.
5353
"""
54-
DaprHealth.wait_until_ready()
54+
DaprHealth.wait_for_sidecar()
5555

5656
self._timeout = aiohttp.ClientTimeout(total=timeout)
5757
self._serializer = message_serializer

tests/clients/test_heatlhcheck.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
class DaprHealthCheckTests(unittest.TestCase):
2525
@patch.object(settings, 'DAPR_HTTP_ENDPOINT', 'http://domain.com:3500')
2626
@patch('urllib.request.urlopen')
27-
def test_wait_until_ready_success(self, mock_urlopen):
27+
def test_wait_for_sidecar_success(self, mock_urlopen):
2828
mock_urlopen.return_value.__enter__.return_value = MagicMock(status=200)
2929

3030
try:
31-
DaprHealth.wait_until_ready()
31+
DaprHealth.wait_for_sidecar()
3232
except Exception as e:
33-
self.fail(f'wait_until_ready() raised an exception unexpectedly: {e}')
33+
self.fail(f'wait_for_sidecar() raised an exception unexpectedly: {e}')
3434

3535
mock_urlopen.assert_called_once()
3636

@@ -45,13 +45,13 @@ def test_wait_until_ready_success(self, mock_urlopen):
4545
@patch.object(settings, 'DAPR_HTTP_ENDPOINT', 'http://domain.com:3500')
4646
@patch.object(settings, 'DAPR_API_TOKEN', 'mytoken')
4747
@patch('urllib.request.urlopen')
48-
def test_wait_until_ready_success_with_api_token(self, mock_urlopen):
48+
def test_wait_for_sidecar_success_with_api_token(self, mock_urlopen):
4949
mock_urlopen.return_value.__enter__.return_value = MagicMock(status=200)
5050

5151
try:
52-
DaprHealth.wait_until_ready()
52+
DaprHealth.wait_for_sidecar()
5353
except Exception as e:
54-
self.fail(f'wait_until_ready() raised an exception unexpectedly: {e}')
54+
self.fail(f'wait_for_sidecar() raised an exception unexpectedly: {e}')
5555

5656
mock_urlopen.assert_called_once()
5757

@@ -64,13 +64,13 @@ def test_wait_until_ready_success_with_api_token(self, mock_urlopen):
6464

6565
@patch.object(settings, 'DAPR_HEALTH_TIMEOUT', '2.5')
6666
@patch('urllib.request.urlopen')
67-
def test_wait_until_ready_timeout(self, mock_urlopen):
67+
def test_wait_for_sidecar_timeout(self, mock_urlopen):
6868
mock_urlopen.return_value.__enter__.return_value = MagicMock(status=500)
6969

7070
start = time.time()
7171

7272
with self.assertRaises(TimeoutError):
73-
DaprHealth.wait_until_ready()
73+
DaprHealth.wait_for_sidecar()
7474

7575
self.assertGreaterEqual(time.time() - start, 2.5)
7676
self.assertGreater(mock_urlopen.call_count, 1)

0 commit comments

Comments
 (0)