diff --git a/api/router/registry_test.go b/api/router/registry_test.go index c196b73..995471d 100644 --- a/api/router/registry_test.go +++ b/api/router/registry_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/unistack-org/micro/v3/registry" + "github.com/unistack-org/micro/v3/register" ) func TestStoreRegex(t *testing.T) { @@ -15,11 +15,11 @@ func TestStoreRegex(t *testing.T) { if err != nil { t.Fatal(err) } - router.store([]*registry.Service{ + router.store([]*register.Service{ { Name: "Foobar", Version: "latest", - Endpoints: []*registry.Endpoint{ + Endpoints: []*register.Endpoint{ { Name: "foo", Metadata: map[string]string{ diff --git a/api/router/router_test.go b/api/router/router_test.go index e2ec1a2..9e61e30 100644 --- a/api/router/router_test.go +++ b/api/router/router_test.go @@ -12,14 +12,14 @@ import ( "time" rpc "github.com/unistack-org/micro-api-handler-rpc/v3" - rregistry "github.com/unistack-org/micro-api-router-registry/v3" + rregister "github.com/unistack-org/micro-api-router-register/v3" rstatic "github.com/unistack-org/micro-api-router-static/v3" bmemory "github.com/unistack-org/micro-broker-memory/v3" gcli "github.com/unistack-org/micro-client-grpc/v3" jsoncodec "github.com/unistack-org/micro-codec-json/v3" protocodec "github.com/unistack-org/micro-codec-proto/v3" - rmemory "github.com/unistack-org/micro-registry-memory/v3" - regRouter "github.com/unistack-org/micro-router-registry/v3" + rmemory "github.com/unistack-org/micro-register-memory/v3" + regRouter "github.com/unistack-org/micro-router-register/v3" gsrv "github.com/unistack-org/micro-server-grpc/v3" pb "github.com/unistack-org/micro-tests/server/grpc/proto" "github.com/unistack-org/micro/v3/api" @@ -48,12 +48,12 @@ func (s *testServer) Call(ctx context.Context, req *pb.Request, rsp *pb.Response func initial(t *testing.T) (server.Server, client.Client) { //logger.DefaultLogger = logger.NewLogger(logger.WithLevel(logger.TraceLevel)) - r := rmemory.NewRegistry() + r := rmemory.NewRegister() if err := r.Init(); err != nil { t.Fatal(err) } - b := bmemory.NewBroker(broker.Registry(r)) + b := bmemory.NewBroker(broker.Register(r)) if err := b.Init(); err != nil { t.Fatal(err) } @@ -65,12 +65,12 @@ func initial(t *testing.T) (server.Server, client.Client) { server.Codec("application/json", jsoncodec.NewCodec()), server.Name("foo"), server.Broker(b), - server.Registry(r), + server.Register(r), server.RegisterInterval(1*time.Second), ) rtr := regRouter.NewRouter( - rt.Registry(r), + rt.Register(r), ) if err := rtr.Init(); err != nil { @@ -82,7 +82,7 @@ func initial(t *testing.T) (server.Server, client.Client) { client.Codec("application/grpc+proto", protocodec.NewCodec()), client.Codec("application/grpc+json", protocodec.NewCodec()), client.Codec("application/json", jsoncodec.NewCodec()), - client.Registry(r), + client.Register(r), client.Router(rtr), client.Broker(b), ) @@ -134,9 +134,9 @@ func TestApiTimeout(t *testing.T) { s, c := initial(t) defer s.Stop() - router := rregistry.NewRouter( + router := rregister.NewRouter( router.WithHandler(rpc.Handler), - router.WithRegistry(s.Options().Registry), + router.WithRegister(s.Options().Register), ) if err := router.Init(); err != nil { t.Fatal(err) @@ -164,13 +164,13 @@ func TestApiTimeout(t *testing.T) { check(t, hsrv.Addr, "http://%s/api/v0/test/call/TEST", `{"Id":"go.micro.client","Code":408,"Detail":"context deadline exceeded","Status":"Request Timeout"}`, true) } -func TestRouterRegistryPcre(t *testing.T) { +func TestRouterRegisterPcre(t *testing.T) { s, c := initial(t) defer s.Stop() - router := rregistry.NewRouter( + router := rregister.NewRouter( router.WithHandler(rpc.Handler), - router.WithRegistry(s.Options().Registry), + router.WithRegister(s.Options().Register), ) if err := router.Init(); err != nil { t.Fatal(err) @@ -204,7 +204,7 @@ func TestRouterStaticPcre(t *testing.T) { router := rstatic.NewRouter( router.WithHandler(rpc.Handler), - router.WithRegistry(s.Options().Registry), + router.WithRegister(s.Options().Register), ) if err := router.Init(); err != nil { t.Fatal(err) @@ -248,7 +248,7 @@ func TestRouterStaticGpath(t *testing.T) { router := rstatic.NewRouter( router.WithHandler(rpc.Handler), - router.WithRegistry(s.Options().Registry), + router.WithRegister(s.Options().Register), ) err := router.Register(&api.Endpoint{ @@ -292,7 +292,7 @@ func TestRouterStaticPcreInvalid(t *testing.T) { router := rstatic.NewRouter( router.WithHandler(rpc.Handler), - router.WithRegistry(s.Options().Registry), + router.WithRegister(s.Options().Register), ) ep = &api.Endpoint{ diff --git a/broker/http/http_test.go b/broker/http/http_test.go index d3cc26c..7a0e4a6 100644 --- a/broker/http/http_test.go +++ b/broker/http/http_test.go @@ -9,19 +9,19 @@ import ( "github.com/google/uuid" http "github.com/unistack-org/micro-broker-http/v3" jsoncodec "github.com/unistack-org/micro-codec-json/v3" - rmemory "github.com/unistack-org/micro-registry-memory/v3" + rmemory "github.com/unistack-org/micro-register-memory/v3" "github.com/unistack-org/micro/v3/broker" - "github.com/unistack-org/micro/v3/registry" + "github.com/unistack-org/micro/v3/register" ) var ( // mock data - testData = map[string][]*registry.Service{ + testData = map[string][]*register.Service{ "foo": { { Name: "foo", Version: "1.0.0", - Nodes: []*registry.Node{ + Nodes: []*register.Node{ { Id: "foo-1.0.0-123", Address: "localhost:9999", @@ -35,7 +35,7 @@ var ( { Name: "foo", Version: "1.0.1", - Nodes: []*registry.Node{ + Nodes: []*register.Node{ { Id: "foo-1.0.1-321", Address: "localhost:6666", @@ -45,7 +45,7 @@ var ( { Name: "foo", Version: "1.0.3", - Nodes: []*registry.Node{ + Nodes: []*register.Node{ { Id: "foo-1.0.3-345", Address: "localhost:8888", @@ -56,15 +56,15 @@ var ( } ) -func newTestRegistry() registry.Registry { - return rmemory.NewRegistry() +func newTestRegister() register.Register { + return rmemory.NewRegister() } func sub(be *testing.B, c int) { be.StopTimer() - m := newTestRegistry() + m := newTestRegister() - b := http.NewBroker(broker.Codec(jsoncodec.NewCodec()), broker.Registry(m)) + b := http.NewBroker(broker.Codec(jsoncodec.NewCodec()), broker.Register(m)) topic := uuid.New().String() if err := b.Init(); err != nil { @@ -122,8 +122,8 @@ func sub(be *testing.B, c int) { func pub(be *testing.B, c int) { be.StopTimer() - m := newTestRegistry() - b := http.NewBroker(broker.Codec(jsoncodec.NewCodec()), broker.Registry(m)) + m := newTestRegister() + b := http.NewBroker(broker.Codec(jsoncodec.NewCodec()), broker.Register(m)) topic := uuid.New().String() if err := b.Init(); err != nil { @@ -191,8 +191,8 @@ func pub(be *testing.B, c int) { } func TestBroker(t *testing.T) { - m := newTestRegistry() - b := http.NewBroker(broker.Codec(jsoncodec.NewCodec()), broker.Registry(m)) + m := newTestRegister() + b := http.NewBroker(broker.Codec(jsoncodec.NewCodec()), broker.Register(m)) if err := b.Init(); err != nil { t.Fatalf("Unexpected init error: %v", err) @@ -238,8 +238,8 @@ func TestBroker(t *testing.T) { } func TestConcurrentSubBroker(t *testing.T) { - m := newTestRegistry() - b := http.NewBroker(broker.Codec(jsoncodec.NewCodec()), broker.Registry(m)) + m := newTestRegister() + b := http.NewBroker(broker.Codec(jsoncodec.NewCodec()), broker.Register(m)) if err := b.Init(); err != nil { t.Fatalf("Unexpected init error: %v", err) @@ -295,8 +295,8 @@ func TestConcurrentSubBroker(t *testing.T) { } func TestConcurrentPubBroker(t *testing.T) { - m := newTestRegistry() - b := http.NewBroker(broker.Codec(jsoncodec.NewCodec()), broker.Registry(m)) + m := newTestRegister() + b := http.NewBroker(broker.Codec(jsoncodec.NewCodec()), broker.Register(m)) if err := b.Init(); err != nil { t.Fatalf("Unexpected init error: %v", err) diff --git a/client/client_call_options_test.go b/client/client_call_options_test.go index 1d8f844..8d0de8f 100644 --- a/client/client_call_options_test.go +++ b/client/client_call_options_test.go @@ -11,9 +11,9 @@ import ( "github.com/unistack-org/micro/v3/client" "github.com/unistack-org/micro/v3/client/grpc" tmemory "github.com/unistack-org/micro/v3/network/transport/memory" - rmemory "github.com/unistack-org/micro/v3/registry/memory" + rmemory "github.com/unistack-org/micro/v3/register/memory" "github.com/unistack-org/micro/v3/router" - rtreg "github.com/unistack-org/micro/v3/router/registry" + rtreg "github.com/unistack-org/micro/v3/router/register" "github.com/unistack-org/micro/v3/server" grpcsrv "github.com/unistack-org/micro/v3/server/grpc" cw "github.com/unistack-org/micro/v3/util/client" @@ -44,14 +44,14 @@ func TestStaticClient(t *testing.T) { ) rsp := &TestRsp{} - reg := rmemory.NewRegistry() - brk := bmemory.NewBroker(broker.Registry(reg)) + reg := rmemory.NewRegister() + brk := bmemory.NewBroker(broker.Register(reg)) tr := tmemory.NewTransport() - rtr := rtreg.NewRouter(router.Registry(reg)) + rtr := rtreg.NewRouter(router.Register(reg)) srv := grpcsrv.NewServer( server.Broker(brk), - server.Registry(reg), + server.Register(reg), server.Name("go.micro.service.foo"), server.Address("127.0.0.1:0"), server.Transport(tr), diff --git a/client/grpc/grpc_test.go b/client/grpc/grpc_test.go index 0943ae0..c6dde61 100644 --- a/client/grpc/grpc_test.go +++ b/client/grpc/grpc_test.go @@ -10,12 +10,12 @@ import ( grpc "github.com/unistack-org/micro-client-grpc/v3" protocodec "github.com/unistack-org/micro-codec-proto/v3" - rmemory "github.com/unistack-org/micro-registry-memory/v3" - regRouter "github.com/unistack-org/micro-router-registry/v3" + rmemory "github.com/unistack-org/micro-register-memory/v3" + regRouter "github.com/unistack-org/micro-router-register/v3" pb "github.com/unistack-org/micro-tests/client/grpc/proto" "github.com/unistack-org/micro/v3/client" "github.com/unistack-org/micro/v3/errors" - "github.com/unistack-org/micro/v3/registry" + "github.com/unistack-org/micro/v3/register" "github.com/unistack-org/micro/v3/router" pgrpc "google.golang.org/grpc" "google.golang.org/grpc/codes" @@ -71,14 +71,14 @@ func TestGRPCClient(t *testing.T) { }() defer s.Stop() - // create mock registry - r := rmemory.NewRegistry() + // create mock register + r := rmemory.NewRegister() // register service - if err := r.Register(ctx, ®istry.Service{ + if err := r.Register(ctx, ®ister.Service{ Name: "helloworld", Version: "test", - Nodes: []*registry.Node{ + Nodes: []*register.Node{ { Id: "test-1", Address: l.Addr().String(), @@ -92,7 +92,7 @@ func TestGRPCClient(t *testing.T) { } // create router - rtr := regRouter.NewRouter(router.Registry(r)) + rtr := regRouter.NewRouter(router.Register(r)) // create client c := grpc.NewClient(client.Codec("application/grpc+proto", protocodec.NewCodec()), client.Router(rtr)) diff --git a/client/http/http_test.go b/client/http/http_test.go index 6bcb3a3..8718d00 100644 --- a/client/http/http_test.go +++ b/client/http/http_test.go @@ -13,12 +13,12 @@ import ( mhttp "github.com/unistack-org/micro-client-http/v3" jsoncodec "github.com/unistack-org/micro-codec-json/v3" - rmemory "github.com/unistack-org/micro-registry-memory/v3" - rrouter "github.com/unistack-org/micro-router-registry/v3" + rmemory "github.com/unistack-org/micro-register-memory/v3" + rrouter "github.com/unistack-org/micro-router-register/v3" pb "github.com/unistack-org/micro-tests/client/http/proto" "github.com/unistack-org/micro/v3/client" "github.com/unistack-org/micro/v3/codec" - "github.com/unistack-org/micro/v3/registry" + "github.com/unistack-org/micro/v3/register" "github.com/unistack-org/micro/v3/router" ) @@ -77,8 +77,8 @@ func TestNative(t *testing.T) { } func TestHTTPClient(t *testing.T) { - reg := rmemory.NewRegistry() - rtr := rrouter.NewRouter(router.Registry(reg)) + reg := rmemory.NewRegister() + rtr := rrouter.NewRouter(router.Register(reg)) ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -129,9 +129,9 @@ func TestHTTPClient(t *testing.T) { }) go http.Serve(l, mux) - if err := reg.Register(ctx, ®istry.Service{ + if err := reg.Register(ctx, ®ister.Service{ Name: "test.service", - Nodes: []*registry.Node{ + Nodes: []*register.Node{ { Id: "test.service.1", Address: l.Addr().String(), @@ -164,8 +164,8 @@ func TestHTTPClient(t *testing.T) { } func TestHTTPClientStream(t *testing.T) { - reg := rmemory.NewRegistry() - rtr := rrouter.NewRouter(router.Registry(reg)) + reg := rmemory.NewRegister() + rtr := rrouter.NewRouter(router.Register(reg)) ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -291,9 +291,9 @@ func TestHTTPClientStream(t *testing.T) { }) go http.Serve(l, mux) - if err := reg.Register(ctx, ®istry.Service{ + if err := reg.Register(ctx, ®ister.Service{ Name: "test.service", - Nodes: []*registry.Node{ + Nodes: []*register.Node{ { Id: "test.service.1", Address: l.Addr().String(), diff --git a/codec/segmentio/grpc_test.go b/codec/segmentio/grpc_test.go index 9b8f899..5745ed5 100644 --- a/codec/segmentio/grpc_test.go +++ b/codec/segmentio/grpc_test.go @@ -9,8 +9,8 @@ import ( // protocodec "github.com/unistack-org/micro-codec-proto/v3" protocodec "github.com/unistack-org/micro-codec-segmentio/v3/proto" - rmemory "github.com/unistack-org/micro-registry-memory/v3" - regRouter "github.com/unistack-org/micro-router-registry/v3" + rmemory "github.com/unistack-org/micro-register-memory/v3" + regRouter "github.com/unistack-org/micro-router-register/v3" gserver "github.com/unistack-org/micro-server-grpc/v3" pb "github.com/unistack-org/micro-tests/server/grpc/proto" "github.com/unistack-org/micro/v3/broker" @@ -35,11 +35,11 @@ func (g *testServer) Call(ctx context.Context, req *pb.Request, rsp *pb.Response func TestGRPCServer(t *testing.T) { var err error - r := rmemory.NewRegistry() - b := bmemory.NewBroker(broker.Registry(r)) - s := gserver.NewServer(server.Codec("application/grpc+proto", protocodec.NewCodec()), server.Address(":12345"), server.Registry(r), server.Name("helloworld"), gserver.Reflection(true)) + r := rmemory.NewRegister() + b := bmemory.NewBroker(broker.Register(r)) + s := gserver.NewServer(server.Codec("application/grpc+proto", protocodec.NewCodec()), server.Address(":12345"), server.Register(r), server.Name("helloworld"), gserver.Reflection(true)) // create router - rtr := regRouter.NewRouter(router.Registry(r)) + rtr := regRouter.NewRouter(router.Register(r)) h := &testServer{} err = pb.RegisterTestHandler(s, h) @@ -62,7 +62,7 @@ func TestGRPCServer(t *testing.T) { }() // create client - c := gclient.NewClient(client.Codec("application/grpc+proto", protocodec.NewCodec()), client.Router(rtr), client.Registry(r), client.Broker(b)) + c := gclient.NewClient(client.Codec("application/grpc+proto", protocodec.NewCodec()), client.Router(rtr), client.Register(r), client.Broker(b)) testMethods := []string{ "Test.Call", diff --git a/go.mod b/go.mod index 14ad5c5..64b8e9f 100644 --- a/go.mod +++ b/go.mod @@ -4,33 +4,33 @@ go 1.15 require ( github.com/golang/protobuf v1.4.3 - github.com/google/uuid v1.1.5 + github.com/google/uuid v1.2.0 github.com/grpc-ecosystem/grpc-gateway/v2 v2.1.0 github.com/opentracing/opentracing-go v1.2.0 github.com/prometheus/client_golang v1.9.0 github.com/prometheus/client_model v0.2.0 github.com/stretchr/testify v1.7.0 github.com/unistack-org/micro-api-handler-rpc/v3 v3.1.1 - github.com/unistack-org/micro-api-router-registry/v3 v3.1.1 - github.com/unistack-org/micro-api-router-static/v3 v3.1.1 - github.com/unistack-org/micro-broker-http/v3 v3.1.1 - github.com/unistack-org/micro-broker-memory/v3 v3.1.1 - github.com/unistack-org/micro-client-grpc/v3 v3.1.1 - github.com/unistack-org/micro-client-http/v3 v3.1.2 + github.com/unistack-org/micro-api-router-register/v3 v3.2.2 + github.com/unistack-org/micro-api-router-static/v3 v3.2.1 + github.com/unistack-org/micro-broker-http/v3 v3.2.2 + github.com/unistack-org/micro-broker-memory/v3 v3.2.3 + github.com/unistack-org/micro-client-grpc/v3 v3.2.3 + github.com/unistack-org/micro-client-http/v3 v3.2.2 github.com/unistack-org/micro-codec-grpc/v3 v3.1.1 github.com/unistack-org/micro-codec-json/v3 v3.1.1 github.com/unistack-org/micro-codec-proto/v3 v3.1.1 github.com/unistack-org/micro-codec-segmentio/v3 v3.1.1 - github.com/unistack-org/micro-config-env/v3 v3.1.3 - github.com/unistack-org/micro-config-vault/v3 v3.1.2 + github.com/unistack-org/micro-config-env/v3 v3.2.4 + github.com/unistack-org/micro-config-vault/v3 v3.2.4 github.com/unistack-org/micro-metrics-prometheus/v3 v3.1.1 - github.com/unistack-org/micro-registry-memory/v3 v3.1.1 - github.com/unistack-org/micro-router-registry/v3 v3.1.1 - github.com/unistack-org/micro-server-grpc/v3 v3.1.1 - github.com/unistack-org/micro-server-http/v3 v3.1.1 - github.com/unistack-org/micro-server-tcp/v3 v3.1.1 + github.com/unistack-org/micro-register-memory/v3 v3.2.2 + github.com/unistack-org/micro-router-register/v3 v3.2.2 + github.com/unistack-org/micro-server-grpc/v3 v3.2.2 + github.com/unistack-org/micro-server-http/v3 v3.2.0 + github.com/unistack-org/micro-server-tcp/v3 v3.2.2 github.com/unistack-org/micro-wrapper-trace-opentracing/v3 v3.1.1 - github.com/unistack-org/micro/v3 v3.1.2 + github.com/unistack-org/micro/v3 v3.2.4 google.golang.org/genproto v0.0.0-20210114201628-6edceaf6022f google.golang.org/grpc v1.35.0 google.golang.org/protobuf v1.25.0 diff --git a/go.sum b/go.sum index 0d69615..36f29b7 100644 --- a/go.sum +++ b/go.sum @@ -119,6 +119,7 @@ github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1 github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/ef-ds/deque v1.0.4-0.20190904040645-54cb57c252a1/go.mod h1:HvODWzv6Y6kBf3Ah2WzN1bHjDUezGLaAhwuWVwfpEJs= +github.com/ef-ds/deque v1.0.4/go.mod h1:gXDnTC3yqvBcHbq2lcExjtAcVrOnJCbMcZXmuj8Z4tg= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -228,6 +229,8 @@ github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.5 h1:kxhtnfFVi+rYdOALN0B3k9UT86zVJKfBimRaciULW4I= github.com/google/uuid v1.1.5/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs= +github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gophercloud/gophercloud v0.3.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8= @@ -348,6 +351,7 @@ github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3N github.com/miekg/dns v1.1.15/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.31 h1:sJFOl9BgwbYAWOGEwr61FU28pqsBNdpRBnhGXtO06Oo= github.com/miekg/dns v1.1.31/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= +github.com/miekg/dns v1.1.35/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= @@ -512,18 +516,18 @@ github.com/transip/gotransip v0.0.0-20190812104329-6d8d9179b66f/go.mod h1:i0f4R4 github.com/uber-go/atomic v1.3.2/go.mod h1:/Ct5t2lcmbJ4OSe/waGBoaVvVqtO0bmtfVNex1PFV8g= github.com/unistack-org/micro-api-handler-rpc/v3 v3.1.1 h1:0DjMFKXM19OQCTMnANRzvsML+0tnGaTon6OO6LIlmPM= github.com/unistack-org/micro-api-handler-rpc/v3 v3.1.1/go.mod h1:m1oT1yVC3ZiunltSdvoDTz/P7Azk7GfO6HwK3j3Mq9U= -github.com/unistack-org/micro-api-router-registry/v3 v3.1.1 h1:SY4SkqjbvQwssEu0RFiP3EWhiBZpNF/FOxL+ojp8dqE= -github.com/unistack-org/micro-api-router-registry/v3 v3.1.1/go.mod h1:KeX7LUe2LMJ/XlcdhZ2dLXk0g6bzpDVbDAh9kSLXJQE= -github.com/unistack-org/micro-api-router-static/v3 v3.1.1 h1:nqkcPnxdixiBkhru1z/SOIqyZA4Ryul/S6PLxAgLWqU= -github.com/unistack-org/micro-api-router-static/v3 v3.1.1/go.mod h1:cvo1UvdrbqdSws/kjUr++usBJMwRBGpzPfHh6bn0OnY= -github.com/unistack-org/micro-broker-http/v3 v3.1.1 h1:KgUVELTqpeAx6npIFBjJlu9villRisINMxnrkwrmu/c= -github.com/unistack-org/micro-broker-http/v3 v3.1.1/go.mod h1:/UyMkAo13sPsoKNGqLqhPeZwHIY8StDPqDNBnIkJMzg= -github.com/unistack-org/micro-broker-memory/v3 v3.1.1 h1:cDBIh/dVxuh2EnzuRyUVCswoBL4hLIC6MevoRxqxst0= -github.com/unistack-org/micro-broker-memory/v3 v3.1.1/go.mod h1:lSFmkUtAlfsizywNOT+nNfpXeagM5+8tFDda3qFSPwY= -github.com/unistack-org/micro-client-grpc/v3 v3.1.1 h1:z0ic1qK3nRIPi30UQQTGJJReSA9K+Q33e8znYTcgtN4= -github.com/unistack-org/micro-client-grpc/v3 v3.1.1/go.mod h1:mJ72LTougMlZ1jTRr0jS38JfK2MRo08ew4V8fpQFZMo= -github.com/unistack-org/micro-client-http/v3 v3.1.2 h1:Ipvgub65nNuX5iSb7Ehy0AZu92v6Xxz9iwMOs9YIOUI= -github.com/unistack-org/micro-client-http/v3 v3.1.2/go.mod h1:7tddLMx5wijKxjK3p1ikhzxKlBubBZ3vlPgPPhS0edc= +github.com/unistack-org/micro-api-router-register/v3 v3.2.2 h1:O8tIP+NFqyp/3F8vYnDMTati4etc2URxUSUH1VrEqOY= +github.com/unistack-org/micro-api-router-register/v3 v3.2.2/go.mod h1:MZeqvmekQB/avrTRajp86+s7GuHkQ8HAee+hZtY+dWw= +github.com/unistack-org/micro-api-router-static/v3 v3.2.1 h1:FMcEb8NYYX72OyQuMKHbtdEQV+eOFbmKyvwSY8cgan8= +github.com/unistack-org/micro-api-router-static/v3 v3.2.1/go.mod h1:vP8VMZrJtlimEQOgYnLJsjnaUMeULNMPBkHEK5DA7G0= +github.com/unistack-org/micro-broker-http/v3 v3.2.2 h1:5Xs1YBZcD1MU9cPPUOsjqz3ZnNLP+vuzTLtrx6jKYSc= +github.com/unistack-org/micro-broker-http/v3 v3.2.2/go.mod h1:G7I9ub3rrorYzxlVjvlfp9HvNt6hqFFfHwdEAiSEe9I= +github.com/unistack-org/micro-broker-memory/v3 v3.2.3 h1:01l0GqY8eG6Ln3E6VZ5GA9EYYh/fIl4OFYuFlvdNxkE= +github.com/unistack-org/micro-broker-memory/v3 v3.2.3/go.mod h1:63X6CabOKmRyxxwEVrDdzFDPOfvzkL+g5SNXft1YWDo= +github.com/unistack-org/micro-client-grpc/v3 v3.2.3 h1:0X+PeAZuDYziROwRSuw7mVWsqzSEN8mVO1SSaWM/jNw= +github.com/unistack-org/micro-client-grpc/v3 v3.2.3/go.mod h1:HcQuzli6tMTVrl7wHAqpyBZw5M4lUV0tk2WQFgyQ4LU= +github.com/unistack-org/micro-client-http/v3 v3.2.2 h1:9Fl/pJvMwsVgWaHPNOBRYGga/hBMFsjSek2g6L2/h28= +github.com/unistack-org/micro-client-http/v3 v3.2.2/go.mod h1:wlIrq+He9oPPG/NSr5kax/O47TS6RMaoI12xfWkNjNU= github.com/unistack-org/micro-codec-grpc/v3 v3.1.1 h1:h+x6ny1UeMEqZWPx7vhkfczetnFh00lbCxdLl9Rr0EU= github.com/unistack-org/micro-codec-grpc/v3 v3.1.1/go.mod h1:2iY/1jF+gnRGwZZBz7PU9pN7DIERWh5mnz2xwQtwm1M= github.com/unistack-org/micro-codec-json/v3 v3.1.1 h1:1iILAzvT7XP7Dxae9yfZJwId0nVA9GZc3Ez+n2iF3tc= @@ -532,28 +536,34 @@ github.com/unistack-org/micro-codec-proto/v3 v3.1.1 h1:97BVfeWjEL9nBCqGPWAYjxbSF github.com/unistack-org/micro-codec-proto/v3 v3.1.1/go.mod h1:c93m6EHNaDgnrOeFuzJRwYA4z/HCgit66It4XRR2DY8= github.com/unistack-org/micro-codec-segmentio/v3 v3.1.1 h1:WFVNcXNm58bEOKnubTztBu3zG8COiGN1giLSgA1Ju78= github.com/unistack-org/micro-codec-segmentio/v3 v3.1.1/go.mod h1:FSrl+q83cohF2N7CmIdi36D6bZsjfGKMhhw0WaozlLs= -github.com/unistack-org/micro-config-env/v3 v3.1.3 h1:fwtu4hsXKjb8OAWQEpM4DGl8wxUfIEvhMT8MPtyzjTk= -github.com/unistack-org/micro-config-env/v3 v3.1.3/go.mod h1:RCh5RoB0KomH2PtIUdyN1zYisfSNUAU1yaCj9ptxmVs= -github.com/unistack-org/micro-config-vault/v3 v3.1.2 h1:P7nPmrQPKlJ3JkRfIWtUUjYaopZcloeycimvg2IaEC8= -github.com/unistack-org/micro-config-vault/v3 v3.1.2/go.mod h1:BV3+AkFBi6FT4y+0awsc7zoxUiOQ4FEhL2UVBAoWT+o= +github.com/unistack-org/micro-config-env/v3 v3.2.4 h1:mMle6VvwmhabvohRxGfNxhcOeVUenLq2mR1goXpLJys= +github.com/unistack-org/micro-config-env/v3 v3.2.4/go.mod h1:NzhRyDsCgNzRhEtuVathSToOIzmkHCEICiSNZsVN75U= +github.com/unistack-org/micro-config-vault/v3 v3.2.4 h1:HUOsVbQoki8YdISUVk3jzTgKYVJSxkLsjGG2Hcu8rhk= +github.com/unistack-org/micro-config-vault/v3 v3.2.4/go.mod h1:Xbj5R5psic0Dyuh7SrJqvFv0hSIHYKHx91p96rn/lxk= github.com/unistack-org/micro-metrics-prometheus/v3 v3.1.1 h1:AZVQ8l1p1pIUyImQo/if/5t1g9C9du9ulMRqATSmgGo= github.com/unistack-org/micro-metrics-prometheus/v3 v3.1.1/go.mod h1:QfquVeYZ2+BqBQ5bv1+uFAeWFiacvwanRDy3nGVqo3c= -github.com/unistack-org/micro-registry-memory/v3 v3.1.1 h1:M5E7pCE6cunr5Fs7RJLHtt5CuAhvqf2iCxpLab9ek8E= -github.com/unistack-org/micro-registry-memory/v3 v3.1.1/go.mod h1:Yh7SP24IRmW+pfhqU8JR1UaCz774FTd+egbTFZuL9zo= -github.com/unistack-org/micro-router-registry/v3 v3.1.1 h1:D/bFqZ5bDTV6uiqUQF4hvaSVNI+FtVkasBjLxo9VxUY= -github.com/unistack-org/micro-router-registry/v3 v3.1.1/go.mod h1:MTQ1JiANp2d+lzplis+hdcRh65fiUyOvHA2YHSmCnko= -github.com/unistack-org/micro-server-grpc/v3 v3.1.1 h1:jnf5FwpKZcx3duXJTyhqwCcwG4s31bVj5DRjQ5m84Q8= -github.com/unistack-org/micro-server-grpc/v3 v3.1.1/go.mod h1:00TihKvniOHnVks7r4IfTF9j75IVm97yq9OorsLuOtA= -github.com/unistack-org/micro-server-http/v3 v3.1.1 h1:sth/o5flT2HBWaWTV295uYu2i0YigSlYK23IXMsRxaw= -github.com/unistack-org/micro-server-http/v3 v3.1.1/go.mod h1:j5qfSIVO1VCFXu+Ck48zBy9Jfo3L/7rqiBSoR1z4ljU= -github.com/unistack-org/micro-server-tcp/v3 v3.1.1 h1:c0nIaIylJ/ObO+S4UeK2+Z6Eo66HldXC7EFLQQdMQTs= -github.com/unistack-org/micro-server-tcp/v3 v3.1.1/go.mod h1:sbLEMdJm0eyN5zA1uwm0Rmiq241u5NcT60DUZzHFdiA= +github.com/unistack-org/micro-register-memory/v3 v3.2.2 h1:u323kc4OWpx7FXtBf/V7Phib3NWVbDydpp8kViQX4cA= +github.com/unistack-org/micro-register-memory/v3 v3.2.2/go.mod h1:utfCoMCsr5xxFI8TH5e5uKK3RlI3Co+SzfVeAWFDfRE= +github.com/unistack-org/micro-router-register/v3 v3.2.2 h1:lYCymDHkJfhZWYQ4+Sb7Fu+NlqoysQCnpJytHGhdnws= +github.com/unistack-org/micro-router-register/v3 v3.2.2/go.mod h1:Y9Qtlg4NHqq5rR6X6Jm+04LoSJMi7/OOCm2mRueZYTE= +github.com/unistack-org/micro-server-grpc/v3 v3.2.2 h1:LfjFdl5jYYGY2SgCEH2qObvlNZ6ENC4HSa36uvI/sx4= +github.com/unistack-org/micro-server-grpc/v3 v3.2.2/go.mod h1:459FWPnuW56+gmI3R9ZbWsGEc/+nR70c3YyaI1nRwN8= +github.com/unistack-org/micro-server-http/v3 v3.2.0 h1:0gnriS8tykOT2vFDbNNWwr2RV02xmq+6xwW/7C+0+8Y= +github.com/unistack-org/micro-server-http/v3 v3.2.0/go.mod h1:JPmmEayerP3Zf7RQtHOjKjA5+EUynWV6yvpg0ftPFww= +github.com/unistack-org/micro-server-tcp/v3 v3.2.2 h1:2/Xn+4+dnzY/tpD3MgLO1wg3ect9Jx5CLSDfPBjdjT4= +github.com/unistack-org/micro-server-tcp/v3 v3.2.2/go.mod h1:TQDIck2+RdEAGIRnwv+2a0OVBUTkL6OM7YUY4AjFFmY= github.com/unistack-org/micro-wrapper-trace-opentracing/v3 v3.1.1 h1:sEnPLn3BGt/t+ITsMJ8zHwtDUV9Qty3NIadOa099uHk= github.com/unistack-org/micro-wrapper-trace-opentracing/v3 v3.1.1/go.mod h1:iY0hsj7ul6sT4Zt2xkclVFpKHG4MZ9k1sllLv01P8vM= 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/unistack-org/micro/v3 v3.1.2 h1:NZnO6uhdRmoW/IhbWT1HWRCNWwgKbLlX4XikNx1cMzI= -github.com/unistack-org/micro/v3 v3.1.2/go.mod h1:0DgOy4OdJxQCDER8YSKitZugd2+1bddrRSNfeooTHDc= +github.com/unistack-org/micro/v3 v3.2.0/go.mod h1:J8XxJj4Pqa3Ee0a4biRRtut7UwTlfBq8QRe+s4PKGS0= +github.com/unistack-org/micro/v3 v3.2.1/go.mod h1:J8XxJj4Pqa3Ee0a4biRRtut7UwTlfBq8QRe+s4PKGS0= +github.com/unistack-org/micro/v3 v3.2.2 h1:wli8jSMheABvEdU2tCdqeBEH4HlOCSmPxizud8DklNo= +github.com/unistack-org/micro/v3 v3.2.2/go.mod h1:J8XxJj4Pqa3Ee0a4biRRtut7UwTlfBq8QRe+s4PKGS0= +github.com/unistack-org/micro/v3 v3.2.3 h1:gzEQwXBp3aoGDKgNJOiMp5sSadBOK81IhR9FCet3PcA= +github.com/unistack-org/micro/v3 v3.2.3/go.mod h1:J8XxJj4Pqa3Ee0a4biRRtut7UwTlfBq8QRe+s4PKGS0= +github.com/unistack-org/micro/v3 v3.2.4 h1:V/QrzeSI/Bjd0j7uL8Lvvbbz8ky/0yj69srd1lE1RLI= +github.com/unistack-org/micro/v3 v3.2.4/go.mod h1:J8XxJj4Pqa3Ee0a4biRRtut7UwTlfBq8QRe+s4PKGS0= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/vultr/govultr v0.1.4/go.mod h1:9H008Uxr/C4vFNGLqKx232C206GL0PBHzOP0809bGNA= @@ -595,6 +605,8 @@ golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a h1:vclmkQCjlDX5OydZ9wv8rBCcS0QyQY66Mpf/7BZbInM= golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad h1:DN0cp81fZ3njFcrLCytUHRSUkqBjfTo4Tx9RJTWs0EY= +golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -708,6 +720,7 @@ golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -731,6 +744,7 @@ golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e h1:AyodaIpKjppX+cBfTASF2E1US3H2JFBj920Ot3rtDjs= golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/metric/victoriametrics/victoriametrics_test.go b/metric/victoriametrics/victoriametrics_test.go new file mode 100644 index 0000000..50f6517 --- /dev/null +++ b/metric/victoriametrics/victoriametrics_test.go @@ -0,0 +1,159 @@ +// +build ignore + +package victoriametrics + +import ( + "bufio" + "bytes" + "context" + "fmt" + "io" + "strings" + "testing" + + metrics "github.com/VictoriaMetrics/metrics" + "github.com/stretchr/testify/assert" + bmemory "github.com/unistack-org/micro-broker-memory/v3" + gclient "github.com/unistack-org/micro-client-grpc/v3" + memory "github.com/unistack-org/micro-register-memory/v3" + rrouter "github.com/unistack-org/micro-router-register/v3" + gserver "github.com/unistack-org/micro-server-grpc/v3" + "github.com/unistack-org/micro/v3/broker" + "github.com/unistack-org/micro/v3/client" + "github.com/unistack-org/micro/v3/router" + "github.com/unistack-org/micro/v3/server" +) + +type Test interface { + Method(ctx context.Context, in *TestRequest, opts ...client.CallOption) (*TestResponse, error) +} + +type TestRequest struct { + IsError bool +} +type TestResponse struct{} + +type testHandler struct{} + +func (t *testHandler) Method(ctx context.Context, req *TestRequest, rsp *TestResponse) error { + if req.IsError { + return fmt.Errorf("test error") + } + return nil +} + +func TestVictoriametrics(t *testing.T) { + // setup + r := memory.NewRegister() + b := bmemory.NewBroker(broker.Register(r)) + + name := "test" + id := "id-1234567890" + version := "1.2.3.4" + + c := gclient.NewClient( + client.Router(rrouter.NewRouter(router.Register(r))), + client.Broker(b), + ) + s := gserver.NewServer( + server.Broker(b), + server.Name(name), + server.Version(version), + server.Id(id), + server.Register(r), + server.WrapHandler( + NewHandlerWrapper( + ServiceName(name), + ServiceVersion(version), + ServiceID(id), + ), + ), + ) + if err := s.Init(); err != nil { + t.Fatal(err) + } + defer s.Stop() + + type Test struct { + *testHandler + } + + s.Handle( + s.NewHandler(&Test{new(testHandler)}), + ) + + if err := s.Start(); err != nil { + t.Fatalf("Unexpected error starting server: %v", err) + } + + req := c.NewRequest(name, "Test.Method", &TestRequest{IsError: false}, client.WithContentType("application/json")) + rsp := TestResponse{} + + assert.NoError(t, c.Call(context.TODO(), req, &rsp)) + + req = c.NewRequest(name, "Test.Method", &TestRequest{IsError: true}, client.WithContentType("application/json")) + assert.Error(t, c.Call(context.TODO(), req, &rsp)) + + buf := bytes.NewBuffer(nil) + metrics.WritePrometheus(buf, false) + + metric, err := findMetricByName(buf, "sum", "micro_server_request_total") + if err != nil { + t.Fatal(err) + } + + labels := metric[0]["labels"].(map[string]string) + for k, v := range labels { + switch k { + case "micro_version": + assert.Equal(t, version, v) + case "micro_id": + assert.Equal(t, id, v) + case "micro_name": + assert.Equal(t, name, v) + case "micro_endpoint": + assert.Equal(t, "Test.Method", v) + case "micro_status": + continue + default: + t.Fatalf("unknown %v with %v", k, v) + } + } +} + +func findMetricByName(buf io.Reader, tp string, name string) ([]map[string]interface{}, error) { + var metrics []map[string]interface{} + scanner := bufio.NewScanner(buf) + for scanner.Scan() { + txt := scanner.Text() + if strings.HasPrefix(txt, name) { + mt := make(map[string]interface{}) + v := txt[strings.LastIndex(txt, " "):] + k := "" + if idx := strings.Index(txt, "{"); idx > 0 { + labels := make(map[string]string) + lb := strings.Split(txt[idx+1:strings.Index(txt, "}")], ",") + for _, l := range lb { + p := strings.Split(l, "=") + labels[strings.Trim(p[0], `"`)] = strings.Trim(p[1], `"`) + } + mt["labels"] = labels + k = txt[:idx] + } else { + k = txt[:strings.Index(txt, " ")] + } + mt["name"] = k + mt["value"] = v + metrics = append(metrics, mt) + } + } + + if err := scanner.Err(); err != nil { + return nil, err + } + + if len(metrics) == 0 { + return nil, fmt.Errorf("%s %s not found", tp, name) + } + return metrics, nil +} diff --git a/server/grpc/grpc_test.go b/server/grpc/grpc_test.go index c3371af..f2a5405 100644 --- a/server/grpc/grpc_test.go +++ b/server/grpc/grpc_test.go @@ -7,8 +7,8 @@ import ( bmemory "github.com/unistack-org/micro-broker-memory/v3" gclient "github.com/unistack-org/micro-client-grpc/v3" protocodec "github.com/unistack-org/micro-codec-proto/v3" - rmemory "github.com/unistack-org/micro-registry-memory/v3" - regRouter "github.com/unistack-org/micro-router-registry/v3" + rmemory "github.com/unistack-org/micro-register-memory/v3" + regRouter "github.com/unistack-org/micro-router-register/v3" gserver "github.com/unistack-org/micro-server-grpc/v3" pb "github.com/unistack-org/micro-tests/server/grpc/proto" "github.com/unistack-org/micro/v3/broker" @@ -36,11 +36,11 @@ func (g *testServer) Call(ctx context.Context, req *pb.Request, rsp *pb.Response func TestGRPCServer(t *testing.T) { var err error - r := rmemory.NewRegistry() - b := bmemory.NewBroker(broker.Registry(r)) - s := gserver.NewServer(server.Codec("application/grpc+proto", protocodec.NewCodec()), server.Address(":12345"), server.Registry(r), server.Name("helloworld"), gserver.Reflection(true)) + r := rmemory.NewRegister() + b := bmemory.NewBroker(broker.Register(r)) + s := gserver.NewServer(server.Codec("application/grpc+proto", protocodec.NewCodec()), server.Address(":12345"), server.Register(r), server.Name("helloworld"), gserver.Reflection(true)) // create router - rtr := regRouter.NewRouter(router.Registry(r)) + rtr := regRouter.NewRouter(router.Register(r)) h := &testServer{} err = pb.RegisterTestHandler(s, h) @@ -63,7 +63,7 @@ func TestGRPCServer(t *testing.T) { }() // create client - c := gclient.NewClient(client.Codec("application/grpc+proto", protocodec.NewCodec()), client.Router(rtr), client.Registry(r), client.Broker(b)) + c := gclient.NewClient(client.Codec("application/grpc+proto", protocodec.NewCodec()), client.Router(rtr), client.Register(r), client.Broker(b)) testMethods := []string{ "Test.Call", diff --git a/server/grpc/proto/helloworld_micro.pb.go b/server/grpc/proto/test_micro.pb.go similarity index 100% rename from server/grpc/proto/helloworld_micro.pb.go rename to server/grpc/proto/test_micro.pb.go diff --git a/server/grpc/proto/helloworld_micro_grpc.pb.go b/server/grpc/proto/test_micro_grpc.pb.go similarity index 100% rename from server/grpc/proto/helloworld_micro_grpc.pb.go rename to server/grpc/proto/test_micro_grpc.pb.go diff --git a/server/http/http_test.go b/server/http/http_test.go index 190423c..6872a6a 100644 --- a/server/http/http_test.go +++ b/server/http/http_test.go @@ -7,17 +7,17 @@ import ( "net/http" "testing" - memory "github.com/unistack-org/micro-registry-memory/v3" + memory "github.com/unistack-org/micro-register-memory/v3" httpsrv "github.com/unistack-org/micro-server-http/v3" "github.com/unistack-org/micro/v3/server" ) func TestHTTPServer(t *testing.T) { - reg := memory.NewRegistry() + reg := memory.NewRegister() ctx := context.Background() // create server - srv := httpsrv.NewServer(server.Registry(reg)) + srv := httpsrv.NewServer(server.Register(reg)) // create server mux mux := http.NewServeMux() @@ -39,7 +39,7 @@ func TestHTTPServer(t *testing.T) { } // lookup server - service, err := reg.GetService(ctx, server.DefaultName) + service, err := reg.LookupService(ctx, server.DefaultName) if err != nil { t.Fatal(err) } diff --git a/server/tcp/tcp_test.go b/server/tcp/tcp_test.go index 2bfc890..ff4468d 100644 --- a/server/tcp/tcp_test.go +++ b/server/tcp/tcp_test.go @@ -9,7 +9,7 @@ import ( "time" bmemory "github.com/unistack-org/micro-broker-memory/v3" - rmemory "github.com/unistack-org/micro-registry-memory/v3" + rmemory "github.com/unistack-org/micro-register-memory/v3" tcp "github.com/unistack-org/micro-server-tcp/v3" "github.com/unistack-org/micro/v3/broker" "github.com/unistack-org/micro/v3/logger" @@ -24,17 +24,17 @@ func TestTCPServer(t *testing.T) { ctx := context.Background() logger.DefaultLogger = logger.NewLogger(logger.WithLevel(logger.TraceLevel)) - reg := rmemory.NewRegistry() + reg := rmemory.NewRegister() if err := reg.Init(); err != nil { t.Fatal(err) } - brk := bmemory.NewBroker(broker.Registry(reg)) + brk := bmemory.NewBroker(broker.Register(reg)) if err := brk.Init(); err != nil { t.Fatal(err) } // create server - srv := tcp.NewServer(server.Registry(reg), server.Broker(brk), server.Address("127.0.0.1:65000")) + srv := tcp.NewServer(server.Register(reg), server.Broker(brk), server.Address("127.0.0.1:65000")) // create handler h := &testHandler{done: make(chan struct{})} @@ -54,7 +54,7 @@ func TestTCPServer(t *testing.T) { } // lookup server - service, err := reg.GetService(ctx, server.DefaultName) + service, err := reg.LookupService(ctx, server.DefaultName) if err != nil { t.Fatal(err) } diff --git a/wrapper/breaker/gobreaker/gobreaker_test.go b/wrapper/breaker/gobreaker/gobreaker_test.go index 22d10c8..5e9d689 100644 --- a/wrapper/breaker/gobreaker/gobreaker_test.go +++ b/wrapper/breaker/gobreaker/gobreaker_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/sony/gobreaker" - "github.com/unistack-org/micro/registry/memory" + "github.com/unistack-org/micro/register/memory" "github.com/unistack-org/micro/v3/client" "github.com/unistack-org/micro/v3/errors" "github.com/unistack-org/micro/v3/router" @@ -15,11 +15,11 @@ import ( func TestBreaker(t *testing.T) { // setup - r := memory.NewRegistry() + r := memory.NewRegister() c := client.NewClient( // set the selector - client.Router(rrouter.NewRouter(router.Registry(registry))), + client.Router(rrouter.NewRouter(router.Register(register))), // add the breaker wrapper client.Wrap(NewClientWrapper()), ) @@ -48,11 +48,11 @@ func TestBreaker(t *testing.T) { func TestCustomBreaker(t *testing.T) { // setup - r := memory.NewRegistry() + r := memory.NewRegister() c := client.NewClient( // set the selector - client.Router(rrouter.NewRouter(router.Registry(registry))), + client.Router(rrouter.NewRouter(router.Register(register))), // add the breaker wrapper client.Wrap(NewCustomClientWrapper( gobreaker.Settings{}, diff --git a/wrapper/breaker/hystrix/hystrix_test.go b/wrapper/breaker/hystrix/hystrix_test.go index aa9bae8..c68c79a 100644 --- a/wrapper/breaker/hystrix/hystrix_test.go +++ b/wrapper/breaker/hystrix/hystrix_test.go @@ -7,19 +7,19 @@ import ( "testing" "github.com/afex/hystrix-go/hystrix" - rrouter "github.com/unistack-org/micro-router-registry/v3" - "github.com/unistack-org/micro/registry/memory" + rrouter "github.com/unistack-org/micro-router-register/v3" + "github.com/unistack-org/micro/register/memory" "github.com/unistack-org/micro/v3/client" "github.com/unistack-org/micro/v3/router" ) func TestBreaker(t *testing.T) { // setup - registry := memory.NewRegistry() + register := memory.NewRegister() c := client.NewClient( // set the selector - client.Router(rrouter.NewRouter(router.Registry(registry))), + client.Router(rrouter.NewRouter(router.Register(register))), // add the breaker wrapper client.Wrap(NewClientWrapper()), ) diff --git a/wrapper/metrics/prometheus/prometheus_test.go b/wrapper/metrics/prometheus/prometheus_test.go index 18613b9..5d9e46c 100644 --- a/wrapper/metrics/prometheus/prometheus_test.go +++ b/wrapper/metrics/prometheus/prometheus_test.go @@ -12,8 +12,8 @@ import ( cli "github.com/unistack-org/micro-client-grpc/v3" jsoncodec "github.com/unistack-org/micro-codec-json/v3" promwrapper "github.com/unistack-org/micro-metrics-prometheus/v3" - rmemory "github.com/unistack-org/micro-registry-memory/v3" - rrouter "github.com/unistack-org/micro-router-registry/v3" + rmemory "github.com/unistack-org/micro-register-memory/v3" + rrouter "github.com/unistack-org/micro-router-register/v3" srv "github.com/unistack-org/micro-server-grpc/v3" "github.com/unistack-org/micro/v3/broker" "github.com/unistack-org/micro/v3/client" @@ -42,13 +42,13 @@ func (t *testHandler) Method(ctx context.Context, req *TestRequest, rsp *TestRes func TestPrometheusMetrics(t *testing.T) { client.DefaultRetries = 0 // setup - reg := rmemory.NewRegistry() - brk := bmemory.NewBroker(broker.Registry(reg)) + reg := rmemory.NewRegister() + brk := bmemory.NewBroker(broker.Register(reg)) name := "test" id := "id-1234567890" version := "1.2.3.4" - rt := rrouter.NewRouter(router.Registry(reg)) + rt := rrouter.NewRouter(router.Register(reg)) c := cli.NewClient( client.Codec("application/grpc+json", jsoncodec.NewCodec()), @@ -61,7 +61,7 @@ func TestPrometheusMetrics(t *testing.T) { server.Name(name), server.Version(version), server.Id(id), - server.Registry(reg), + server.Register(reg), server.Broker(brk), server.WrapHandler( promwrapper.NewHandlerWrapper( diff --git a/wrapper/ratelimiter/juju/ratelimit_test.go b/wrapper/ratelimiter/juju/ratelimit_test.go index 8c51a89..80af35f 100644 --- a/wrapper/ratelimiter/juju/ratelimit_test.go +++ b/wrapper/ratelimiter/juju/ratelimit_test.go @@ -11,8 +11,8 @@ import ( "github.com/juju/ratelimit" bmemory "github.com/unistack-org/micro-broker-memory/v3" tmemory "github.com/unistack-org/micro-network-transport-memory" - rmemory "github.com/unistack-org/micro-registry-memory/v3" - rrouter "github.com/unistack-org/micro-router-registry/v3" + rmemory "github.com/unistack-org/micro-register-memory/v3" + rrouter "github.com/unistack-org/micro-router-register/v3" "github.com/unistack-org/micro/v3/client" "github.com/unistack-org/micro/v3/errors" "github.com/unistack-org/micro/v3/router" @@ -29,7 +29,7 @@ func (t *testHandler) Method(ctx context.Context, req *TestRequest, rsp *TestRes func TestRateClientLimit(t *testing.T) { // setup - r := rmemory.NewRegistry() + r := rmemory.NewRegister() tr := tmemory.NewTransport() testRates := []int{1, 10, 20} @@ -37,7 +37,7 @@ func TestRateClientLimit(t *testing.T) { b := ratelimit.NewBucketWithRate(float64(limit), int64(limit)) c := client.NewClient( - client.Router(rrouter.NewRouter(router.Registry(registry))), + client.Router(rrouter.NewRouter(router.Register(register))), client.Transport(tr), // add the breaker wrapper client.Wrap(NewClientWrapper(b, false)), @@ -72,22 +72,22 @@ func TestRateServerLimit(t *testing.T) { testRates := []int{1, 5, 6, 10} for _, limit := range testRates { - r := rmemory.NewRegistry() + r := rmemory.NewRegister() b := bmemory.NewBroker() tr := tmemory.NewTransport() _ = b br := ratelimit.NewBucketWithRate(float64(limit), int64(limit)) c := client.NewClient( - client.Router(rrouter.NewRouter(router.Registry(registry))), + client.Router(rrouter.NewRouter(router.Register(register))), client.Transport(tr)) name := fmt.Sprintf("test.service.%d", limit) srv := server.NewServer( server.Name(name), - // add registry - server.Registry(r), + // add register + server.Register(r), server.Transport(tr), // add broker //server.Broker(b), diff --git a/wrapper/trace/datadog/datadog_test.go b/wrapper/trace/datadog/datadog_test.go index e338aeb..4195b8b 100644 --- a/wrapper/trace/datadog/datadog_test.go +++ b/wrapper/trace/datadog/datadog_test.go @@ -8,8 +8,8 @@ import ( "testing" "github.com/stretchr/testify/assert" - rrouter "github.com/unistack-org/micro-router-registry/v3" - "github.com/unistack-org/micro/registry/memory" + rrouter "github.com/unistack-org/micro-router-register/v3" + "github.com/unistack-org/micro/register/memory" "github.com/unistack-org/micro/v3/client" microerr "github.com/unistack-org/micro/v3/errors" "github.com/unistack-org/micro/v3/router" @@ -71,14 +71,14 @@ func TestClient(t *testing.T) { mt := mocktracer.Start() defer mt.Stop() - registry := memory.NewRegistry() + register := memory.NewRegister() serverName := "micro.server.name" serverID := "id-1234567890" serverVersion := "1.0.0" c := cli.NewClient( - client.Router(rrouter.NewRouter(router.Registry(registry))), + client.Router(rrouter.NewRouter(router.Register(register))), client.WrapCall(NewCallWrapper()), ) @@ -86,7 +86,7 @@ func TestClient(t *testing.T) { server.Name(serverName), server.Version(serverVersion), server.Id(serverID), - server.Registry(registry), + server.Register(register), server.WrapSubscriber(NewSubscriberWrapper()), server.WrapHandler(NewHandlerWrapper()), ) @@ -151,14 +151,14 @@ func TestRace(t *testing.T) { mt := mocktracer.Start() defer mt.Stop() - registry := memory.NewRegistry() + register := memory.NewRegister() serverName := "micro.server.name" serverID := "id-1234567890" serverVersion := "1.0.0" c := cli.NewClient( - client.Router(rrouter.NewRouter(router.Registry(registry))), + client.Router(rrouter.NewRouter(router.Register(register))), client.WrapCall(NewCallWrapper()), ) @@ -166,7 +166,7 @@ func TestRace(t *testing.T) { server.Name(serverName), server.Version(serverVersion), server.Id(serverID), - server.Registry(registry), + server.Register(register), server.WrapSubscriber(NewSubscriberWrapper()), server.WrapHandler(NewHandlerWrapper()), ) diff --git a/wrapper/trace/opentracing/opentracing_test.go b/wrapper/trace/opentracing/opentracing_test.go index c6a156b..e401ecd 100644 --- a/wrapper/trace/opentracing/opentracing_test.go +++ b/wrapper/trace/opentracing/opentracing_test.go @@ -11,8 +11,8 @@ import ( rbroker "github.com/unistack-org/micro-broker-memory/v3" cli "github.com/unistack-org/micro-client-grpc/v3" jsoncodec "github.com/unistack-org/micro-codec-json/v3" - rmemory "github.com/unistack-org/micro-registry-memory/v3" - rrouter "github.com/unistack-org/micro-router-registry/v3" + rmemory "github.com/unistack-org/micro-register-memory/v3" + rrouter "github.com/unistack-org/micro-router-register/v3" srv "github.com/unistack-org/micro-server-grpc/v3" otwrapper "github.com/unistack-org/micro-wrapper-trace-opentracing/v3" "github.com/unistack-org/micro/v3/broker" @@ -70,14 +70,14 @@ func TestClient(t *testing.T) { t.Run(name, func(t *testing.T) { tracer := mocktracer.New() - reg := rmemory.NewRegistry() - brk := rbroker.NewBroker(broker.Registry(reg)) + reg := rmemory.NewRegister() + brk := rbroker.NewBroker(broker.Register(reg)) serverName := "micro.server.name" serverID := "id-1234567890" serverVersion := "1.0.0" - rt := rrouter.NewRouter(router.Registry(reg)) + rt := rrouter.NewRouter(router.Register(reg)) c := cli.NewClient( client.Codec("application/grpc+json", jsoncodec.NewCodec()), @@ -92,7 +92,7 @@ func TestClient(t *testing.T) { server.Name(serverName), server.Version(serverVersion), server.Id(serverID), - server.Registry(reg), + server.Register(reg), server.Broker(brk), server.WrapSubscriber(otwrapper.NewServerSubscriberWrapper(otwrapper.WithTracer(tracer))), server.WrapHandler(otwrapper.NewServerHandlerWrapper(otwrapper.WithTracer(tracer))),