sort routes by metric
This commit is contained in:
parent
bb7fe21c46
commit
3011bad518
@ -2,6 +2,7 @@ package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sort"
|
||||
|
||||
"github.com/micro/go-micro/v3/errors"
|
||||
"github.com/micro/go-micro/v3/router"
|
||||
@ -34,6 +35,11 @@ func LookupRoute(ctx context.Context, req Request, opts CallOptions) ([]string,
|
||||
return nil, errors.InternalServerError("go.micro.client", "error getting next %s node: %s", req.Service(), err.Error())
|
||||
}
|
||||
|
||||
// sort by lowest metric first
|
||||
sort.Slice(routes, func(i, j int) bool {
|
||||
return routes[i].Metric < routes[j].Metric
|
||||
})
|
||||
|
||||
var addrs []string
|
||||
|
||||
for _, route := range routes {
|
||||
|
Loading…
x
Reference in New Issue
Block a user