Skip to content

Small demonstration of working with grpc in golang

Notifications You must be signed in to change notification settings

Rchanger/Go-gRPC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go-gRPC

This is simple demonstration of how grpc is to be used with golang.

Setting up the environment required for grpc.

  1. Download and install protoc form below link:
https://github.com/protocolbuffers/protobuf/releases
  1. Next, install Go support for Google’s protocol buffers and grpc:
go get -u github.com/golang/protobuf/protoc-gen-go
go install github.com/golang/protobuf/protoc-gen-go
go get google.golang.org/grpc

Running Demo examples.

  1. Unary gRPC is explained with example of addition and subtraction example.You will find the example inside SimpleGRPC directory. For simple/unary grpc sample.pb.go file is generated by executing following command:
protoc -I SimpleGRPC/ProtoDir/ ./SimpleGRPC/ProtoDir/sample.proto --go_out=plugins=grpc:SimpleGRPC/ProtoDir/ 
  1. Server Side Streaming type of grpc is explained with the help of small example of finding Divisors of number.It is present under ServerSideStreaming directory. For server side streaming grpc serverStreamingProto.pb.go file is generated by executing following command:
protoc -I ServerSideStreaming/ServerSideStreamingProto/ ./ServerSideStreaming/ServerSideStreamingProto/serverStreamingProto.proto --go_out=plugins=grpc:ServerSideStreaming/ServerSideStreamingProto/
  1. Client Side Streaming type of grpc is explained with the help of small example of finding max number from stream of number.The example is present under ClientSideStramingGRPC directory. For client side streaming grpc clientstraming.pb.go file is generated by executing following command:
protoc -I ClientSideStramingGRPC/ClientSideStramingProto/ ./ClientSideStramingGRPC/ClientSideStramingProto/clientstraming.proto --go_out=plugins=grpc:ClientSideStramingGRPC/ClientSideStramingProto/ 
  1. Bidirectional Streaming type of grpc is explained with the help of small example of finding max number from stream of number.The example is present under BiDirectionGRPC directory. For bidirectional streaming grpc bidirctionalProto.pb.go file is generated by executing following command:
protoc -I BiDirectionGRPC/BiDirProto/  ./BiDirectionGRPC/BiDirProto/bidirctionalProto.proto --go_out=plugins=grpc:BiDirectionGRPC/BiDirProto/

About

Small demonstration of working with grpc in golang

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages