Skip to content

Latest commit

 

History

History

06-greet-client-streaming-golang

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

06-greet-client-streaming-golang

Implements a client-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"}
Sending req: greeting:{first_name:"Bob"  last_name:"Bar"}
Sending req: greeting:{first_name:"Alice"  last_name:"Ger"}
Response: Hello John
Hello Bob
Hello Alice