Skip to content

Commit

Permalink
Fixes bug of constructor argument being used as http endpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Elena Kolevska <elena@kolevska.com>
  • Loading branch information
elena-kolevska committed Oct 18, 2023
1 parent ff08864 commit bf7af70
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
3 changes: 1 addition & 2 deletions dapr/clients/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ def __init__(
if http_timeout_seconds is None:
http_timeout_seconds = settings.DAPR_HTTP_TIMEOUT_SECONDS
self.invocation_client = DaprInvocationHttpClient(headers_callback=headers_callback,
timeout=http_timeout_seconds,
address=address)
timeout=http_timeout_seconds)
elif invocation_protocol == 'GRPC':
pass
else:
Expand Down
10 changes: 3 additions & 7 deletions dapr/clients/http/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ class DaprHttpClient:
def __init__(self,
message_serializer: 'Serializer',
timeout: Optional[int] = 60,
headers_callback: Optional[Callable[[], Dict[str, str]]] = None,
address: Optional[str] = None):
headers_callback: Optional[Callable[[], Dict[str, str]]] = None):
"""Invokes Dapr over HTTP.
Args:
Expand All @@ -49,15 +48,12 @@ def __init__(self,
self._timeout = aiohttp.ClientTimeout(total=timeout)
self._serializer = message_serializer
self._headers_callback = headers_callback
self._address = address

def get_api_url(self) -> str:
if self._address:
return '{}/{}'.format(self._address, settings.DAPR_API_VERSION)
if settings.DAPR_HTTP_ENDPOINT:
return '{}/{}'.format(settings.DAPR_HTTP_ENDPOINT, settings.DAPR_API_VERSION)
else:
return 'http://{}:{}/{}'.format(settings.DAPR_RUNTIME_HOST,

return 'http://{}:{}/{}'.format(settings.DAPR_RUNTIME_HOST,
settings.DAPR_HTTP_PORT, settings.DAPR_API_VERSION)

async def send_bytes(
Expand Down
5 changes: 2 additions & 3 deletions dapr/clients/http/dapr_invocation_http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,14 @@ class DaprInvocationHttpClient:
def __init__(
self,
timeout: int = 60,
headers_callback: Optional[Callable[[], Dict[str, str]]] = None,
address: Optional[str] = None):
headers_callback: Optional[Callable[[], Dict[str, str]]] = None):
"""Invokes Dapr's API for method invocation over HTTP.
Args:
timeout (int, optional): Timeout in seconds, defaults to 60.
headers_callback (lambda: Dict[str, str]], optional): Generates header for each request.
"""
self._client = DaprHttpClient(DefaultJSONSerializer(), timeout, headers_callback, address)
self._client = DaprHttpClient(DefaultJSONSerializer(), timeout, headers_callback)

async def invoke_method_async(
self,
Expand Down

0 comments on commit bf7af70

Please sign in to comment.