Skip to content

Latest commit

 

History

History
44 lines (29 loc) · 987 Bytes

File metadata and controls

44 lines (29 loc) · 987 Bytes

08-greet-bi-directional-streaming-golang

Implements a bi-directional streaming RPC using Golang.

Installing the protocol compiler plugins for Go

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

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

Generating source files from .proto definition

$ protoc --go_out=. --go_opt=paths=source_relative \
    --go-grpc_out=. --go-grpc_opt=paths=source_relative \
    --go-grpc_opt=require_unimplemented_servers=false \
    greetpb/greet.proto

Starting Server

$ go run server/server.go

Running Client

$ go run client/client.go

Output:

Starting client streaming...
Sending req: greeting:{first_name:"John"  last_name:"Days"}
Received: Hello John

Sending req: greeting:{first_name:"Bob"  last_name:"Bar"}
Received: Hello Bob

Sending req: greeting:{first_name:"Alice"  last_name:"Ger"}
Received: Hello Alice