GRPC Basic Implementation

What is Remote Procedure Call

In your CLIENT code, It looks like you’re just calling a function directly on SERVER

For example golang client call cpp functions

Protocol Buffers.

Protocol buffers are Google’s language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler. You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages.

brew install protobuf

GRPC install

brew install grpc

Make microservice Definition

.proto3 Files set definitions of microservice

https://developers.google.com/protocol-buffers/docs/proto3

Generate Code

Generate GRPC service code

./go_generate.sh

Build microservice in Golang

go get google.golang.org/grpc
go install google.golang.org/protobuf/cmd/[email protected]
go install google.golang.org/grpc/cmd/[email protected]

Update

export PATH="$PATH:$(go env GOPATH)/bin"

Grpc microservice need Server and Client.

Build server and Client

Build

go build -o server_exec server/server.go
go build -o client_exec client/client.go

Run

./server_exec
./client_exec

GitHub

View Github