Service Discovery
Service Discovery
Section titled “Service Discovery”go-zero supports pluggable service discovery backends. etcd is the most common option.
Register (Server Side)
Section titled “Register (Server Side)”Name: order.rpcListenOn: 0.0.0.0:8080Etcd: Hosts: [127.0.0.1:2379] Key: order.rpcNo code changes needed — go-zero registers at startup automatically.
Discover (Client Side)
Section titled “Discover (Client Side)”OrderRpc: Etcd: Hosts: [127.0.0.1:2379] Key: order.rpcorderClient := order.NewOrderClient(zrpc.MustNewClient(c.OrderRpc).Conn())Kubernetes DNS
Section titled “Kubernetes DNS”OrderRpc: Endpoints: [order-rpc-svc.default:8080]Direct Endpoints (Dev)
Section titled “Direct Endpoints (Dev)”OrderRpc: Endpoints: [127.0.0.1:8080]Health Checks
Section titled “Health Checks”go-zero RPC servers implement the gRPC health check protocol automatically.
livenessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:8080"] initialDelaySeconds: 5