update notes

pull/19938/head
kerbalwzy 5 years ago
parent d1b64c3a3e
commit d33d30a595
  1. 6
      examples/python/easy_start_demo/PyClient.py
  2. 6
      examples/python/easy_start_demo/PyServer.py
  3. 6
      examples/python/easy_start_demo/README.md
  4. 8
      examples/python/easy_start_demo/demo.proto

@ -15,7 +15,7 @@ ClientId = 1
# 简单模式
# Unary
# Simple
def simple_method(stub):
print("--------------Call SimpleMethod Begin--------------")
req = demo_pb2.Request(Cid=ClientId, ReqMsg="called by Python client")
@ -25,7 +25,7 @@ def simple_method(stub):
# 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应)
# Client Streaming (In a single call, the client can transfer data to the server several times,
# Request-streaming (In a single call, the client can transfer data to the server several times,
# but the server can only return a response once.)
def c_stream_method(stub):
print("--------------Call CStreamMethod Begin--------------")
@ -43,7 +43,7 @@ def c_stream_method(stub):
# 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应)
# Server Streaming (In a single call, the client can only transmit data to the server at one time,
# Response-streaming (In a single call, the client can only transmit data to the server at one time,
# but the server can return the response many times.)
def s_stream_method(stub):
print("--------------Call SStreamMethod Begin--------------")

@ -20,14 +20,14 @@ ServerId = 1
class DemoServer(demo_pb2_grpc.GRPCDemoServicer):
# 简单模式
# Unary
# Simple
def SimpleMethod(self, request, context):
print(f"SimpleMethod called by client({request.Cid}) the message: {request.ReqMsg}")
resp = demo_pb2.Response(Sid=ServerId, RespMsg="Python server SimpleMethod Ok!!!!")
return resp
# 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应)
# Client Streaming (In a single call, the client can transfer data to the server several times,
# Request-streaming (In a single call, the client can transfer data to the server several times,
# but the server can only return a response once.)
def CStreamMethod(self, request_iterator, context):
print("CStreamMethod called by client...")
@ -37,7 +37,7 @@ class DemoServer(demo_pb2_grpc.GRPCDemoServicer):
return resp
# 服务端流模式(在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应)
# Server Streaming (In a single call, the client can only transmit data to the server at one time,
# Response-streaming (In a single call, the client can only transmit data to the server at one time,
# but the server can return the response many times.)
def SStreamMethod(self, request, context):
print(f"SStreamMethod called by client({request.Cid}), message={request.ReqMsg}")

@ -2,18 +2,18 @@
###主要是介绍了在Python中使用GRPC时, 进行数据传输的四种方式。
###This paper mainly introduces four ways of data transmission when GRPC is used in Python.
- ####简单模式 (Unary)
- ####简单模式 (Simple)
```text
没啥好说的,跟调普通方法没差
There's nothing to say. It's no different from the usual way.
```
- ####客户端流模式 (Client Streaming)
- ####客户端流模式 (Request-streaming)
```text
在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应.
In a single call, the client can transfer data to the server several times,
but the server can only return a response once.
```
- ####服务端流模式 (Server Streaming)
- ####服务端流模式 (Response-streaming)
```text
在一次调用中, 客户端只能一次向服务器传输数据, 但是服务器可以多次返回响应
In a single call, the client can only transmit data to the server at one time,

@ -30,21 +30,21 @@ message Response {
// `service` is used to define methods for GRPC services in a fixed format, similar to defining an interface in Golang
service GRPCDemo {
//
// Unary
// Simple
rpc SimpleMethod (Request) returns (Response);
// , ,
// Client Streaming (In a single call, the client can transfer data to the server several times,
// Request-streaming (In a single call, the client can transfer data to the server several times,
// but the server can only return a response once.)
rpc CStreamMethod (stream Request) returns (Response);
// , ,
// Server Streaming (In a single call, the client can only transmit data to the server at one time,
// Response-streaming (In a single call, the client can only transmit data to the server at one time,
// but the server can return the response many times.)
rpc SStreamMethod (Request) returns (stream Response);
// (, )
// Bidirectional Streaming (In a single call, both client and server can send and receive data
// Bidirectional streaming (In a single call, both client and server can send and receive data
// to each other multiple times.)
rpc TWFMethod (stream Request) returns (stream Response);
}

Loading…
Cancel
Save