Skip to content

Commit

Permalink
Refactor endpoint_uri property to private func.
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbartel committed Sep 8, 2023
1 parent 6d63be3 commit 583dbf3
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions python/lib/communication/dmod/communication/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,18 @@ def __init__(self, *, endpoint_host: str, endpoint_port: Union[int, str], endpoi
else:
self._client_ssl_context = None

@abstractmethod
def _get_endpoint_uri(self) -> str:
"""
Get the endpoint for the client to connect to when opening a connection.
Returns
-------
str
The endpoint for the client to connect to when opening a connection.
"""
pass

@abstractmethod
async def async_send(self, data: Union[str, bytearray, bytes], await_response: bool = False) -> Optional[str]:
"""
Expand Down Expand Up @@ -159,19 +171,6 @@ async def async_recv(self) -> str:
"""
pass

@property
@abstractmethod
def endpoint_uri(self) -> str:
"""
The endpoint for the client to connect to when opening a connection.
Returns
-------
str
The endpoint for the client to connect to when opening a connection.
"""
pass


class AuthClient:
"""
Expand Down Expand Up @@ -856,10 +855,9 @@ async def _establish_connection(self) -> CONN:
CONN
A newly established connection.
"""
return await websockets.connect(self.endpoint_uri, ssl=self._client_ssl_context)
return await websockets.connect(self._get_endpoint_uri(), ssl=self._client_ssl_context)

@property
def endpoint_uri(self) -> str:
def _get_endpoint_uri(self) -> str:
"""
The endpoint for the client to connect to when opening a connection.
Expand Down

0 comments on commit 583dbf3

Please sign in to comment.