The etcd client provides a gRPC resolver for resolving gRPC endpoints with an etcd backend. The resolver is initialized with an etcd client and given a target for resolution:
Managing service endpoints
New endpoints can be added to the service through etcdctl
:
ETCDCTL_API=3 etcdctl put my-service/1.2.3.4 '{"Addr":"1.2.3.4","Metadata":"..."}'
Hosts can be deleted from the service through etcdctl
:
Registering an endpoint with a lease ensures that if the host can’t maintain a keepalive heartbeat (e.g., its machine fails), it will be removed from the service:
lease=`ETCDCTL_API=3 etcdctl lease grant 5 | cut -f2 -d' '`