This lib resolves Consul services by name.
Somewhere in your init
code:
import (
"github.com/ekomobile/grpc-consul-resolver"
)
// Will query consul every 5 seconds.
resolver.RegisterDefault(time.Second * 5)
Getting connection:
conn, err := grpc.DialContext(ctx, "srv://consul/my-awesome-service")
With round-robin balancer:
import (
"google.golang.org/grpc/balancer/roundrobin"
)
conn, err := grpc.DialContext(ctx, "srv://consul/my-awesome-service", grpc.WithBalancerName(roundrobin.Name))