Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding a max size parameter to the connection function #131

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions surrealdb/async_surrealdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ async def __aenter__(self):
async def __aexit__(self, *args):
await self.close()

async def connect(self) -> Self:
async def connect(self, max_size: int = 1024) -> Self:
"""Connect to SurrealDB."""
await self.__connection.connect()
await self.__connection.connect(max_size=max_size)
return self

async def close(self):
Expand Down
2 changes: 1 addition & 1 deletion surrealdb/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ async def use(self, namespace: str, database: str) -> None:
"""
raise NotImplementedError("use method must be implemented")

async def connect(self) -> None:
async def connect(self, max_size: int = 2024) -> None:
"""
Establish a connection to the server.
"""
Expand Down
2 changes: 1 addition & 1 deletion surrealdb/connection_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async def unset(self, key: str):
if self._request_variables.get(key) is not None:
del self._request_variables[key]

async def connect(self) -> None:
async def connect(self, _max_size: int = 1024) -> None:
if self._base_url is None:
raise SurrealDbConnectionError("base url not set for http connection")

Expand Down
6 changes: 4 additions & 2 deletions surrealdb/connection_ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ class WebsocketConnection(Connection):
_ws: ClientConnection
_receiver_task: Task

async def connect(self):
async def connect(self, max_size: int = 1024) -> None:
try:
self._ws = await connect(
self._base_url + "/rpc", subprotocols=[Subprotocol("cbor")]
self._base_url + "/rpc",
subprotocols=[Subprotocol("cbor")],
max_size=max_size,
)
self._receiver_task = asyncio.create_task(self.listen_to_ws(self._ws))
except Exception as e:
Expand Down
6 changes: 4 additions & 2 deletions surrealdb/surrealdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ def __enter__(self):
def __exit__(self, *args):
self.close()

def connect(self) -> Self:
def connect(self, max_size: int = 1024) -> Self:
"""Connect to SurrealDB."""
loop_manager = AsyncioRuntime()
loop_manager.loop.run_until_complete(self.__connection.connect())
loop_manager.loop.run_until_complete(
self.__connection.connect(max_size=max_size)
)

return self

Expand Down
Loading