GRPC学习(An RPC library and framework)
来源:互联网 发布:mac上玩dota2 编辑:程序博客网 时间:2024/06/05 09:02
汇总:
https://grpc.io/docs/
github:
https://github.com/grpc/grpc
介绍:
https://grpc.io/docs/guides/index.html
快速:
https://grpc.io/docs/quickstart/
gRPC Basics-Python:
https://grpc.io/docs/tutorials/basic/python.html
python 快速:
https://grpc.io/docs/quickstart/python.html
#Ensure you have pip version 9.0.1 or higher:python -m pip install --upgrade pip#If you cannot upgrade pip due to a system-owned installation, #you can run the example in a virtualenv:python -m pip install virtualenvvirtualenv venvsource venv/bin/activatepython -m pip install --upgrade pip#Install gRPC:python -m pip install grpcio#Install gRPC toolspython -m pip install grpcio-tools#Download the example# Clone the repository to get the example code:git clone -b v1.7.x https://github.com/grpc/grpc# Navigate to the "hello, world" Python example:cd grpc/examples/python/helloworld#Run a gRPC application#From the examples/python/helloworld directory:#1.Run the serverpython greeter_server.py#2.In another terminal, run the clientpython greeter_client.py#Congratulations! You’ve just run a client-server application with gRPC.
Update a gRPC service
#Edit examples/protos/helloworld.proto// The greeting service definition.service Greeter { // Sends a greeting rpc SayHello (HelloRequest) returns (HelloReply) {} // Sends another greeting rpc SayHelloAgain (HelloRequest) returns (HelloReply) {}}// The request message containing the user's name.message HelloRequest { string name = 1;}// The response message containing the greetingsmessage HelloReply { string message = 1;}#Generate gRPC code#From the examples/python/helloworld directory, run:python -m grpc_tools.protoc -I../../protos --python_out=. --grpc_python_out=. ../../protos/helloworld.proto#This regenerates helloworld_pb2.py which contains our generated request #and response classes and helloworld_pb2_grpc.py #which contains our generated client and server classes.#Update and run the application#Update the server#In the same directory, open greeter_server.pyclass Greeter(helloworld_pb2_grpc.GreeterServicer): def SayHello(self, request, context): return helloworld_pb2.HelloReply(message='Hello, %s!' % request.name) def SayHelloAgain(self, request, context): return helloworld_pb2.HelloReply(message='Hello again, %s!' % request.name)...#Update the client#In the same directory, open greeter_client.py. Call the new method like this:def run(): channel = grpc.insecure_channel('localhost:50051') stub = helloworld_pb2_grpc.GreeterStub(channel) response = stub.SayHello(helloworld_pb2.HelloRequest(name='you')) print("Greeter client received: " + response.message) response = stub.SayHelloAgain(helloworld_pb2.HelloRequest(name='you')) print("Greeter client received: " + response.message)#Run!#Just like we did before, from the examples/python/helloworld directory:#1.Run the server python greeter_server.py#2.In another terminal, run the clientpython greeter_client.py
proto buffers:
https://developers.google.com/protocol-buffers/docs/overview
阅读全文
0 0
- GRPC学习(An RPC library and framework)
- rpc框架之gRPC 学习 - hello world
- Triple is an RPC framework(Netty,ZooKeeper)
- 通过实例带你学习RPC框架gRPC
- 通过 实例带你学习RPC框架gRPC
- rpc框架--grpc-java
- Python RPC 之 gRPC
- 学习GRPC
- The difference between Framework and Library
- Open Source Framework and Library Recommendations
- google开源RPC框架gRPC:安装
- google的RPC框架:grpc 介绍
- Google 开源 RPC 框架 gRPC 初探
- Fluid Geometry - An Animation Library and Configuration Application
- An Application Program Dynamically Loading and Linking the Shared Library
- GRPC学习笔记
- grpc学习记录
- gRPC学习笔记(一)
- POJ3415 Common Substrings 【后缀数组 + 单调栈】
- mongo数据库的各种查询语句示例(比较全的)
- [springBoot系列]--springBoot注解大全
- python----------------正则实现计算器功能
- 插件化开发之发展历史及特性区别总结
- GRPC学习(An RPC library and framework)
- PDF控件Aspose.Pdf 12月新版17.12发布 | 附下载
- fresco加载GIF格式图片
- Linux网络编程之TCP编程,select多路复用和超时检测,网络属性设置setsockopt之快速重启(非常经典)
- 知乎上关于‘深度学习调参技巧’讨论
- 数据结构实验之查找一:二叉排序树
- oracle中随机抽取N条记录
- nuxus maven库在maven项目中如何使用
- OpenCV-图像的融合