The C based gRPC (C++, Python, Ruby, Objective-C, PHP, C#) https://grpc.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.8 KiB

Added Python Example for Flow Control (#37044) Have added the required client, server, proto and proto generated files. The design of the example is as follows: 1. The client sends a bulk amount of data(approx. 2 KB in each iteration) to the server in a streaming call. 2. The server applies back-pressure by delaying reading of the requests, which makes the client pause sending requests after around 64KB 3. The client then resumes sending requests only after the server reads a few requests and clears the buffer. By adding print statements on data send/receive on both client and server side, the client pausing/resuming requests can be seen clearly. The client and server logs can be seen below: **Client Logs** ``` Request 10: Sent 20000 bytes in total Request 20: Sent 40000 bytes in total Request 30: Sent 60000 bytes in total Request 40: Sent 80000 bytes in total Received 10 responses Request 50: Sent 100000 bytes in total Received 20 responses Request 60: Sent 120000 bytes in total Received 30 responses Request 70: Sent 140000 bytes in total Received 40 responses Request 80: Sent 160000 bytes in total Received 50 responses Request 90: Sent 180000 bytes in total Received 60 responses Request 100: Sent 200000 bytes in total Received 70 responses Received 80 responses Received 90 responses Received 100 responses ``` **Server Logs** ``` Server started, listening on 50051 Request 10: Received 20000 bytes in total Request 10: Sent 20000 bytes in total Request 20: Received 40000 bytes in total Request 20: Sent 40000 bytes in total Request 30: Received 60000 bytes in total Request 30: Sent 60000 bytes in total Request 40: Received 80000 bytes in total Request 40: Sent 80000 bytes in total Request 50: Received 100000 bytes in total Request 50: Sent 100000 bytes in total Request 60: Received 120000 bytes in total Request 60: Sent 120000 bytes in total Request 70: Received 140000 bytes in total Request 70: Sent 140000 bytes in total Request 80: Received 160000 bytes in total Request 80: Sent 160000 bytes in total Request 90: Received 180000 bytes in total Request 90: Sent 180000 bytes in total Request 100: Received 200000 bytes in total Request 100: Sent 200000 bytes in total ```
5 months ago
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: helloworld.proto
# Protobuf Python Version: 5.26.1
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import symbol_database as _symbol_database
from google.protobuf.internal import builder as _builder
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x10helloworld.proto\x12\nhelloworld\"\x1c\n\x0cHelloRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"\x1d\n\nHelloReply\x12\x0f\n\x07message\x18\x01 \x01(\t2\xe4\x01\n\x07Greeter\x12>\n\x08SayHello\x12\x18.helloworld.HelloRequest\x1a\x16.helloworld.HelloReply\"\x00\x12K\n\x13SayHelloStreamReply\x12\x18.helloworld.HelloRequest\x1a\x16.helloworld.HelloReply\"\x00\x30\x01\x12L\n\x12SayHelloBidiStream\x12\x18.helloworld.HelloRequest\x1a\x16.helloworld.HelloReply\"\x00(\x01\x30\x01\x42\x36\n\x1bio.grpc.examples.helloworldB\x0fHelloWorldProtoP\x01\xa2\x02\x03HLWb\x06proto3')
_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'helloworld_pb2', _globals)
if not _descriptor._USE_C_DESCRIPTORS:
_globals['DESCRIPTOR']._loaded_options = None
_globals['DESCRIPTOR']._serialized_options = b'\n\033io.grpc.examples.helloworldB\017HelloWorldProtoP\001\242\002\003HLW'
_globals['_HELLOREQUEST']._serialized_start=32
_globals['_HELLOREQUEST']._serialized_end=60
_globals['_HELLOREPLY']._serialized_start=62
_globals['_HELLOREPLY']._serialized_end=91
_globals['_GREETER']._serialized_start=94
_globals['_GREETER']._serialized_end=322
# @@protoc_insertion_point(module_scope)