gRPC 笔记

Intro

A high performance, open source universal RPC framework

https://www.grpc.io/

gRPC is a modern open source high performance RPC framework that can run in any environment. It can efficiently connect services in and across data centers with pluggable support for load balancing, tracing, health checking and authentication. It is also applicable in last mile of distributed computing to connect devices, mobile applications and browsers to backend services.

  • Simple service definition Define your service using Protocol Buffers, a powerful binary serialization toolset and language
  • Start quickly and scale Install runtime and dev environments with a single line and also scale to millions of RPCs per second with the framework
  • Works across languages and platforms Automatically generate idiomatic client and server stubs for your service in a variety of languages and platforms
  • Bi-directional streaming and integrated auth Bi-directional streaming and fully integrated pluggable authentication with HTTP/2-based transport

Overview

landing-2

Protocol Compiler

Download: https://github.com/protocolbuffers/protobuf/releases

1
2
3
4
5
6
7
8
9
# https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/protoc-3.14.0-osx-x86_64.zip

cp /Users/shankai/Downloads/protoc-3.14.0-osx-x86_64/bin/protoc /usr/local/bin/protoc

protoc -h

# cd /path/xx.proto

protoc --java_out=../java/ vehicle-service.proto

Example

java & nodejs

https://github.com/shankai/artifacts/tree/master/grpc-example

Reference

Java

https://www.grpc.io/docs/languages/java/quickstart/

https://www.grpc.io/docs/languages/java/basics/

https://github.com/grpc/grpc-java/blob/master/README.md

Node

https://www.grpc.io/docs/languages/node/quickstart/