Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

gRPC: An Example

A gRPC example with a Go server and Python client that exhibits the 3 (of the 4) kinds of service methods.

Prerequisites

Server

Install the protocol compiler plugins for Go:

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

Client

Install required python libraries:

pip install -r client/requirements.txt

Generate files

Generate Go and Python files from .proto service definition.

# Server (Go) files
protoc --go_out=server --go_opt=paths=source_relative --go-grpc_out=server --go-grpc_opt=paths=source_relative model/todo.proto
# Client (Python) files
python -m grpc_tools.protoc -I model --python_out=client --pyi_out=client --grpc_python_out=client model/todo.proto

Usage

Server

Start server with:

cd server
go mod tidy
go run . -port=8080

Client

In a different terminal window, run client with:

cd client
python client.py

References