Skip to content

Commit

Permalink
add grpc compression
Browse files Browse the repository at this point in the history
Signed-off-by: PowderLi <[email protected]>
  • Loading branch information
PowderLi committed Mar 28, 2024
1 parent b9a10c9 commit 26beb5f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pymilvus/client/grpc_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@
len_of,
)

_DESCRIPTION = "A client capable of compression."
_COMPRESSION_OPTIONS = {
"none": grpc.Compression.NoCompression,
"deflate": grpc.Compression.Deflate,
"gzip": grpc.Compression.Gzip,
}

class GrpcHandler:
# pylint: disable=too-many-instance-attributes
Expand All @@ -84,6 +90,7 @@ def __init__(
self._log_level = None
self._request_id = None
self._user = kwargs.get("user", None)
self._compression_type = kwargs.get("compression_type", "none")
self._set_authorization(**kwargs)
self._setup_db_interceptor(kwargs.get("db_name", None))
self._setup_grpc_channel()
Expand Down Expand Up @@ -193,6 +200,7 @@ def _setup_grpc_channel(self):
self._channel = grpc.insecure_channel(
self._address,
options=opts,
compression=_COMPRESSION_OPTIONS[self._compression_type],
)
else:
if self._server_name != "":
Expand Down Expand Up @@ -223,6 +231,7 @@ def _setup_grpc_channel(self):
self._address,
creds,
options=opts,
compression=_COMPRESSION_OPTIONS[self._compression_type],
)

# avoid to add duplicate headers.
Expand Down
2 changes: 2 additions & 0 deletions pymilvus/orm/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ def connect(
to each RPC call.
* *keep_alive* (``bool``) --
Optional. Default is false. If set to true, client will keep an alive connection.
* *compression_type* (``str``) --
Optional. Default is none. ["none", "deflate", "gzip"]
* *db_name* (``str``) --
Optional. default database name of this connection
* *client_key_path* (``str``) --
Expand Down

0 comments on commit 26beb5f

Please sign in to comment.