From ea29920afb9a4cbebcf16deefee75893344537ec Mon Sep 17 00:00:00 2001 From: Ben Toogood Date: Wed, 15 Apr 2020 11:31:19 +0100 Subject: [PATCH] Add Priority to auth rules --- agent/proto/bot.pb.micro.go | 8 -- api/service/proto/api.pb.micro.go | 8 -- auth/service/proto/auth.pb.go | 123 ++++++++++-------- auth/service/proto/auth.pb.micro.go | 20 --- auth/service/proto/auth.proto | 1 + auth/service/service.go | 6 + auth/service/sevice_test.go | 26 ++++ broker/service/proto/broker.pb.micro.go | 8 -- client/service/proto/client.pb.micro.go | 8 -- .../source/service/proto/service.pb.micro.go | 8 -- debug/service/proto/debug.pb.micro.go | 8 -- go.sum | 1 + network/service/proto/network.pb.micro.go | 8 -- registry/service/proto/registry.pb.micro.go | 8 -- router/service/proto/router.pb.micro.go | 14 -- runtime/service/proto/runtime.pb.micro.go | 8 -- server/grpc/proto/test.pb.micro.go | 23 ---- server/proto/server.pb.micro.go | 8 -- service/grpc/proto/test.pb.micro.go | 8 -- store/service/proto/store.pb.micro.go | 8 -- transport/grpc/proto/transport.pb.micro.go | 8 -- 21 files changed, 100 insertions(+), 218 deletions(-) create mode 100644 auth/service/sevice_test.go diff --git a/agent/proto/bot.pb.micro.go b/agent/proto/bot.pb.micro.go index 7c105aa6..60338cda 100644 --- a/agent/proto/bot.pb.micro.go +++ b/agent/proto/bot.pb.micro.go @@ -11,7 +11,6 @@ import ( import ( context "context" - api "github.com/micro/go-micro/v2/api" client "github.com/micro/go-micro/v2/client" server "github.com/micro/go-micro/v2/server" ) @@ -28,17 +27,10 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package // Reference imports to suppress errors if they are not otherwise used. -var _ api.Endpoint var _ context.Context var _ client.Option var _ server.Option -// Api Endpoints for Command service - -func NewCommandEndpoints() []*api.Endpoint { - return []*api.Endpoint{} -} - // Client API for Command service type CommandService interface { diff --git a/api/service/proto/api.pb.micro.go b/api/service/proto/api.pb.micro.go index c2bcfbc6..301b7c55 100644 --- a/api/service/proto/api.pb.micro.go +++ b/api/service/proto/api.pb.micro.go @@ -11,7 +11,6 @@ import ( import ( context "context" - api "github.com/micro/go-micro/v2/api" client "github.com/micro/go-micro/v2/client" server "github.com/micro/go-micro/v2/server" ) @@ -28,17 +27,10 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package // Reference imports to suppress errors if they are not otherwise used. -var _ api.Endpoint var _ context.Context var _ client.Option var _ server.Option -// Api Endpoints for Api service - -func NewApiEndpoints() []*api.Endpoint { - return []*api.Endpoint{} -} - // Client API for Api service type ApiService interface { diff --git a/auth/service/proto/auth.pb.go b/auth/service/proto/auth.pb.go index 0cd12014..58f5c535 100644 --- a/auth/service/proto/auth.pb.go +++ b/auth/service/proto/auth.pb.go @@ -802,6 +802,7 @@ type Rule struct { Role string `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"` Resource *Resource `protobuf:"bytes,3,opt,name=resource,proto3" json:"resource,omitempty"` Access Access `protobuf:"varint,4,opt,name=access,proto3,enum=go.micro.auth.Access" json:"access,omitempty"` + Priority int32 `protobuf:"varint,5,opt,name=priority,proto3" json:"priority,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -860,6 +861,13 @@ func (m *Rule) GetAccess() Access { return Access_UNKNOWN } +func (m *Rule) GetPriority() int32 { + if m != nil { + return m.Priority + } + return 0 +} + type CreateRequest struct { Role string `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` Resource *Resource `protobuf:"bytes,2,opt,name=resource,proto3" json:"resource,omitempty"` @@ -1133,63 +1141,64 @@ func init() { func init() { proto.RegisterFile("auth/service/proto/auth.proto", fileDescriptor_21300bfacc51fc2a) } var fileDescriptor_21300bfacc51fc2a = []byte{ - // 885 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc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x9e, 0xcd, 0xa6, - 0x23, 0x7b, 0xf2, 0x8f, 0x05, 0xad, 0x93, 0x82, 0x9f, 0x92, 0x17, 0xd0, 0x35, 0x1b, 0x89, 0xdc, - 0x7f, 0xf3, 0xe2, 0xf5, 0xdf, 0xdd, 0x6a, 0xd7, 0x78, 0x76, 0xc8, 0x73, 0xe8, 0xe8, 0xcb, 0x49, - 0x0e, 0x6a, 0xde, 0xd5, 0xcb, 0xed, 0xdf, 0xdf, 0x66, 0x2e, 0x63, 0x4d, 0xcd, 0xdb, 0xe2, 0x6e, - 0xe3, 0x65, 0xd0, 0x71, 0xee, 0x35, 0x1b, 0x4d, 0x94, 0xc9, 0xf7, 0xd0, 0x35, 0x4f, 0x1d, 0xf2, - 0x0d, 0xb4, 0x04, 0xc1, 0x24, 0xa8, 0x7d, 0xd3, 0xf0, 0x4c, 0xf2, 0x1f, 0xbe, 0xd1, 0xa7, 0x0c, - 0xff, 0xb7, 0x05, 0x6d, 0xd1, 0x08, 0x46, 0xe6, 0xe0, 0xaa, 0xd1, 0x23, 0xf5, 0x92, 0x2a, 0x57, - 0xc3, 0x3f, 0xd8, 0x62, 0x2d, 0x71, 0xcf, 0xc1, 0x55, 0x73, 0xb2, 0x11, 0xa8, 0x32, 0xc7, 0x1b, - 0x81, 0x6a, 0xc3, 0xb5, 0x43, 0x4e, 0x34, 0x5c, 0xbf, 0x01, 0x8a, 0x09, 0x72, 0xb7, 0xd1, 0x66, - 0x42, 0xfc, 0xe0, 0xca, 0x97, 0xe5, 0xe3, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x8c, 0xe4, 0x2e, - 0x5a, 0x7a, 0x0a, 0x00, 0x00, + // 897 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0x4f, 0x8f, 0xdb, 0x54, + 0x10, 0x5f, 0xdb, 0x89, 0x93, 0x9d, 0x24, 0xbb, 0xd1, 0xeb, 0xb6, 0x58, 0x6e, 0xb7, 0x6c, 0x5d, + 0x84, 0x96, 0x0a, 0xb2, 0x28, 0xbd, 0x00, 0xbd, 0xb0, 0x6a, 0xa2, 0xd0, 0x42, 0x83, 0xb0, 0x8a, + 0xca, 0x05, 0x55, 0xc6, 0x19, 0x58, 0x6b, 0xb3, 0xb6, 0x79, 0xef, 0x79, 0x45, 0x2e, 0x48, 0x9c, + 0xf8, 0x02, 0x7c, 0x04, 0x4e, 0x7c, 0x26, 0xee, 0x7c, 0x0d, 0xf4, 0xfe, 0x79, 0x63, 0xc7, 0xa9, + 0x56, 0xb0, 0x87, 0xde, 0xde, 0xbc, 0x19, 0xcf, 0xcc, 0xef, 0x37, 0x7f, 0xfc, 0xe0, 0x30, 0x2a, + 0xf8, 0xd9, 0x09, 0x43, 0x7a, 0x99, 0xc4, 0x78, 0x92, 0xd3, 0x8c, 0x67, 0x27, 0xe2, 0x6a, 0x24, + 0x8f, 0x64, 0xf0, 0x53, 0x36, 0xba, 0x48, 0x62, 0x9a, 0x8d, 0xc4, 0x65, 0x70, 0x1b, 0x6e, 0x7d, + 0x95, 0x30, 0x7e, 0x1a, 0xc7, 0x59, 0x91, 0x72, 0x16, 0xe2, 0xcf, 0x05, 0x32, 0x1e, 0x3c, 0x87, + 0x83, 0xea, 0x35, 0xcb, 0xb3, 0x94, 0x21, 0x19, 0x43, 0x37, 0xd2, 0x77, 0x9e, 0x75, 0xe4, 0x1c, + 0xf7, 0xc6, 0x77, 0x46, 0x15, 0x87, 0x23, 0xfd, 0x49, 0x58, 0xda, 0x05, 0xbf, 0x59, 0xd0, 0x7e, + 0x99, 0x9d, 0x63, 0x4a, 0x1e, 0x40, 0x3f, 0x8a, 0x63, 0x64, 0xec, 0x35, 0x17, 0xb2, 0x67, 0x1d, + 0x59, 0xc7, 0xbb, 0x61, 0x4f, 0xdd, 0x29, 0x93, 0x87, 0x30, 0xa0, 0xf8, 0x23, 0x45, 0x76, 0xa6, + 0x6d, 0x6c, 0x69, 0xd3, 0xd7, 0x97, 0xca, 0xc8, 0x83, 0x4e, 0x4c, 0x31, 0xe2, 0xb8, 0xf0, 0x9c, + 0x23, 0xeb, 0xd8, 0x09, 0x8d, 0x48, 0xee, 0x80, 0x8b, 0xbf, 0xe4, 0x09, 0x5d, 0x79, 0x2d, 0xa9, + 0xd0, 0x52, 0xf0, 0x87, 0x0d, 0x1d, 0x9d, 0x19, 0xd9, 0x03, 0x3b, 0x59, 0xe8, 0xd8, 0x76, 0xb2, + 0x20, 0x04, 0x5a, 0x7c, 0x95, 0xa3, 0x8e, 0x24, 0xcf, 0xe4, 0x00, 0xda, 0x34, 0x5b, 0x22, 0xf3, + 0x9c, 0x23, 0xe7, 0x78, 0x37, 0x54, 0x02, 0xf9, 0x1c, 0xba, 0x17, 0xc8, 0xa3, 0x45, 0xc4, 0x23, + 0xaf, 0x25, 0xd1, 0xbf, 0xd7, 0x8c, 0x7e, 0xf4, 0x42, 0x9b, 0x4d, 0x53, 0x4e, 0x57, 0x61, 0xf9, + 0x15, 0xb9, 0x07, 0xbb, 0x69, 0x74, 0x81, 0x2c, 0x8f, 0x62, 0xf4, 0xda, 0x32, 0xe0, 0xd5, 0x05, + 0xf1, 0xa1, 0x9b, 0xd3, 0xec, 0x32, 0x59, 0x20, 0xf5, 0x5c, 0xa9, 0x2c, 0x65, 0x81, 0x8c, 0x61, + 0x4c, 0x91, 0x7b, 0x1d, 0xa9, 0xd1, 0x92, 0xff, 0x04, 0x06, 0x95, 0x60, 0x64, 0x08, 0xce, 0x39, + 0xae, 0x34, 0x3e, 0x71, 0x14, 0x60, 0x2e, 0xa3, 0x65, 0x61, 0x10, 0x2a, 0xe1, 0x33, 0xfb, 0x13, + 0x2b, 0x58, 0x42, 0x37, 0x44, 0x96, 0x15, 0x34, 0x46, 0x41, 0x83, 0xc8, 0x44, 0x7f, 0x28, 0xcf, + 0x8d, 0xd4, 0xf8, 0xd0, 0xc5, 0x74, 0x91, 0x67, 0x49, 0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82, 0x9f, 0x91, 0x17, 0xd0, 0x35, 0xdb, 0x8a, 0xdc, 0x7f, 0xf3, 0x52, + 0xf6, 0xdf, 0xdd, 0xaa, 0xd7, 0x78, 0x76, 0xc8, 0x73, 0xe8, 0xe8, 0xc1, 0x25, 0x87, 0x35, 0xeb, + 0xea, 0xe0, 0xfb, 0xf7, 0xb7, 0xa9, 0x4b, 0x5f, 0x13, 0xf3, 0xee, 0xb8, 0xdb, 0x38, 0x28, 0xda, + 0xcf, 0xbd, 0x66, 0xa5, 0xf1, 0x32, 0xfe, 0x1e, 0xba, 0xe6, 0x19, 0x44, 0xbe, 0x81, 0x96, 0x20, + 0x98, 0x04, 0xb5, 0x6f, 0x1a, 0x9e, 0x50, 0xfe, 0xc3, 0x37, 0xda, 0x94, 0xee, 0xff, 0xb6, 0xa0, + 0x2d, 0x0a, 0xc1, 0xc8, 0x0c, 0x5c, 0xd5, 0x7a, 0xa4, 0x9e, 0x52, 0x65, 0x34, 0xfc, 0xc3, 0x2d, + 0xda, 0x12, 0xf7, 0x0c, 0x5c, 0xd5, 0x27, 0x1b, 0x8e, 0x2a, 0x7d, 0xbc, 0xe1, 0xa8, 0xd6, 0x5c, + 0x3b, 0xe4, 0x54, 0xc3, 0xf5, 0x1b, 0xa0, 0x18, 0x27, 0x77, 0x1b, 0x75, 0xc6, 0xc5, 0x0f, 0xae, + 0x7c, 0x75, 0x3e, 0xfe, 0x37, 0x00, 0x00, 0xff, 0xff, 0xe8, 0xcd, 0x03, 0x66, 0x96, 0x0a, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/auth/service/proto/auth.pb.micro.go b/auth/service/proto/auth.pb.micro.go index 0fcdaf74..52008a15 100644 --- a/auth/service/proto/auth.pb.micro.go +++ b/auth/service/proto/auth.pb.micro.go @@ -11,7 +11,6 @@ import ( import ( context "context" - api "github.com/micro/go-micro/v2/api" client "github.com/micro/go-micro/v2/client" server "github.com/micro/go-micro/v2/server" ) @@ -28,17 +27,10 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package // Reference imports to suppress errors if they are not otherwise used. -var _ api.Endpoint var _ context.Context var _ client.Option var _ server.Option -// Api Endpoints for Auth service - -func NewAuthEndpoints() []*api.Endpoint { - return []*api.Endpoint{} -} - // Client API for Auth service type AuthService interface { @@ -126,12 +118,6 @@ func (h *authHandler) Token(ctx context.Context, in *TokenRequest, out *TokenRes return h.AuthHandler.Token(ctx, in, out) } -// Api Endpoints for Accounts service - -func NewAccountsEndpoints() []*api.Endpoint { - return []*api.Endpoint{} -} - // Client API for Accounts service type AccountsService interface { @@ -185,12 +171,6 @@ func (h *accountsHandler) List(ctx context.Context, in *ListAccountsRequest, out return h.AccountsHandler.List(ctx, in, out) } -// Api Endpoints for Rules service - -func NewRulesEndpoints() []*api.Endpoint { - return []*api.Endpoint{} -} - // Client API for Rules service type RulesService interface { diff --git a/auth/service/proto/auth.proto b/auth/service/proto/auth.proto index 77a44af8..aa225f1d 100644 --- a/auth/service/proto/auth.proto +++ b/auth/service/proto/auth.proto @@ -107,6 +107,7 @@ message Rule { string role = 2; Resource resource = 3; Access access = 4; + int32 priority = 5; } message CreateRequest { diff --git a/auth/service/service.go b/auth/service/service.go index 73e3f80a..67c4d4ca 100644 --- a/auth/service/service.go +++ b/auth/service/service.go @@ -3,6 +3,7 @@ package service import ( "context" "fmt" + "sort" "strings" "sync" "time" @@ -290,6 +291,11 @@ func (s *svc) listRules(filters ...string) []*pb.Rule { rules = append(rules, r) } + // sort rules by priority + sort.Slice(rules, func(i, j int) bool { + return rules[i].Priority < rules[j].Priority + }) + return rules } diff --git a/auth/service/sevice_test.go b/auth/service/sevice_test.go new file mode 100644 index 00000000..1c206ee3 --- /dev/null +++ b/auth/service/sevice_test.go @@ -0,0 +1,26 @@ +package service + +import ( + "testing" + + pb "github.com/micro/go-micro/v2/auth/service/proto" +) + +func TestListRulesSorting(t *testing.T) { + s := &svc{ + rules: []*pb.Rule{ + &pb.Rule{Priority: 1}, + &pb.Rule{Priority: 3}, + &pb.Rule{Priority: 2}, + }, + } + + var priorities []int32 + for _, r := range s.listRules() { + priorities = append(priorities, r.Priority) + } + + if priorities[0] != 1 || priorities[1] != 2 || priorities[2] != 3 { + t.Errorf("Incorrect Rule Sequence") + } +} diff --git a/broker/service/proto/broker.pb.micro.go b/broker/service/proto/broker.pb.micro.go index 01e6f938..384f66f6 100644 --- a/broker/service/proto/broker.pb.micro.go +++ b/broker/service/proto/broker.pb.micro.go @@ -11,7 +11,6 @@ import ( import ( context "context" - api "github.com/micro/go-micro/v2/api" client "github.com/micro/go-micro/v2/client" server "github.com/micro/go-micro/v2/server" ) @@ -28,17 +27,10 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package // Reference imports to suppress errors if they are not otherwise used. -var _ api.Endpoint var _ context.Context var _ client.Option var _ server.Option -// Api Endpoints for Broker service - -func NewBrokerEndpoints() []*api.Endpoint { - return []*api.Endpoint{} -} - // Client API for Broker service type BrokerService interface { diff --git a/client/service/proto/client.pb.micro.go b/client/service/proto/client.pb.micro.go index 0f3094bb..671e5021 100644 --- a/client/service/proto/client.pb.micro.go +++ b/client/service/proto/client.pb.micro.go @@ -11,7 +11,6 @@ import ( import ( context "context" - api "github.com/micro/go-micro/v2/api" client "github.com/micro/go-micro/v2/client" server "github.com/micro/go-micro/v2/server" ) @@ -28,17 +27,10 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package // Reference imports to suppress errors if they are not otherwise used. -var _ api.Endpoint var _ context.Context var _ client.Option var _ server.Option -// Api Endpoints for Client service - -func NewClientEndpoints() []*api.Endpoint { - return []*api.Endpoint{} -} - // Client API for Client service type ClientService interface { diff --git a/config/source/service/proto/service.pb.micro.go b/config/source/service/proto/service.pb.micro.go index d37fc283..58e606ee 100644 --- a/config/source/service/proto/service.pb.micro.go +++ b/config/source/service/proto/service.pb.micro.go @@ -11,7 +11,6 @@ import ( import ( context "context" - api "github.com/micro/go-micro/v2/api" client "github.com/micro/go-micro/v2/client" server "github.com/micro/go-micro/v2/server" ) @@ -28,17 +27,10 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package // Reference imports to suppress errors if they are not otherwise used. -var _ api.Endpoint var _ context.Context var _ client.Option var _ server.Option -// Api Endpoints for Config service - -func NewConfigEndpoints() []*api.Endpoint { - return []*api.Endpoint{} -} - // Client API for Config service type ConfigService interface { diff --git a/debug/service/proto/debug.pb.micro.go b/debug/service/proto/debug.pb.micro.go index 3d71b722..9747f3c2 100644 --- a/debug/service/proto/debug.pb.micro.go +++ b/debug/service/proto/debug.pb.micro.go @@ -11,7 +11,6 @@ import ( import ( context "context" - api "github.com/micro/go-micro/v2/api" client "github.com/micro/go-micro/v2/client" server "github.com/micro/go-micro/v2/server" ) @@ -28,17 +27,10 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package // Reference imports to suppress errors if they are not otherwise used. -var _ api.Endpoint var _ context.Context var _ client.Option var _ server.Option -// Api Endpoints for Debug service - -func NewDebugEndpoints() []*api.Endpoint { - return []*api.Endpoint{} -} - // Client API for Debug service type DebugService interface { diff --git a/go.sum b/go.sum index db9453b6..f36442e8 100644 --- a/go.sum +++ b/go.sum @@ -288,6 +288,7 @@ github.com/mholt/certmagic v0.9.3 h1:RmzuNJ5mpFplDbyS41z+gGgE/py24IX6m0nHZ0yNTQU github.com/mholt/certmagic v0.9.3/go.mod h1:nu8jbsbtwK4205EDH/ZUMTKsfYpJA1Q7MKXHfgTihNw= github.com/micro/cli/v2 v2.1.2 h1:43J1lChg/rZCC1rvdqZNFSQDrGT7qfMrtp6/ztpIkEM= github.com/micro/cli/v2 v2.1.2/go.mod h1:EguNh6DAoWKm9nmk+k/Rg0H3lQnDxqzu5x5srOtGtYg= +github.com/micro/go-micro v1.18.0 h1:gP70EZVHpJuUIT0YWth192JmlIci+qMOEByHm83XE9E= github.com/miekg/dns v1.1.15/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.27 h1:aEH/kqUzUxGJ/UHcEKdJY+ugH6WEzsEBBSPa8zuy1aM= github.com/miekg/dns v1.1.27/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= diff --git a/network/service/proto/network.pb.micro.go b/network/service/proto/network.pb.micro.go index 2446ff23..8b5ab957 100644 --- a/network/service/proto/network.pb.micro.go +++ b/network/service/proto/network.pb.micro.go @@ -12,7 +12,6 @@ import ( import ( context "context" - api "github.com/micro/go-micro/v2/api" client "github.com/micro/go-micro/v2/client" server "github.com/micro/go-micro/v2/server" ) @@ -29,17 +28,10 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package // Reference imports to suppress errors if they are not otherwise used. -var _ api.Endpoint var _ context.Context var _ client.Option var _ server.Option -// Api Endpoints for Network service - -func NewNetworkEndpoints() []*api.Endpoint { - return []*api.Endpoint{} -} - // Client API for Network service type NetworkService interface { diff --git a/registry/service/proto/registry.pb.micro.go b/registry/service/proto/registry.pb.micro.go index 482b2146..96af6f7e 100644 --- a/registry/service/proto/registry.pb.micro.go +++ b/registry/service/proto/registry.pb.micro.go @@ -11,7 +11,6 @@ import ( import ( context "context" - api "github.com/micro/go-micro/v2/api" client "github.com/micro/go-micro/v2/client" server "github.com/micro/go-micro/v2/server" ) @@ -28,17 +27,10 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package // Reference imports to suppress errors if they are not otherwise used. -var _ api.Endpoint var _ context.Context var _ client.Option var _ server.Option -// Api Endpoints for Registry service - -func NewRegistryEndpoints() []*api.Endpoint { - return []*api.Endpoint{} -} - // Client API for Registry service type RegistryService interface { diff --git a/router/service/proto/router.pb.micro.go b/router/service/proto/router.pb.micro.go index b39fff3a..d554458a 100644 --- a/router/service/proto/router.pb.micro.go +++ b/router/service/proto/router.pb.micro.go @@ -11,7 +11,6 @@ import ( import ( context "context" - api "github.com/micro/go-micro/v2/api" client "github.com/micro/go-micro/v2/client" server "github.com/micro/go-micro/v2/server" ) @@ -28,17 +27,10 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package // Reference imports to suppress errors if they are not otherwise used. -var _ api.Endpoint var _ context.Context var _ client.Option var _ server.Option -// Api Endpoints for Router service - -func NewRouterEndpoints() []*api.Endpoint { - return []*api.Endpoint{} -} - // Client API for Router service type RouterService interface { @@ -293,12 +285,6 @@ func (h *routerHandler) Process(ctx context.Context, in *Advert, out *ProcessRes return h.RouterHandler.Process(ctx, in, out) } -// Api Endpoints for Table service - -func NewTableEndpoints() []*api.Endpoint { - return []*api.Endpoint{} -} - // Client API for Table service type TableService interface { diff --git a/runtime/service/proto/runtime.pb.micro.go b/runtime/service/proto/runtime.pb.micro.go index 73b7c3ca..8c968415 100644 --- a/runtime/service/proto/runtime.pb.micro.go +++ b/runtime/service/proto/runtime.pb.micro.go @@ -11,7 +11,6 @@ import ( import ( context "context" - api "github.com/micro/go-micro/v2/api" client "github.com/micro/go-micro/v2/client" server "github.com/micro/go-micro/v2/server" ) @@ -28,17 +27,10 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package // Reference imports to suppress errors if they are not otherwise used. -var _ api.Endpoint var _ context.Context var _ client.Option var _ server.Option -// Api Endpoints for Runtime service - -func NewRuntimeEndpoints() []*api.Endpoint { - return []*api.Endpoint{} -} - // Client API for Runtime service type RuntimeService interface { diff --git a/server/grpc/proto/test.pb.micro.go b/server/grpc/proto/test.pb.micro.go index 0139530b..c1bdad72 100644 --- a/server/grpc/proto/test.pb.micro.go +++ b/server/grpc/proto/test.pb.micro.go @@ -12,7 +12,6 @@ import ( import ( context "context" - api "github.com/micro/go-micro/v2/api" client "github.com/micro/go-micro/v2/client" server "github.com/micro/go-micro/v2/server" ) @@ -29,25 +28,10 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package // Reference imports to suppress errors if they are not otherwise used. -var _ api.Endpoint var _ context.Context var _ client.Option var _ server.Option -// Api Endpoints for Test service - -func NewTestEndpoints() []*api.Endpoint { - return []*api.Endpoint{ - &api.Endpoint{ - Name: "Test.Call", - Path: []string{"/api/v0/test/call/{uuid}"}, - Method: []string{"POST"}, - Body: "*", - Handler: "rpc", - }, - } -} - // Client API for Test service type TestService interface { @@ -90,13 +74,6 @@ func RegisterTestHandler(s server.Server, hdlr TestHandler, opts ...server.Handl test } h := &testHandler{hdlr} - opts = append(opts, api.WithEndpoint(&api.Endpoint{ - Name: "Test.Call", - Path: []string{"/api/v0/test/call/{uuid}"}, - Method: []string{"POST"}, - Body: "*", - Handler: "rpc", - })) return s.Handle(s.NewHandler(&Test{h}, opts...)) } diff --git a/server/proto/server.pb.micro.go b/server/proto/server.pb.micro.go index 5d84eda9..892ce569 100644 --- a/server/proto/server.pb.micro.go +++ b/server/proto/server.pb.micro.go @@ -11,7 +11,6 @@ import ( import ( context "context" - api "github.com/micro/go-micro/v2/api" client "github.com/micro/go-micro/v2/client" server "github.com/micro/go-micro/v2/server" ) @@ -28,17 +27,10 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package // Reference imports to suppress errors if they are not otherwise used. -var _ api.Endpoint var _ context.Context var _ client.Option var _ server.Option -// Api Endpoints for Server service - -func NewServerEndpoints() []*api.Endpoint { - return []*api.Endpoint{} -} - // Client API for Server service type ServerService interface { diff --git a/service/grpc/proto/test.pb.micro.go b/service/grpc/proto/test.pb.micro.go index 0c748d47..f4d93011 100644 --- a/service/grpc/proto/test.pb.micro.go +++ b/service/grpc/proto/test.pb.micro.go @@ -11,7 +11,6 @@ import ( import ( context "context" - api "github.com/micro/go-micro/v2/api" client "github.com/micro/go-micro/v2/client" server "github.com/micro/go-micro/v2/server" ) @@ -28,17 +27,10 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package // Reference imports to suppress errors if they are not otherwise used. -var _ api.Endpoint var _ context.Context var _ client.Option var _ server.Option -// Api Endpoints for Test service - -func NewTestEndpoints() []*api.Endpoint { - return []*api.Endpoint{} -} - // Client API for Test service type TestService interface { diff --git a/store/service/proto/store.pb.micro.go b/store/service/proto/store.pb.micro.go index 0e622f09..819b1974 100644 --- a/store/service/proto/store.pb.micro.go +++ b/store/service/proto/store.pb.micro.go @@ -11,7 +11,6 @@ import ( import ( context "context" - api "github.com/micro/go-micro/v2/api" client "github.com/micro/go-micro/v2/client" server "github.com/micro/go-micro/v2/server" ) @@ -28,17 +27,10 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package // Reference imports to suppress errors if they are not otherwise used. -var _ api.Endpoint var _ context.Context var _ client.Option var _ server.Option -// Api Endpoints for Store service - -func NewStoreEndpoints() []*api.Endpoint { - return []*api.Endpoint{} -} - // Client API for Store service type StoreService interface { diff --git a/transport/grpc/proto/transport.pb.micro.go b/transport/grpc/proto/transport.pb.micro.go index 96532171..d3866eb3 100644 --- a/transport/grpc/proto/transport.pb.micro.go +++ b/transport/grpc/proto/transport.pb.micro.go @@ -11,7 +11,6 @@ import ( import ( context "context" - api "github.com/micro/go-micro/v2/api" client "github.com/micro/go-micro/v2/client" server "github.com/micro/go-micro/v2/server" ) @@ -28,17 +27,10 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package // Reference imports to suppress errors if they are not otherwise used. -var _ api.Endpoint var _ context.Context var _ client.Option var _ server.Option -// Api Endpoints for Transport service - -func NewTransportEndpoints() []*api.Endpoint { - return []*api.Endpoint{} -} - // Client API for Transport service type TransportService interface {