Skip to content

An example to implement gRPC bidirectional streaming calls using Go and Protobuf

Notifications You must be signed in to change notification settings

pallasite99/gRPC-bidirectional-streaming-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gRPC-bidirectional-streaming-go

(tested on Linux-Ubuntu 16.04 Xenial Xerus)

go-gRPC bidirectional streaming

  • An example to implement gRPC bidirectional streaming calls using Go and Protobuf

Requirements

  1. protoc (v3.x and above)
  2. go (v1.16)
  3. git
  4. protoc plugin for go
  5. go implementation of gRPC (using go get command)
  6. Some additional go get commands may be required if Makefile can't resolve them.

(You can install these manually [very painful] or use the req-gRPC.sh file provided for Ubuntu 16.04)

If you want to generate proto headers for Go manually

  • cd into the proto directory and enter in terminal:
protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative users.proto

Generating a go.mod file

  • Enter in terminal:
go mod init <link-to-github-repo>
  • This file is required else you will get a package is not part of a module error

To resolve conflicts with go modules like version:latest, upgrade, etc...

  • Enter in terminal:
go mod tidy
  • This formats the go.mod file

To build this example

  • Enter in terminal
make all
  • This command will generate proto headers, client and server executables

Running the example

  1. First start the server with the command:
./ser
  1. Then start the client using the command:
./cli
  • As the output you will see a stream of messages with requests on server and corresponding responses on the client side as a gRPC bidirectional stream.

About

An example to implement gRPC bidirectional streaming calls using Go and Protobuf

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published