The code is an oversimplified example of how to
- Create C++ gRPC async server with multiple endpoints
- How to asynchronously call another gRPC service from the server endpoint code
First, built the gRPC library and the example in a container:
docker build -f grpc-ubuntu2004.Dockerfile --no-cache -t drepin/grpc-cpp:grpc-ubuntu2004 .
docker build -f grpc-cpp-async-server.Dockerfile --no-cache -t drepin/grpc-cpp:grpc-cpp-async-server .
Start an interactive bash session in the container
docker run -it --rm drepin/grpc-cpp:grpc-cpp-async-server
Run the pinger server and clients:
# In bash shell 1 run pinger service:
/opt/grpc-cpp-async/bin/Release/pinger_server.exe &
# In bash shell 2 connect to it with a block client:
/opt/grpc-cpp-async/bin/Release/pinger_client.exe
# In bash shell 1 run pinger service:
/opt/grpc-cpp-async/bin/Release/pinger_server.exe &
# In bash shell 2 connect to it with an async client:
/opt/grpc-cpp-async/bin/Release/pinger_client_async.exe
Run the talker server (that calls pinger) and client tests:
# In bash shell 1 run pinger service:
/opt/grpc-cpp-async/bin/Release/pinger_server.exe &
# In bash shell 2 run talker service:
/opt/grpc-cpp-async/bin/Release/talker_async_server.exe &
# In bash shell 3 connect to it with an async client:
/opt/grpc-cpp-async/bin/Release/talker_client.exe