diff --git a/server.go b/server.go index cdd98e2..78b8b4d 100644 --- a/server.go +++ b/server.go @@ -8,6 +8,7 @@ import ( "github.com/mholt/caddy/caddyhttp/httpserver" "github.com/pieterlouw/caddy-grpc/proxy" "google.golang.org/grpc" + "google.golang.org/grpc/balancer/roundrobin" "google.golang.org/grpc/credentials" "google.golang.org/grpc/metadata" @@ -25,8 +26,10 @@ type server struct { // ServeHTTP satisfies the httpserver.Handler interface. func (s server) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { //dial Backend - opt := []grpc.DialOption{} - opt = append(opt, grpc.WithCodec(proxy.Codec())) + opt := []grpc.DialOption{ + grpc.WithBalancerName(roundrobin.Name), + grpc.WithCodec(proxy.Codec()), + } if s.backendIsInsecure { opt = append(opt, grpc.WithInsecure()) } else {