A High-Performance, Open-Source Universal RPC Framework: High Performance, Open Source Universal RPC Framework
The so-called RPC (Remote Procedure Call Remote Process Call) framework is actually provided a mechanism that can be communicated between the applications, and also follow the Server / Client model. When using it, the client calls the server-connected interface is like calling a local function.
Both GRPC and RESTFUL API provide a set of communication mechanisms for server / client model communication, and they all use HTTP as the underlying transport protocol (strictly said that the HTTP2.0 used by GRPC, and the Restful API is not necessarily) .
GRPC can define the interface through Protobuf, so that there can beMore stringent interface constraints。
In addition, data sequence can be serialized through ProtobufBinary codeThis will greatly reduce the amount of data that needs to be transmitted, thereby greatly improves performance.
GRPC can easily supportStreamCommunication (theoretically via HTTP2.0 can use Streaming mode, but usually the RESTful API of the web service seems to be so useful, usually flow data applications such as video streams, generally use specializes such as HLS, RTMP, etc. It's not us usually web service, but there is a dedicated server application.)
Protobuf is actually a data transfer format and specification similar to JSON or XML, which is used when communicating between different applications or processes. The information transmitted during communication is packed by the Message data structure defined by Protobuf, and then compiled into binary code streams and then transmits or stores.
In contrast, Protobuf has the following advantages:
The protoc command comes from https://github.com/golang/protobuf, which can generate serialization and reverse selecente code, without Go-related code.
Protoc is a compiler of the protobuf file (.proto), with it to translate the .proto file into a source code corresponding to a variety of programming languages.
Compilation method
protoc --go_out=./go1/ ./proto/my.proto
Protoc's version can be viewed through Protoc --Version
Protoc-gen-GO plug-in, from https://github.com/golang/protobuf/protoc-gen-go, you can generate GO-related code, in addition to the above serialization and reverse sequence code, add some communication public Library. It is a Go version in the Protobuf compilation plugin series
Compilation method
protoc --go_out=plugins=grpc:./go2/ ./proto/my.proto
GRPC comes from https://google.golang.org/grpc or https://github.com/grpc/grpc-go ,Protoc and protoc-gen-go These two tools are not there, The protoc and protoc-gen-g are needed to be placed in the system PATH.
Method 1: Download binary directly
Download address: https://github.com/protocolbuffers/protobuf/releases

Download the corresponding OS compression package to decompress,binYou can see the compiled Protoc, you can use it in the system PATH.
Method Two:
Download the source code slowly compile, but I won't hahahahaha
Project address: https://github.com/grpc/grpc
go get google.golang.org/grpc
But it will report an error: (I will not go online.
package google.golang.org/grpc: unrecognized import path “google.golang.org/grpc”(https fetch: Get https://google.golang.org/grpc?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
git clone https://github.com/grpc/grpc-go.git $GOPATH/src/google.golang.org/grpc
git clone https://github.com/golang/net.git $GOPATH/src/golang.org/x/net
git clone https://github.com/golang/text.git $GOPATH/src/golang.org/x/text
cd $GOPATH/src/
go install google.golang.org/grpc
go installThe deficiencies are gitclone
go get -u github.com/golang/protobuf/protoc-gen-go
exist$GOPATH/binGo down to generate corresponding binary
protoc --go_out=output_directory input_directory/file.proto
Where "-go_out =" means generating a Go file, Protoc automatically looks for the Protoc-Gen-GO execution file in the PATH (system execution path).
If you need to download the specified version of Protoc-Gen-Go, then: (Version in version can passGit Checkout [Tab Key]Add it to see what
cd "$(go env GOPATH)"/src/github.com/golang/protobuf
VERSION=v1.5.0
git checkout $VERSION
cd protoc-gen-go
go install
The generated binary will also be placed$GOPATH/binMiddle (remember$GOPATH/binJoin the system path, otherwise you can find it when using protoc
Reference link:
https://www.jianshu.com/p/dba4c7a6d608
https://blog.csdn.net/stpeace/article/details/82713647
https://studygolang.com/articles/12673?fr=sidebar
If there is something wrong, please point out, thank you ~
Interface implementation: Simple RPC: The client initiates the Point request, the server returns the Feature Message The entire interface request response process: 1. Execute the response process: onn...
Original address:GRPC learning notes | detailed tutorial(Permanent address, save the URL is not lost) Problem Description We believe that after the prevailing from DevOps, the operation and maintenanc...
This paper introduces some key points of the gRPC concept through the structural overview and life cycle of gRPC. Overview Service definition Like many RPC systems, gRPC is based on the idea of defi...
Latex download and install and use tutorial 1. Introduction (1) About LaTeX and CTeX Two TexLive2018 + WinEdt10.3 installation (1) Basic installation (B) Introduction (3) Complete entry resources: 1. ...
Table of contents 1. What is the docker? Second, CentOS Docker installation (CentOS7 and above) 1.Docker installation 2. Docker start and stop 2. Docker uninstall (RM -RF carefully) 3. Docker mirror o...
The first chapter recommends 2 hours of study. The course has 10 chapters. Learning style: read in detail and manually implement the relevant code learning targetThis tutorial will teach you to...
First, what is docker 1, Docker's role and principle Docker container technology can imagine a software industry container, which can quickly pack different applications or a different version of the ...
reference:Liao Xuefeng Tutorial 1 Introduction Git is a distributed version control system. Key isdistributedwithversion control。 Distributed and centralized contrast Each time you need to connect to ...
1. Redux contains the following parts containing applications state: The real data source of the driver application view: UI declaration description based on the current state actions: Depending on th...
Table of contents I. Overview 2. Route_guide.proto file 3. Generate code (slightly) Fourth, code detailed explanation 4-1 service side code 4-2 tool class 4-3 client and running results display 4-3-1 ...