From 637dcb5cc1250878e2e5966e49fb5867d0467090 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sat, 16 Jan 2021 01:24:38 +0300 Subject: [PATCH] update micro to v3.1.1 Signed-off-by: Vasiliy Tolstov --- go.mod | 4 ++-- go.sum | 4 ++-- registry.go | 32 ++++++++++++++++---------------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/go.mod b/go.mod index c950f06..277d958 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,5 @@ -module github.com/unistack-org/micro-api-router-registry +module github.com/unistack-org/micro-api-router-registry/v3 go 1.15 -require github.com/unistack-org/micro/v3 v3.0.2-0.20210109225421-8930c3fbb748 +require github.com/unistack-org/micro/v3 v3.1.1 diff --git a/go.sum b/go.sum index 64ee2ae..3820621 100644 --- a/go.sum +++ b/go.sum @@ -221,8 +221,8 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/timewasted/linode v0.0.0-20160829202747-37e84520dcf7/go.mod h1:imsgLplxEC/etjIhdr3dNzV3JeT27LbVu5pYWm0JCBY= github.com/transip/gotransip v0.0.0-20190812104329-6d8d9179b66f/go.mod h1:i0f4R4o2HM0m3DZYQWsj6/MEowD57VzoH0v3d7igeFY= github.com/uber-go/atomic v1.3.2/go.mod h1:/Ct5t2lcmbJ4OSe/waGBoaVvVqtO0bmtfVNex1PFV8g= -github.com/unistack-org/micro/v3 v3.0.2-0.20210109225421-8930c3fbb748 h1:tPXIO1QFi2DxPv8nsSACNKsydmToqHZ4x0xIZMvX9es= -github.com/unistack-org/micro/v3 v3.0.2-0.20210109225421-8930c3fbb748/go.mod h1:0DgOy4OdJxQCDER8YSKitZugd2+1bddrRSNfeooTHDc= +github.com/unistack-org/micro/v3 v3.1.1 h1:kWL0BVzUBdotjfDbl1qL9lNYmZqvebQWPNCyqrjUSAk= +github.com/unistack-org/micro/v3 v3.1.1/go.mod h1:0DgOy4OdJxQCDER8YSKitZugd2+1bddrRSNfeooTHDc= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/vultr/govultr v0.1.4/go.mod h1:9H008Uxr/C4vFNGLqKx232C206GL0PBHzOP0809bGNA= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= diff --git a/registry.go b/registry.go index a2a4d42..c0375f7 100644 --- a/registry.go +++ b/registry.go @@ -54,7 +54,7 @@ func (r *registryRouter) refresh() { if err != nil { attempts++ if logger.V(logger.ErrorLevel) { - logger.Errorf("unable to list services: %v", err) + logger.Errorf(r.opts.Context, "unable to list services: %v", err) } time.Sleep(time.Duration(attempts) * time.Second) continue @@ -67,7 +67,7 @@ func (r *registryRouter) refresh() { service, err := r.opts.Registry.GetService(r.opts.Context, s.Name) if err != nil { if logger.V(logger.ErrorLevel) { - logger.Errorf("unable to get service: %v", err) + logger.Errorf(r.opts.Context, "unable to get service: %v", err) } continue } @@ -95,7 +95,7 @@ func (r *registryRouter) process(res *registry.Result) { service, err := r.opts.Registry.GetService(r.opts.Context, res.Service.Name) if err != nil { if logger.V(logger.ErrorLevel) { - logger.Errorf("unable to get %v service: %v", res.Service.Name, err) + logger.Errorf(r.opts.Context, "unable to get %v service: %v", res.Service.Name, err) } return } @@ -130,7 +130,7 @@ func (r *registryRouter) store(services []*registry.Service) { // if we got nothing skip if err := api.Validate(end); err != nil { if logger.V(logger.TraceLevel) { - logger.Tracef("endpoint validation failed: %v", err) + logger.Tracef(r.opts.Context, "endpoint validation failed: %v", err) } continue } @@ -177,7 +177,7 @@ func (r *registryRouter) store(services []*registry.Service) { hostreg, err := regexp.CompilePOSIX(h) if err != nil { if logger.V(logger.TraceLevel) { - logger.Tracef("endpoint have invalid host regexp: %v", err) + logger.Tracef(r.opts.Context, "endpoint have invalid host regexp: %v", err) } continue } @@ -198,7 +198,7 @@ func (r *registryRouter) store(services []*registry.Service) { rule, err := util.Parse(p) if err != nil && !pcreok { if logger.V(logger.TraceLevel) { - logger.Tracef("endpoint have invalid path pattern: %v", err) + logger.Tracef(r.opts.Context, "endpoint have invalid path pattern: %v", err) } continue } else if err != nil && pcreok { @@ -209,7 +209,7 @@ func (r *registryRouter) store(services []*registry.Service) { pathreg, err := util.NewPattern(tpl.Version, tpl.OpCodes, tpl.Pool, "") if err != nil { if logger.V(logger.TraceLevel) { - logger.Tracef("endpoint have invalid path pattern: %v", err) + logger.Tracef(r.opts.Context, "endpoint have invalid path pattern: %v", err) } continue } @@ -234,7 +234,7 @@ func (r *registryRouter) watch() { if err != nil { attempts++ if logger.V(logger.ErrorLevel) { - logger.Errorf("error watching endpoints: %v", err) + logger.Errorf(r.opts.Context, "error watching endpoints: %v", err) } time.Sleep(time.Duration(attempts) * time.Second) continue @@ -259,7 +259,7 @@ func (r *registryRouter) watch() { res, err := w.Next() if err != nil { if logger.V(logger.ErrorLevel) { - logger.Errorf("error getting next endpoint: %v", err) + logger.Errorf(r.opts.Context, "error getting next endpoint: %v", err) } close(ch) break @@ -325,7 +325,7 @@ func (r *registryRouter) Endpoint(req *http.Request) (*api.Service, error) { continue } if logger.V(logger.TraceLevel) { - logger.Tracef("api method match %s", req.Method) + logger.Tracef(r.opts.Context, "api method match %s", req.Method) } // 2. try host @@ -348,7 +348,7 @@ func (r *registryRouter) Endpoint(req *http.Request) (*api.Service, error) { continue } if logger.V(logger.TraceLevel) { - logger.Tracef("api host match %s", req.URL.Host) + logger.Tracef(r.opts.Context, "api host match %s", req.URL.Host) } // 3. try path via google.api path matching @@ -356,18 +356,18 @@ func (r *registryRouter) Endpoint(req *http.Request) (*api.Service, error) { matches, err := pathreg.Match(path, "") if err != nil { if logger.V(logger.TraceLevel) { - logger.Tracef("api gpath not match %s != %v", path, pathreg) + logger.Tracef(r.opts.Context, "api gpath not match %s != %v", path, pathreg) } continue } if logger.V(logger.TraceLevel) { - logger.Tracef("api gpath match %s = %v", path, pathreg) + logger.Tracef(r.opts.Context, "api gpath match %s = %v", path, pathreg) } pMatch = true ctx := req.Context() md, ok := metadata.FromContext(ctx) if !ok { - md = make(metadata.Metadata) + md = metadata.New(len(matches) + 1) } for k, v := range matches { md[fmt.Sprintf("x-api-field-%s", k)] = v @@ -382,12 +382,12 @@ func (r *registryRouter) Endpoint(req *http.Request) (*api.Service, error) { for _, pathreg := range cep.pcreregs { if !pathreg.MatchString(req.URL.Path) { if logger.V(logger.TraceLevel) { - logger.Tracef("api pcre path not match %s != %v", path, pathreg) + logger.Tracef(r.opts.Context, "api pcre path not match %s != %v", path, pathreg) } continue } if logger.V(logger.TraceLevel) { - logger.Tracef("api pcre path match %s != %v", path, pathreg) + logger.Tracef(r.opts.Context, "api pcre path match %s != %v", path, pathreg) } pMatch = true break