Skip to content

Commit 3968c39

Browse files
Grzegorz BaziorMBoldyrev
authored andcommitted
Add optional argument to configure GRPC max message length
Signed-off-by: Grzegorz Bazior <[email protected]>
1 parent 293d682 commit 3968c39

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

iroha/iroha.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,19 +341,26 @@ class IrohaGrpc(object):
341341
Possible implementation of gRPC transport to Iroha
342342
"""
343343

344-
def __init__(self, address=None, timeout=None, secure=False):
344+
def __init__(self, address=None, timeout=None, secure=False, *, max_message_length=None):
345345
"""
346346
Create Iroha gRPC client
347347
:param address: Iroha Torii address with port, example "127.0.0.1:50051"
348348
:param timeout: timeout for network I/O operations in seconds
349349
:param secure: enable grpc ssl channel
350+
:param max_message_length: it is max message length in bytes for grpc
350351
"""
351352
self._address = address if address else '127.0.0.1:50051'
352353

354+
channel_kwargs = {}
355+
if max_message_length is not None:
356+
channel_kwargs['options'] = [
357+
('grpc.max_send_message_length', max_message_length),
358+
('grpc.max_receive_message_length', max_message_length)]
359+
353360
if secure:
354-
self._channel = grpc.secure_channel(self._address, grpc.ssl_channel_credentials())
361+
self._channel = grpc.secure_channel(self._address, grpc.ssl_channel_credentials(), **channel_kwargs)
355362
else:
356-
self._channel = grpc.insecure_channel(self._address)
363+
self._channel = grpc.insecure_channel(self._address, **channel_kwargs)
357364

358365
self._timeout = timeout
359366
self._command_service_stub = endpoint_pb2_grpc.CommandService_v1Stub(

0 commit comments

Comments
 (0)