This is an example of two python microservices communicating with each other via gRPC using Consul as service registry.
- Service registration
- gRPC health checking
- HTTP or DNS service names resolution
- Python 2.7+ or 3.4+
- Python packages:
grpcio
,grpcio-tools
,dnspython
,requests
,grpcio-health-checking
,flask
- Consul binary (https://www.consul.io/downloads.html)
- Compile protobuf services definitions:
python -m grpc_tools.protoc --proto_path=. --python_out=. --grpc_python_out=. todolist.proto
- Run Consul binary:
consul agent -dev -enable-script-checks -config-dir=./consul.d
- Run calculator service:
python todolist_service.py
- Run calculator client:
python web_server.py [--resolver {dns,http,grpc-dns}]
- Access
http://localhost:50052
from your browser and have fun! - Monitor services from Consul UI running at
http://localhost:8500