I hava a python grpc service that streams large amounts of data to client microservices.
service GeoService {
rpc GetGeoCoordinates(GetRequest) returns (stream Chunk){}
}
message Chunk {
bytes data_part = 1;
}
I can not send more that 4MB of data at once because tcp connection has limits. Here is my code (only relevant part):
def GetGeoCoordinates(self, request, context):
...
...
dataBytes = geo_pb2.Chunk(data_part=bytes(json.dumps(coordinates["data"]), 'utf-8'))
yield dataBytes
How can I send this data in 4MB chunks?
Also is it a good practice to json.dumps() large data then stream? Any help is appreciated.
resultcan be consumed as stream