Learning gRPC and protocol buffers based on this tutorial blog.
- python3
- virtualenv
create virtual environment directory for python
virtualenv venv
start virtualenv
source venv/bin/activate
change to app directory
cd app/
install python packages
pip install -r requirements.txt
generate gRPC class files from .proto files
python \
-m grpc_tools.protoc \
--proto_path=autogenerated=proto \
--python_out=. \
--grpc_python_out=. \
proto/*.proto
spin-up gRPC server
python server.py
docker build -t=learn-grpc-protobuf .
docker run -p 50051:50051 learn-grpc-protobuf
in another terminal, start virtualenv
source venv/bin/activate
change to app directory
cd app/
make a request to the gRPC server via the client script
python client.py
you should see this output:
result of square_root(16): 4.0
result of add(4,5): 9.0
result of say_hello(My name is Harry): Hello, your request message was: My name is Harry
spin-down python gRPC server in 1st terminal
ctrl+c
deactivate virtualenv in both terminals
deactivate