From 955dc2a23d1d806cdf68164b245b921c69521602 Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Fri, 23 Aug 2019 14:11:53 +0100 Subject: [PATCH] change where we order the routes --- proxy/mucp/mucp.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/proxy/mucp/mucp.go b/proxy/mucp/mucp.go index b7e380a5..ec95f407 100644 --- a/proxy/mucp/mucp.go +++ b/proxy/mucp/mucp.go @@ -110,6 +110,10 @@ func (p *Proxy) getRoute(service string) ([]router.Route, error) { for _, v := range r { routes = append(routes, v) } + + // sort the routes in order of metric + sort.Slice(routes, func(i, j int) bool { return routes[i].Metric < routes[j].Metric }) + return routes } @@ -253,9 +257,6 @@ func (p *Proxy) ServeRequest(ctx context.Context, req server.Request, rsp server return p.serveRequest(ctx, p.Client, service, endpoint, req, rsp, client.WithAddress(addresses...)) } - // sort the routes in order of metric - sort.Slice(routes, func(i, j int) bool { return routes[i].Metric < routes[j].Metric }) - // there's no links e.g we're local routing then just serve it with addresses if local { var opts []client.CallOption