From dbe8c93e202bf9d19c354c3c671081dc80f6f5e5 Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Fri, 11 Dec 2020 11:12:44 +0000 Subject: [PATCH] remove service implementations (#2094) --- api/service/proto/api.pb.go | 268 --- api/service/proto/api.pb.micro.go | 110 -- api/service/proto/api.proto | 18 - auth/service/proto/auth.pb.go | 1512 ----------------- auth/service/proto/auth.pb.micro.go | 279 --- auth/service/proto/auth.proto | 127 -- auth/service/service.go | 228 --- broker/service/proto/broker.pb.go | 374 ---- broker/service/proto/broker.pb.micro.go | 185 -- broker/service/proto/broker.proto | 25 - broker/service/service.go | 146 -- broker/service/subscriber.go | 108 -- client/service/proto/client.pb.go | 402 ----- client/service/proto/client.pb.micro.go | 215 --- client/service/proto/client.proto | 30 - cmd/cmd.go | 26 +- config/source/service/options.go | 38 - config/source/service/proto/service.pb.go | 952 ----------- .../source/service/proto/service.pb.micro.go | 253 --- config/source/service/proto/service.proto | 67 - config/source/service/service.go | 106 -- config/source/service/util.go | 18 - config/source/service/watcher.go | 27 - go.mod | 2 +- registry/service/options.go | 21 - registry/service/proto/registry.pb.go | 1024 ----------- registry/service/proto/registry.pb.micro.go | 236 --- registry/service/proto/registry.proto | 98 -- registry/service/service.go | 217 --- registry/service/util.go | 134 -- registry/service/watcher.go | 47 - runtime/service/proto/runtime.pb.go | 1276 -------------- runtime/service/proto/runtime.pb.micro.go | 236 --- runtime/service/proto/runtime.proto | 127 -- runtime/service/service.go | 286 ---- store/service/proto/store.pb.go | 1455 ---------------- store/service/proto/store.pb.micro.go | 253 --- store/service/proto/store.proto | 109 -- store/service/service.go | 258 --- 39 files changed, 3 insertions(+), 11290 deletions(-) delete mode 100644 api/service/proto/api.pb.go delete mode 100644 api/service/proto/api.pb.micro.go delete mode 100644 api/service/proto/api.proto delete mode 100644 auth/service/proto/auth.pb.go delete mode 100644 auth/service/proto/auth.pb.micro.go delete mode 100644 auth/service/proto/auth.proto delete mode 100644 auth/service/service.go delete mode 100644 broker/service/proto/broker.pb.go delete mode 100644 broker/service/proto/broker.pb.micro.go delete mode 100644 broker/service/proto/broker.proto delete mode 100644 broker/service/service.go delete mode 100644 broker/service/subscriber.go delete mode 100644 client/service/proto/client.pb.go delete mode 100644 client/service/proto/client.pb.micro.go delete mode 100644 client/service/proto/client.proto delete mode 100644 config/source/service/options.go delete mode 100644 config/source/service/proto/service.pb.go delete mode 100644 config/source/service/proto/service.pb.micro.go delete mode 100644 config/source/service/proto/service.proto delete mode 100644 config/source/service/service.go delete mode 100644 config/source/service/util.go delete mode 100644 config/source/service/watcher.go delete mode 100644 registry/service/options.go delete mode 100644 registry/service/proto/registry.pb.go delete mode 100644 registry/service/proto/registry.pb.micro.go delete mode 100644 registry/service/proto/registry.proto delete mode 100644 registry/service/service.go delete mode 100644 registry/service/util.go delete mode 100644 registry/service/watcher.go delete mode 100644 runtime/service/proto/runtime.pb.go delete mode 100644 runtime/service/proto/runtime.pb.micro.go delete mode 100644 runtime/service/proto/runtime.proto delete mode 100644 runtime/service/service.go delete mode 100644 store/service/proto/store.pb.go delete mode 100644 store/service/proto/store.pb.micro.go delete mode 100644 store/service/proto/store.proto delete mode 100644 store/service/service.go diff --git a/api/service/proto/api.pb.go b/api/service/proto/api.pb.go deleted file mode 100644 index 7cdff499..00000000 --- a/api/service/proto/api.pb.go +++ /dev/null @@ -1,268 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: api/service/proto/api.proto - -package go_micro_api - -import ( - context "context" - fmt "fmt" - proto "github.com/golang/protobuf/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - math "math" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package - -type Endpoint struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Host []string `protobuf:"bytes,2,rep,name=host,proto3" json:"host,omitempty"` - Path []string `protobuf:"bytes,3,rep,name=path,proto3" json:"path,omitempty"` - Method []string `protobuf:"bytes,4,rep,name=method,proto3" json:"method,omitempty"` - Stream bool `protobuf:"varint,5,opt,name=stream,proto3" json:"stream,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Endpoint) Reset() { *m = Endpoint{} } -func (m *Endpoint) String() string { return proto.CompactTextString(m) } -func (*Endpoint) ProtoMessage() {} -func (*Endpoint) Descriptor() ([]byte, []int) { - return fileDescriptor_c4a48b6b680b5c31, []int{0} -} - -func (m *Endpoint) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Endpoint.Unmarshal(m, b) -} -func (m *Endpoint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Endpoint.Marshal(b, m, deterministic) -} -func (m *Endpoint) XXX_Merge(src proto.Message) { - xxx_messageInfo_Endpoint.Merge(m, src) -} -func (m *Endpoint) XXX_Size() int { - return xxx_messageInfo_Endpoint.Size(m) -} -func (m *Endpoint) XXX_DiscardUnknown() { - xxx_messageInfo_Endpoint.DiscardUnknown(m) -} - -var xxx_messageInfo_Endpoint proto.InternalMessageInfo - -func (m *Endpoint) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *Endpoint) GetHost() []string { - if m != nil { - return m.Host - } - return nil -} - -func (m *Endpoint) GetPath() []string { - if m != nil { - return m.Path - } - return nil -} - -func (m *Endpoint) GetMethod() []string { - if m != nil { - return m.Method - } - return nil -} - -func (m *Endpoint) GetStream() bool { - if m != nil { - return m.Stream - } - return false -} - -type EmptyResponse struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *EmptyResponse) Reset() { *m = EmptyResponse{} } -func (m *EmptyResponse) String() string { return proto.CompactTextString(m) } -func (*EmptyResponse) ProtoMessage() {} -func (*EmptyResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_c4a48b6b680b5c31, []int{1} -} - -func (m *EmptyResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_EmptyResponse.Unmarshal(m, b) -} -func (m *EmptyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_EmptyResponse.Marshal(b, m, deterministic) -} -func (m *EmptyResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_EmptyResponse.Merge(m, src) -} -func (m *EmptyResponse) XXX_Size() int { - return xxx_messageInfo_EmptyResponse.Size(m) -} -func (m *EmptyResponse) XXX_DiscardUnknown() { - xxx_messageInfo_EmptyResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_EmptyResponse proto.InternalMessageInfo - -func init() { - proto.RegisterType((*Endpoint)(nil), "go.micro.api.Endpoint") - proto.RegisterType((*EmptyResponse)(nil), "go.micro.api.EmptyResponse") -} - -func init() { proto.RegisterFile("api/service/proto/api.proto", fileDescriptor_c4a48b6b680b5c31) } - -var fileDescriptor_c4a48b6b680b5c31 = []byte{ - // 212 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0xd0, 0xc1, 0x4a, 0x03, 0x31, - 0x10, 0x80, 0x61, 0xd7, 0xad, 0x65, 0x1d, 0x14, 0x21, 0x87, 0x12, 0xec, 0x65, 0xd9, 0x53, 0x4f, - 0x59, 0xd0, 0x27, 0x28, 0xda, 0x17, 0xd8, 0x37, 0x88, 0xed, 0xd0, 0x9d, 0x43, 0x32, 0x43, 0x32, - 0x14, 0x7c, 0x08, 0xdf, 0x59, 0x12, 0x2b, 0x2c, 0x5e, 0xbd, 0xfd, 0xf3, 0x1d, 0x86, 0x61, 0x60, - 0xeb, 0x85, 0xc6, 0x8c, 0xe9, 0x42, 0x47, 0x1c, 0x25, 0xb1, 0xf2, 0xe8, 0x85, 0x5c, 0x2d, 0xf3, - 0x70, 0x66, 0x17, 0xe8, 0x98, 0xd8, 0x79, 0xa1, 0xe1, 0x02, 0xdd, 0x21, 0x9e, 0x84, 0x29, 0xaa, - 0x31, 0xb0, 0x8a, 0x3e, 0xa0, 0x6d, 0xfa, 0x66, 0x77, 0x3f, 0xd5, 0x2e, 0x36, 0x73, 0x56, 0x7b, - 0xdb, 0xb7, 0xc5, 0x4a, 0x17, 0x13, 0xaf, 0xb3, 0x6d, 0x7f, 0xac, 0xb4, 0xd9, 0xc0, 0x3a, 0xa0, - 0xce, 0x7c, 0xb2, 0xab, 0xaa, 0xd7, 0xa9, 0x78, 0xd6, 0x84, 0x3e, 0xd8, 0xbb, 0xbe, 0xd9, 0x75, - 0xd3, 0x75, 0x1a, 0x9e, 0xe0, 0xf1, 0x10, 0x44, 0x3f, 0x27, 0xcc, 0xc2, 0x31, 0xe3, 0xcb, 0x57, - 0x03, 0xed, 0x5e, 0xc8, 0xec, 0xa1, 0x9b, 0xf0, 0x4c, 0x59, 0x31, 0x99, 0x8d, 0x5b, 0xde, 0xea, - 0x7e, 0x0f, 0x7d, 0xde, 0xfe, 0xf1, 0xe5, 0xa2, 0xe1, 0xc6, 0xbc, 0x01, 0xbc, 0x63, 0xfa, 0xdf, - 0x92, 0x8f, 0x75, 0xfd, 0xd6, 0xeb, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x46, 0x62, 0x67, 0x30, - 0x4c, 0x01, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// ApiClient is the client API for Api service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type ApiClient interface { - Register(ctx context.Context, in *Endpoint, opts ...grpc.CallOption) (*EmptyResponse, error) - Deregister(ctx context.Context, in *Endpoint, opts ...grpc.CallOption) (*EmptyResponse, error) -} - -type apiClient struct { - cc *grpc.ClientConn -} - -func NewApiClient(cc *grpc.ClientConn) ApiClient { - return &apiClient{cc} -} - -func (c *apiClient) Register(ctx context.Context, in *Endpoint, opts ...grpc.CallOption) (*EmptyResponse, error) { - out := new(EmptyResponse) - err := c.cc.Invoke(ctx, "/go.micro.api.Api/Register", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *apiClient) Deregister(ctx context.Context, in *Endpoint, opts ...grpc.CallOption) (*EmptyResponse, error) { - out := new(EmptyResponse) - err := c.cc.Invoke(ctx, "/go.micro.api.Api/Deregister", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// ApiServer is the server API for Api service. -type ApiServer interface { - Register(context.Context, *Endpoint) (*EmptyResponse, error) - Deregister(context.Context, *Endpoint) (*EmptyResponse, error) -} - -// UnimplementedApiServer can be embedded to have forward compatible implementations. -type UnimplementedApiServer struct { -} - -func (*UnimplementedApiServer) Register(ctx context.Context, req *Endpoint) (*EmptyResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Register not implemented") -} -func (*UnimplementedApiServer) Deregister(ctx context.Context, req *Endpoint) (*EmptyResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Deregister not implemented") -} - -func RegisterApiServer(s *grpc.Server, srv ApiServer) { - s.RegisterService(&_Api_serviceDesc, srv) -} - -func _Api_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Endpoint) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ApiServer).Register(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/go.micro.api.Api/Register", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ApiServer).Register(ctx, req.(*Endpoint)) - } - return interceptor(ctx, in, info, handler) -} - -func _Api_Deregister_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Endpoint) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ApiServer).Deregister(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/go.micro.api.Api/Deregister", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ApiServer).Deregister(ctx, req.(*Endpoint)) - } - return interceptor(ctx, in, info, handler) -} - -var _Api_serviceDesc = grpc.ServiceDesc{ - ServiceName: "go.micro.api.Api", - HandlerType: (*ApiServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Register", - Handler: _Api_Register_Handler, - }, - { - MethodName: "Deregister", - Handler: _Api_Deregister_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "api/service/proto/api.proto", -} diff --git a/api/service/proto/api.pb.micro.go b/api/service/proto/api.pb.micro.go deleted file mode 100644 index c2bcfbc6..00000000 --- a/api/service/proto/api.pb.micro.go +++ /dev/null @@ -1,110 +0,0 @@ -// Code generated by protoc-gen-micro. DO NOT EDIT. -// source: api/service/proto/api.proto - -package go_micro_api - -import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" - math "math" -) - -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" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -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 { - Register(ctx context.Context, in *Endpoint, opts ...client.CallOption) (*EmptyResponse, error) - Deregister(ctx context.Context, in *Endpoint, opts ...client.CallOption) (*EmptyResponse, error) -} - -type apiService struct { - c client.Client - name string -} - -func NewApiService(name string, c client.Client) ApiService { - return &apiService{ - c: c, - name: name, - } -} - -func (c *apiService) Register(ctx context.Context, in *Endpoint, opts ...client.CallOption) (*EmptyResponse, error) { - req := c.c.NewRequest(c.name, "Api.Register", in) - out := new(EmptyResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *apiService) Deregister(ctx context.Context, in *Endpoint, opts ...client.CallOption) (*EmptyResponse, error) { - req := c.c.NewRequest(c.name, "Api.Deregister", in) - out := new(EmptyResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// Server API for Api service - -type ApiHandler interface { - Register(context.Context, *Endpoint, *EmptyResponse) error - Deregister(context.Context, *Endpoint, *EmptyResponse) error -} - -func RegisterApiHandler(s server.Server, hdlr ApiHandler, opts ...server.HandlerOption) error { - type api interface { - Register(ctx context.Context, in *Endpoint, out *EmptyResponse) error - Deregister(ctx context.Context, in *Endpoint, out *EmptyResponse) error - } - type Api struct { - api - } - h := &apiHandler{hdlr} - return s.Handle(s.NewHandler(&Api{h}, opts...)) -} - -type apiHandler struct { - ApiHandler -} - -func (h *apiHandler) Register(ctx context.Context, in *Endpoint, out *EmptyResponse) error { - return h.ApiHandler.Register(ctx, in, out) -} - -func (h *apiHandler) Deregister(ctx context.Context, in *Endpoint, out *EmptyResponse) error { - return h.ApiHandler.Deregister(ctx, in, out) -} diff --git a/api/service/proto/api.proto b/api/service/proto/api.proto deleted file mode 100644 index c4317d12..00000000 --- a/api/service/proto/api.proto +++ /dev/null @@ -1,18 +0,0 @@ -syntax = "proto3"; - -package go.micro.api; - -service Api { - rpc Register(Endpoint) returns (EmptyResponse) {}; - rpc Deregister(Endpoint) returns (EmptyResponse) {}; -} - -message Endpoint { - string name = 1; - repeated string host = 2; - repeated string path = 3; - repeated string method = 4; - bool stream = 5; -} - -message EmptyResponse {} diff --git a/auth/service/proto/auth.pb.go b/auth/service/proto/auth.pb.go deleted file mode 100644 index fe13d389..00000000 --- a/auth/service/proto/auth.pb.go +++ /dev/null @@ -1,1512 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: auth/service/proto/auth.proto - -package go_micro_auth - -import ( - context "context" - fmt "fmt" - proto "github.com/golang/protobuf/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - math "math" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package - -type Access int32 - -const ( - Access_UNKNOWN Access = 0 - Access_GRANTED Access = 1 - Access_DENIED Access = 2 -) - -var Access_name = map[int32]string{ - 0: "UNKNOWN", - 1: "GRANTED", - 2: "DENIED", -} - -var Access_value = map[string]int32{ - "UNKNOWN": 0, - "GRANTED": 1, - "DENIED": 2, -} - -func (x Access) String() string { - return proto.EnumName(Access_name, int32(x)) -} - -func (Access) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_21300bfacc51fc2a, []int{0} -} - -type ListAccountsRequest struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListAccountsRequest) Reset() { *m = ListAccountsRequest{} } -func (m *ListAccountsRequest) String() string { return proto.CompactTextString(m) } -func (*ListAccountsRequest) ProtoMessage() {} -func (*ListAccountsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_21300bfacc51fc2a, []int{0} -} - -func (m *ListAccountsRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListAccountsRequest.Unmarshal(m, b) -} -func (m *ListAccountsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListAccountsRequest.Marshal(b, m, deterministic) -} -func (m *ListAccountsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListAccountsRequest.Merge(m, src) -} -func (m *ListAccountsRequest) XXX_Size() int { - return xxx_messageInfo_ListAccountsRequest.Size(m) -} -func (m *ListAccountsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ListAccountsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ListAccountsRequest proto.InternalMessageInfo - -type ListAccountsResponse struct { - Accounts []*Account `protobuf:"bytes,1,rep,name=accounts,proto3" json:"accounts,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListAccountsResponse) Reset() { *m = ListAccountsResponse{} } -func (m *ListAccountsResponse) String() string { return proto.CompactTextString(m) } -func (*ListAccountsResponse) ProtoMessage() {} -func (*ListAccountsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_21300bfacc51fc2a, []int{1} -} - -func (m *ListAccountsResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListAccountsResponse.Unmarshal(m, b) -} -func (m *ListAccountsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListAccountsResponse.Marshal(b, m, deterministic) -} -func (m *ListAccountsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListAccountsResponse.Merge(m, src) -} -func (m *ListAccountsResponse) XXX_Size() int { - return xxx_messageInfo_ListAccountsResponse.Size(m) -} -func (m *ListAccountsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ListAccountsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_ListAccountsResponse proto.InternalMessageInfo - -func (m *ListAccountsResponse) GetAccounts() []*Account { - if m != nil { - return m.Accounts - } - return nil -} - -type Token struct { - AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"` - RefreshToken string `protobuf:"bytes,2,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token,omitempty"` - Created int64 `protobuf:"varint,3,opt,name=created,proto3" json:"created,omitempty"` - Expiry int64 `protobuf:"varint,4,opt,name=expiry,proto3" json:"expiry,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Token) Reset() { *m = Token{} } -func (m *Token) String() string { return proto.CompactTextString(m) } -func (*Token) ProtoMessage() {} -func (*Token) Descriptor() ([]byte, []int) { - return fileDescriptor_21300bfacc51fc2a, []int{2} -} - -func (m *Token) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Token.Unmarshal(m, b) -} -func (m *Token) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Token.Marshal(b, m, deterministic) -} -func (m *Token) XXX_Merge(src proto.Message) { - xxx_messageInfo_Token.Merge(m, src) -} -func (m *Token) XXX_Size() int { - return xxx_messageInfo_Token.Size(m) -} -func (m *Token) XXX_DiscardUnknown() { - xxx_messageInfo_Token.DiscardUnknown(m) -} - -var xxx_messageInfo_Token proto.InternalMessageInfo - -func (m *Token) GetAccessToken() string { - if m != nil { - return m.AccessToken - } - return "" -} - -func (m *Token) GetRefreshToken() string { - if m != nil { - return m.RefreshToken - } - return "" -} - -func (m *Token) GetCreated() int64 { - if m != nil { - return m.Created - } - return 0 -} - -func (m *Token) GetExpiry() int64 { - if m != nil { - return m.Expiry - } - return 0 -} - -type Account struct { - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` - Metadata map[string]string `protobuf:"bytes,4,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - Scopes []string `protobuf:"bytes,5,rep,name=scopes,proto3" json:"scopes,omitempty"` - Issuer string `protobuf:"bytes,6,opt,name=issuer,proto3" json:"issuer,omitempty"` - Secret string `protobuf:"bytes,7,opt,name=secret,proto3" json:"secret,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Account) Reset() { *m = Account{} } -func (m *Account) String() string { return proto.CompactTextString(m) } -func (*Account) ProtoMessage() {} -func (*Account) Descriptor() ([]byte, []int) { - return fileDescriptor_21300bfacc51fc2a, []int{3} -} - -func (m *Account) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Account.Unmarshal(m, b) -} -func (m *Account) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Account.Marshal(b, m, deterministic) -} -func (m *Account) XXX_Merge(src proto.Message) { - xxx_messageInfo_Account.Merge(m, src) -} -func (m *Account) XXX_Size() int { - return xxx_messageInfo_Account.Size(m) -} -func (m *Account) XXX_DiscardUnknown() { - xxx_messageInfo_Account.DiscardUnknown(m) -} - -var xxx_messageInfo_Account proto.InternalMessageInfo - -func (m *Account) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -func (m *Account) GetType() string { - if m != nil { - return m.Type - } - return "" -} - -func (m *Account) GetMetadata() map[string]string { - if m != nil { - return m.Metadata - } - return nil -} - -func (m *Account) GetScopes() []string { - if m != nil { - return m.Scopes - } - return nil -} - -func (m *Account) GetIssuer() string { - if m != nil { - return m.Issuer - } - return "" -} - -func (m *Account) GetSecret() string { - if m != nil { - return m.Secret - } - return "" -} - -type Resource struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` - Endpoint string `protobuf:"bytes,3,opt,name=endpoint,proto3" json:"endpoint,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Resource) Reset() { *m = Resource{} } -func (m *Resource) String() string { return proto.CompactTextString(m) } -func (*Resource) ProtoMessage() {} -func (*Resource) Descriptor() ([]byte, []int) { - return fileDescriptor_21300bfacc51fc2a, []int{4} -} - -func (m *Resource) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Resource.Unmarshal(m, b) -} -func (m *Resource) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Resource.Marshal(b, m, deterministic) -} -func (m *Resource) XXX_Merge(src proto.Message) { - xxx_messageInfo_Resource.Merge(m, src) -} -func (m *Resource) XXX_Size() int { - return xxx_messageInfo_Resource.Size(m) -} -func (m *Resource) XXX_DiscardUnknown() { - xxx_messageInfo_Resource.DiscardUnknown(m) -} - -var xxx_messageInfo_Resource proto.InternalMessageInfo - -func (m *Resource) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *Resource) GetType() string { - if m != nil { - return m.Type - } - return "" -} - -func (m *Resource) GetEndpoint() string { - if m != nil { - return m.Endpoint - } - return "" -} - -type GenerateRequest struct { - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Metadata map[string]string `protobuf:"bytes,3,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - Scopes []string `protobuf:"bytes,4,rep,name=scopes,proto3" json:"scopes,omitempty"` - Secret string `protobuf:"bytes,5,opt,name=secret,proto3" json:"secret,omitempty"` - Type string `protobuf:"bytes,6,opt,name=type,proto3" json:"type,omitempty"` - Provider string `protobuf:"bytes,7,opt,name=provider,proto3" json:"provider,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GenerateRequest) Reset() { *m = GenerateRequest{} } -func (m *GenerateRequest) String() string { return proto.CompactTextString(m) } -func (*GenerateRequest) ProtoMessage() {} -func (*GenerateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_21300bfacc51fc2a, []int{5} -} - -func (m *GenerateRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GenerateRequest.Unmarshal(m, b) -} -func (m *GenerateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GenerateRequest.Marshal(b, m, deterministic) -} -func (m *GenerateRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GenerateRequest.Merge(m, src) -} -func (m *GenerateRequest) XXX_Size() int { - return xxx_messageInfo_GenerateRequest.Size(m) -} -func (m *GenerateRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GenerateRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GenerateRequest proto.InternalMessageInfo - -func (m *GenerateRequest) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -func (m *GenerateRequest) GetMetadata() map[string]string { - if m != nil { - return m.Metadata - } - return nil -} - -func (m *GenerateRequest) GetScopes() []string { - if m != nil { - return m.Scopes - } - return nil -} - -func (m *GenerateRequest) GetSecret() string { - if m != nil { - return m.Secret - } - return "" -} - -func (m *GenerateRequest) GetType() string { - if m != nil { - return m.Type - } - return "" -} - -func (m *GenerateRequest) GetProvider() string { - if m != nil { - return m.Provider - } - return "" -} - -type GenerateResponse struct { - Account *Account `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GenerateResponse) Reset() { *m = GenerateResponse{} } -func (m *GenerateResponse) String() string { return proto.CompactTextString(m) } -func (*GenerateResponse) ProtoMessage() {} -func (*GenerateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_21300bfacc51fc2a, []int{6} -} - -func (m *GenerateResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GenerateResponse.Unmarshal(m, b) -} -func (m *GenerateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GenerateResponse.Marshal(b, m, deterministic) -} -func (m *GenerateResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_GenerateResponse.Merge(m, src) -} -func (m *GenerateResponse) XXX_Size() int { - return xxx_messageInfo_GenerateResponse.Size(m) -} -func (m *GenerateResponse) XXX_DiscardUnknown() { - xxx_messageInfo_GenerateResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_GenerateResponse proto.InternalMessageInfo - -func (m *GenerateResponse) GetAccount() *Account { - if m != nil { - return m.Account - } - return nil -} - -type GrantRequest struct { - Scope string `protobuf:"bytes,1,opt,name=scope,proto3" json:"scope,omitempty"` - Resource *Resource `protobuf:"bytes,2,opt,name=resource,proto3" json:"resource,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GrantRequest) Reset() { *m = GrantRequest{} } -func (m *GrantRequest) String() string { return proto.CompactTextString(m) } -func (*GrantRequest) ProtoMessage() {} -func (*GrantRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_21300bfacc51fc2a, []int{7} -} - -func (m *GrantRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GrantRequest.Unmarshal(m, b) -} -func (m *GrantRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GrantRequest.Marshal(b, m, deterministic) -} -func (m *GrantRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GrantRequest.Merge(m, src) -} -func (m *GrantRequest) XXX_Size() int { - return xxx_messageInfo_GrantRequest.Size(m) -} -func (m *GrantRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GrantRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GrantRequest proto.InternalMessageInfo - -func (m *GrantRequest) GetScope() string { - if m != nil { - return m.Scope - } - return "" -} - -func (m *GrantRequest) GetResource() *Resource { - if m != nil { - return m.Resource - } - return nil -} - -type GrantResponse struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GrantResponse) Reset() { *m = GrantResponse{} } -func (m *GrantResponse) String() string { return proto.CompactTextString(m) } -func (*GrantResponse) ProtoMessage() {} -func (*GrantResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_21300bfacc51fc2a, []int{8} -} - -func (m *GrantResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GrantResponse.Unmarshal(m, b) -} -func (m *GrantResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GrantResponse.Marshal(b, m, deterministic) -} -func (m *GrantResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_GrantResponse.Merge(m, src) -} -func (m *GrantResponse) XXX_Size() int { - return xxx_messageInfo_GrantResponse.Size(m) -} -func (m *GrantResponse) XXX_DiscardUnknown() { - xxx_messageInfo_GrantResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_GrantResponse proto.InternalMessageInfo - -type RevokeRequest struct { - Scope string `protobuf:"bytes,1,opt,name=scope,proto3" json:"scope,omitempty"` - Resource *Resource `protobuf:"bytes,2,opt,name=resource,proto3" json:"resource,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *RevokeRequest) Reset() { *m = RevokeRequest{} } -func (m *RevokeRequest) String() string { return proto.CompactTextString(m) } -func (*RevokeRequest) ProtoMessage() {} -func (*RevokeRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_21300bfacc51fc2a, []int{9} -} - -func (m *RevokeRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_RevokeRequest.Unmarshal(m, b) -} -func (m *RevokeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_RevokeRequest.Marshal(b, m, deterministic) -} -func (m *RevokeRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_RevokeRequest.Merge(m, src) -} -func (m *RevokeRequest) XXX_Size() int { - return xxx_messageInfo_RevokeRequest.Size(m) -} -func (m *RevokeRequest) XXX_DiscardUnknown() { - xxx_messageInfo_RevokeRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_RevokeRequest proto.InternalMessageInfo - -func (m *RevokeRequest) GetScope() string { - if m != nil { - return m.Scope - } - return "" -} - -func (m *RevokeRequest) GetResource() *Resource { - if m != nil { - return m.Resource - } - return nil -} - -type RevokeResponse struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *RevokeResponse) Reset() { *m = RevokeResponse{} } -func (m *RevokeResponse) String() string { return proto.CompactTextString(m) } -func (*RevokeResponse) ProtoMessage() {} -func (*RevokeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_21300bfacc51fc2a, []int{10} -} - -func (m *RevokeResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_RevokeResponse.Unmarshal(m, b) -} -func (m *RevokeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_RevokeResponse.Marshal(b, m, deterministic) -} -func (m *RevokeResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_RevokeResponse.Merge(m, src) -} -func (m *RevokeResponse) XXX_Size() int { - return xxx_messageInfo_RevokeResponse.Size(m) -} -func (m *RevokeResponse) XXX_DiscardUnknown() { - xxx_messageInfo_RevokeResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_RevokeResponse proto.InternalMessageInfo - -type InspectRequest struct { - Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *InspectRequest) Reset() { *m = InspectRequest{} } -func (m *InspectRequest) String() string { return proto.CompactTextString(m) } -func (*InspectRequest) ProtoMessage() {} -func (*InspectRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_21300bfacc51fc2a, []int{11} -} - -func (m *InspectRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_InspectRequest.Unmarshal(m, b) -} -func (m *InspectRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_InspectRequest.Marshal(b, m, deterministic) -} -func (m *InspectRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_InspectRequest.Merge(m, src) -} -func (m *InspectRequest) XXX_Size() int { - return xxx_messageInfo_InspectRequest.Size(m) -} -func (m *InspectRequest) XXX_DiscardUnknown() { - xxx_messageInfo_InspectRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_InspectRequest proto.InternalMessageInfo - -func (m *InspectRequest) GetToken() string { - if m != nil { - return m.Token - } - return "" -} - -type InspectResponse struct { - Account *Account `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *InspectResponse) Reset() { *m = InspectResponse{} } -func (m *InspectResponse) String() string { return proto.CompactTextString(m) } -func (*InspectResponse) ProtoMessage() {} -func (*InspectResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_21300bfacc51fc2a, []int{12} -} - -func (m *InspectResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_InspectResponse.Unmarshal(m, b) -} -func (m *InspectResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_InspectResponse.Marshal(b, m, deterministic) -} -func (m *InspectResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_InspectResponse.Merge(m, src) -} -func (m *InspectResponse) XXX_Size() int { - return xxx_messageInfo_InspectResponse.Size(m) -} -func (m *InspectResponse) XXX_DiscardUnknown() { - xxx_messageInfo_InspectResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_InspectResponse proto.InternalMessageInfo - -func (m *InspectResponse) GetAccount() *Account { - if m != nil { - return m.Account - } - return nil -} - -type TokenRequest struct { - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Secret string `protobuf:"bytes,2,opt,name=secret,proto3" json:"secret,omitempty"` - RefreshToken string `protobuf:"bytes,3,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token,omitempty"` - TokenExpiry int64 `protobuf:"varint,4,opt,name=token_expiry,json=tokenExpiry,proto3" json:"token_expiry,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *TokenRequest) Reset() { *m = TokenRequest{} } -func (m *TokenRequest) String() string { return proto.CompactTextString(m) } -func (*TokenRequest) ProtoMessage() {} -func (*TokenRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_21300bfacc51fc2a, []int{13} -} - -func (m *TokenRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_TokenRequest.Unmarshal(m, b) -} -func (m *TokenRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_TokenRequest.Marshal(b, m, deterministic) -} -func (m *TokenRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_TokenRequest.Merge(m, src) -} -func (m *TokenRequest) XXX_Size() int { - return xxx_messageInfo_TokenRequest.Size(m) -} -func (m *TokenRequest) XXX_DiscardUnknown() { - xxx_messageInfo_TokenRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_TokenRequest proto.InternalMessageInfo - -func (m *TokenRequest) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -func (m *TokenRequest) GetSecret() string { - if m != nil { - return m.Secret - } - return "" -} - -func (m *TokenRequest) GetRefreshToken() string { - if m != nil { - return m.RefreshToken - } - return "" -} - -func (m *TokenRequest) GetTokenExpiry() int64 { - if m != nil { - return m.TokenExpiry - } - return 0 -} - -type TokenResponse struct { - Token *Token `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *TokenResponse) Reset() { *m = TokenResponse{} } -func (m *TokenResponse) String() string { return proto.CompactTextString(m) } -func (*TokenResponse) ProtoMessage() {} -func (*TokenResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_21300bfacc51fc2a, []int{14} -} - -func (m *TokenResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_TokenResponse.Unmarshal(m, b) -} -func (m *TokenResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_TokenResponse.Marshal(b, m, deterministic) -} -func (m *TokenResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_TokenResponse.Merge(m, src) -} -func (m *TokenResponse) XXX_Size() int { - return xxx_messageInfo_TokenResponse.Size(m) -} -func (m *TokenResponse) XXX_DiscardUnknown() { - xxx_messageInfo_TokenResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_TokenResponse proto.InternalMessageInfo - -func (m *TokenResponse) GetToken() *Token { - if m != nil { - return m.Token - } - return nil -} - -type Rule struct { - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Scope string `protobuf:"bytes,2,opt,name=scope,proto3" json:"scope,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:"-"` -} - -func (m *Rule) Reset() { *m = Rule{} } -func (m *Rule) String() string { return proto.CompactTextString(m) } -func (*Rule) ProtoMessage() {} -func (*Rule) Descriptor() ([]byte, []int) { - return fileDescriptor_21300bfacc51fc2a, []int{15} -} - -func (m *Rule) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Rule.Unmarshal(m, b) -} -func (m *Rule) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Rule.Marshal(b, m, deterministic) -} -func (m *Rule) XXX_Merge(src proto.Message) { - xxx_messageInfo_Rule.Merge(m, src) -} -func (m *Rule) XXX_Size() int { - return xxx_messageInfo_Rule.Size(m) -} -func (m *Rule) XXX_DiscardUnknown() { - xxx_messageInfo_Rule.DiscardUnknown(m) -} - -var xxx_messageInfo_Rule proto.InternalMessageInfo - -func (m *Rule) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -func (m *Rule) GetScope() string { - if m != nil { - return m.Scope - } - return "" -} - -func (m *Rule) GetResource() *Resource { - if m != nil { - return m.Resource - } - return nil -} - -func (m *Rule) GetAccess() Access { - if m != nil { - return m.Access - } - return Access_UNKNOWN -} - -func (m *Rule) GetPriority() int32 { - if m != nil { - return m.Priority - } - return 0 -} - -type CreateRequest struct { - Rule *Rule `protobuf:"bytes,1,opt,name=rule,proto3" json:"rule,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CreateRequest) Reset() { *m = CreateRequest{} } -func (m *CreateRequest) String() string { return proto.CompactTextString(m) } -func (*CreateRequest) ProtoMessage() {} -func (*CreateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_21300bfacc51fc2a, []int{16} -} - -func (m *CreateRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CreateRequest.Unmarshal(m, b) -} -func (m *CreateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CreateRequest.Marshal(b, m, deterministic) -} -func (m *CreateRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_CreateRequest.Merge(m, src) -} -func (m *CreateRequest) XXX_Size() int { - return xxx_messageInfo_CreateRequest.Size(m) -} -func (m *CreateRequest) XXX_DiscardUnknown() { - xxx_messageInfo_CreateRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_CreateRequest proto.InternalMessageInfo - -func (m *CreateRequest) GetRule() *Rule { - if m != nil { - return m.Rule - } - return nil -} - -type CreateResponse struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CreateResponse) Reset() { *m = CreateResponse{} } -func (m *CreateResponse) String() string { return proto.CompactTextString(m) } -func (*CreateResponse) ProtoMessage() {} -func (*CreateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_21300bfacc51fc2a, []int{17} -} - -func (m *CreateResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CreateResponse.Unmarshal(m, b) -} -func (m *CreateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CreateResponse.Marshal(b, m, deterministic) -} -func (m *CreateResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_CreateResponse.Merge(m, src) -} -func (m *CreateResponse) XXX_Size() int { - return xxx_messageInfo_CreateResponse.Size(m) -} -func (m *CreateResponse) XXX_DiscardUnknown() { - xxx_messageInfo_CreateResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_CreateResponse proto.InternalMessageInfo - -type DeleteRequest struct { - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DeleteRequest) Reset() { *m = DeleteRequest{} } -func (m *DeleteRequest) String() string { return proto.CompactTextString(m) } -func (*DeleteRequest) ProtoMessage() {} -func (*DeleteRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_21300bfacc51fc2a, []int{18} -} - -func (m *DeleteRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_DeleteRequest.Unmarshal(m, b) -} -func (m *DeleteRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_DeleteRequest.Marshal(b, m, deterministic) -} -func (m *DeleteRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeleteRequest.Merge(m, src) -} -func (m *DeleteRequest) XXX_Size() int { - return xxx_messageInfo_DeleteRequest.Size(m) -} -func (m *DeleteRequest) XXX_DiscardUnknown() { - xxx_messageInfo_DeleteRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_DeleteRequest proto.InternalMessageInfo - -func (m *DeleteRequest) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -type DeleteResponse struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DeleteResponse) Reset() { *m = DeleteResponse{} } -func (m *DeleteResponse) String() string { return proto.CompactTextString(m) } -func (*DeleteResponse) ProtoMessage() {} -func (*DeleteResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_21300bfacc51fc2a, []int{19} -} - -func (m *DeleteResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_DeleteResponse.Unmarshal(m, b) -} -func (m *DeleteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_DeleteResponse.Marshal(b, m, deterministic) -} -func (m *DeleteResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeleteResponse.Merge(m, src) -} -func (m *DeleteResponse) XXX_Size() int { - return xxx_messageInfo_DeleteResponse.Size(m) -} -func (m *DeleteResponse) XXX_DiscardUnknown() { - xxx_messageInfo_DeleteResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_DeleteResponse proto.InternalMessageInfo - -type ListRequest struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListRequest) Reset() { *m = ListRequest{} } -func (m *ListRequest) String() string { return proto.CompactTextString(m) } -func (*ListRequest) ProtoMessage() {} -func (*ListRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_21300bfacc51fc2a, []int{20} -} - -func (m *ListRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListRequest.Unmarshal(m, b) -} -func (m *ListRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListRequest.Marshal(b, m, deterministic) -} -func (m *ListRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListRequest.Merge(m, src) -} -func (m *ListRequest) XXX_Size() int { - return xxx_messageInfo_ListRequest.Size(m) -} -func (m *ListRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ListRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ListRequest proto.InternalMessageInfo - -type ListResponse struct { - Rules []*Rule `protobuf:"bytes,1,rep,name=rules,proto3" json:"rules,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListResponse) Reset() { *m = ListResponse{} } -func (m *ListResponse) String() string { return proto.CompactTextString(m) } -func (*ListResponse) ProtoMessage() {} -func (*ListResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_21300bfacc51fc2a, []int{21} -} - -func (m *ListResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListResponse.Unmarshal(m, b) -} -func (m *ListResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListResponse.Marshal(b, m, deterministic) -} -func (m *ListResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListResponse.Merge(m, src) -} -func (m *ListResponse) XXX_Size() int { - return xxx_messageInfo_ListResponse.Size(m) -} -func (m *ListResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ListResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_ListResponse proto.InternalMessageInfo - -func (m *ListResponse) GetRules() []*Rule { - if m != nil { - return m.Rules - } - return nil -} - -func init() { - proto.RegisterEnum("go.micro.auth.Access", Access_name, Access_value) - proto.RegisterType((*ListAccountsRequest)(nil), "go.micro.auth.ListAccountsRequest") - proto.RegisterType((*ListAccountsResponse)(nil), "go.micro.auth.ListAccountsResponse") - proto.RegisterType((*Token)(nil), "go.micro.auth.Token") - proto.RegisterType((*Account)(nil), "go.micro.auth.Account") - proto.RegisterMapType((map[string]string)(nil), "go.micro.auth.Account.MetadataEntry") - proto.RegisterType((*Resource)(nil), "go.micro.auth.Resource") - proto.RegisterType((*GenerateRequest)(nil), "go.micro.auth.GenerateRequest") - proto.RegisterMapType((map[string]string)(nil), "go.micro.auth.GenerateRequest.MetadataEntry") - proto.RegisterType((*GenerateResponse)(nil), "go.micro.auth.GenerateResponse") - proto.RegisterType((*GrantRequest)(nil), "go.micro.auth.GrantRequest") - proto.RegisterType((*GrantResponse)(nil), "go.micro.auth.GrantResponse") - proto.RegisterType((*RevokeRequest)(nil), "go.micro.auth.RevokeRequest") - proto.RegisterType((*RevokeResponse)(nil), "go.micro.auth.RevokeResponse") - proto.RegisterType((*InspectRequest)(nil), "go.micro.auth.InspectRequest") - proto.RegisterType((*InspectResponse)(nil), "go.micro.auth.InspectResponse") - proto.RegisterType((*TokenRequest)(nil), "go.micro.auth.TokenRequest") - proto.RegisterType((*TokenResponse)(nil), "go.micro.auth.TokenResponse") - proto.RegisterType((*Rule)(nil), "go.micro.auth.Rule") - proto.RegisterType((*CreateRequest)(nil), "go.micro.auth.CreateRequest") - proto.RegisterType((*CreateResponse)(nil), "go.micro.auth.CreateResponse") - proto.RegisterType((*DeleteRequest)(nil), "go.micro.auth.DeleteRequest") - proto.RegisterType((*DeleteResponse)(nil), "go.micro.auth.DeleteResponse") - proto.RegisterType((*ListRequest)(nil), "go.micro.auth.ListRequest") - proto.RegisterType((*ListResponse)(nil), "go.micro.auth.ListResponse") -} - -func init() { proto.RegisterFile("auth/service/proto/auth.proto", fileDescriptor_21300bfacc51fc2a) } - -var fileDescriptor_21300bfacc51fc2a = []byte{ - // 872 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x51, 0x8f, 0xdb, 0x44, - 0x10, 0x3e, 0x27, 0xb1, 0x93, 0x9b, 0xc4, 0x77, 0xd1, 0xf6, 0x5a, 0xac, 0x94, 0x6b, 0xaf, 0x2e, - 0x82, 0xa3, 0x82, 0x1c, 0x4a, 0x5f, 0x0a, 0x7d, 0xe1, 0xd4, 0x44, 0xa1, 0x85, 0x06, 0x61, 0x15, - 0x21, 0x90, 0x50, 0x65, 0x9c, 0x81, 0xb3, 0x2e, 0x67, 0x9b, 0xdd, 0xf5, 0x89, 0xbc, 0x20, 0xf1, - 0xc6, 0x8f, 0xe1, 0x27, 0xf1, 0xce, 0x1f, 0xe0, 0x07, 0x20, 0xef, 0xce, 0xba, 0xb1, 0xe3, 0x54, - 0x15, 0x88, 0x37, 0xcf, 0xec, 0xb7, 0xb3, 0xf3, 0x7d, 0x3b, 0x33, 0x6b, 0x38, 0x0e, 0x73, 0x79, - 0x71, 0x26, 0x90, 0x5f, 0xc7, 0x11, 0x9e, 0x65, 0x3c, 0x95, 0xe9, 0x59, 0xe1, 0x1a, 0xab, 0x4f, - 0xe6, 0xfe, 0x94, 0x8e, 0xaf, 0xe2, 0x88, 0xa7, 0xe3, 0xc2, 0xe9, 0xdf, 0x84, 0x1b, 0x5f, 0xc4, - 0x42, 0x9e, 0x47, 0x51, 0x9a, 0x27, 0x52, 0x04, 0xf8, 0x73, 0x8e, 0x42, 0xfa, 0xcf, 0xe0, 0xa8, - 0xea, 0x16, 0x59, 0x9a, 0x08, 0x64, 0x13, 0xe8, 0x85, 0xe4, 0xf3, 0xac, 0x93, 0xf6, 0x69, 0x7f, - 0x72, 0x6b, 0x5c, 0x09, 0x38, 0xa6, 0x2d, 0x41, 0x89, 0xf3, 0x7f, 0xb3, 0xc0, 0x7e, 0x91, 0x5e, - 0x62, 0xc2, 0xee, 0xc1, 0x20, 0x8c, 0x22, 0x14, 0xe2, 0xa5, 0x2c, 0x6c, 0xcf, 0x3a, 0xb1, 0x4e, - 0xf7, 0x83, 0xbe, 0xf6, 0x69, 0xc8, 0x7d, 0x70, 0x39, 0xfe, 0xc8, 0x51, 0x5c, 0x10, 0xa6, 0xa5, - 0x30, 0x03, 0x72, 0x6a, 0x90, 0x07, 0xdd, 0x88, 0x63, 0x28, 0x71, 0xe9, 0xb5, 0x4f, 0xac, 0xd3, - 0x76, 0x60, 0x4c, 0x76, 0x0b, 0x1c, 0xfc, 0x25, 0x8b, 0xf9, 0xda, 0xeb, 0xa8, 0x05, 0xb2, 0xfc, - 0xbf, 0x2d, 0xe8, 0x52, 0x66, 0xec, 0x00, 0x5a, 0xf1, 0x92, 0xce, 0x6e, 0xc5, 0x4b, 0xc6, 0xa0, - 0x23, 0xd7, 0x19, 0xd2, 0x49, 0xea, 0x9b, 0x7d, 0x0a, 0xbd, 0x2b, 0x94, 0xe1, 0x32, 0x94, 0xa1, - 0xd7, 0x51, 0x3c, 0xdf, 0x69, 0xe6, 0x39, 0x7e, 0x4e, 0xb0, 0x59, 0x22, 0xf9, 0x3a, 0x28, 0x77, - 0x15, 0x99, 0x88, 0x28, 0xcd, 0x50, 0x78, 0xf6, 0x49, 0xfb, 0x74, 0x3f, 0x20, 0xab, 0xf0, 0xc7, - 0x42, 0xe4, 0xc8, 0x3d, 0x47, 0x9d, 0x47, 0x96, 0xc2, 0x63, 0xc4, 0x51, 0x7a, 0x5d, 0xed, 0xd7, - 0xd6, 0xe8, 0x31, 0xb8, 0x95, 0x23, 0xd8, 0x10, 0xda, 0x97, 0xb8, 0xa6, 0xfc, 0x8b, 0x4f, 0x76, - 0x04, 0xf6, 0x75, 0xb8, 0xca, 0x0d, 0x03, 0x6d, 0x7c, 0xd2, 0x7a, 0x64, 0xf9, 0x0b, 0xe8, 0x05, - 0x28, 0xd2, 0x9c, 0x47, 0x58, 0xd0, 0x4c, 0xc2, 0x2b, 0xa4, 0x8d, 0xea, 0xbb, 0x91, 0xfa, 0x08, - 0x7a, 0x98, 0x2c, 0xb3, 0x34, 0x4e, 0xa4, 0x52, 0x77, 0x3f, 0x28, 0x6d, 0xff, 0xf7, 0x16, 0x1c, - 0xce, 0x31, 0x41, 0x1e, 0x4a, 0xa4, 0x52, 0xd9, 0x92, 0xf3, 0xb3, 0x0d, 0xe9, 0xda, 0x4a, 0xba, - 0x0f, 0x6a, 0xd2, 0xd5, 0x22, 0xbc, 0x81, 0x84, 0x9d, 0xba, 0x84, 0x24, 0x95, 0xbd, 0x29, 0x55, - 0xc9, 0xc6, 0xa9, 0xb2, 0xc9, 0x78, 0x7a, 0x1d, 0x2f, 0x91, 0x93, 0xb0, 0xa5, 0xfd, 0xdf, 0xa4, - 0x9d, 0xc2, 0xf0, 0x15, 0x0f, 0xea, 0x8e, 0x8f, 0xa0, 0x4b, 0x55, 0xaf, 0x62, 0xec, 0x6e, 0x0e, - 0x03, 0xf3, 0xbf, 0x85, 0xc1, 0x9c, 0x87, 0x89, 0x34, 0x62, 0x1e, 0x81, 0xad, 0x48, 0x52, 0x0e, - 0xda, 0x60, 0x0f, 0xa1, 0xc7, 0xe9, 0x1a, 0x55, 0x22, 0xfd, 0xc9, 0x5b, 0xb5, 0xc0, 0xe6, 0x96, - 0x83, 0x12, 0xe8, 0x1f, 0x82, 0x4b, 0xa1, 0x75, 0x76, 0xfe, 0x77, 0xe0, 0x06, 0x78, 0x9d, 0x5e, - 0xe2, 0xff, 0x70, 0xd8, 0x10, 0x0e, 0x4c, 0x6c, 0x3a, 0xed, 0x5d, 0x38, 0x78, 0x9a, 0x88, 0x0c, - 0xa3, 0x4d, 0x6e, 0x9b, 0x6d, 0xaf, 0x0d, 0xff, 0x09, 0x1c, 0x96, 0xb8, 0x7f, 0x2d, 0xe3, 0xaf, - 0x30, 0x50, 0x93, 0x61, 0x57, 0x4d, 0xbe, 0xaa, 0x98, 0x56, 0xa5, 0x62, 0xb6, 0xa6, 0x4d, 0xbb, - 0x61, 0xda, 0xdc, 0x83, 0x81, 0x5a, 0x7c, 0x59, 0x99, 0x2c, 0x7d, 0xe5, 0x9b, 0xe9, 0xf1, 0xf2, - 0x18, 0x5c, 0x3a, 0x9f, 0x28, 0x3c, 0xd8, 0xe4, 0xda, 0x9f, 0x1c, 0xd5, 0x08, 0x68, 0x30, 0x29, - 0xf0, 0x87, 0x05, 0x9d, 0x20, 0x5f, 0xe1, 0x56, 0xd6, 0xe5, 0xfd, 0xb4, 0x76, 0xdd, 0x4f, 0xfb, - 0x0d, 0xef, 0x87, 0x7d, 0x08, 0x8e, 0x9e, 0xb2, 0x2a, 0xfb, 0x83, 0xc9, 0xcd, 0x6d, 0x45, 0x51, - 0x88, 0x80, 0x40, 0xba, 0x6b, 0xe2, 0x94, 0xc7, 0x72, 0xad, 0x7a, 0xcc, 0x0e, 0x4a, 0xdb, 0x7f, - 0x04, 0xee, 0x13, 0x35, 0x6d, 0x8d, 0xd8, 0xef, 0x41, 0x87, 0xe7, 0x2b, 0x24, 0xaa, 0x37, 0xea, - 0xc9, 0xe4, 0x2b, 0x0c, 0x14, 0xa0, 0x28, 0x12, 0xb3, 0x93, 0x8a, 0xe4, 0x2e, 0xb8, 0x53, 0x5c, - 0xe1, 0xce, 0x61, 0x52, 0x6c, 0x31, 0x00, 0xda, 0xe2, 0x42, 0xbf, 0x78, 0x99, 0xcc, 0x43, 0xf5, - 0x31, 0x0c, 0xb4, 0x49, 0xc2, 0xbf, 0x0f, 0x76, 0x71, 0x96, 0x79, 0x9d, 0x1a, 0xb3, 0xd1, 0x88, - 0x07, 0x63, 0x70, 0x34, 0x6d, 0xd6, 0x87, 0xee, 0xd7, 0x8b, 0xcf, 0x17, 0x5f, 0x7e, 0xb3, 0x18, - 0xee, 0x15, 0xc6, 0x3c, 0x38, 0x5f, 0xbc, 0x98, 0x4d, 0x87, 0x16, 0x03, 0x70, 0xa6, 0xb3, 0xc5, - 0xd3, 0xd9, 0x74, 0xd8, 0x9a, 0xfc, 0x65, 0x41, 0xe7, 0x3c, 0x97, 0x17, 0xec, 0x39, 0xf4, 0x4c, - 0xeb, 0xb3, 0x3b, 0xaf, 0x9f, 0x6d, 0xa3, 0xbb, 0x3b, 0xd7, 0x89, 0xcf, 0x1e, 0x7b, 0x06, 0x5d, - 0xea, 0x00, 0x76, 0x5c, 0x43, 0x57, 0x3b, 0x68, 0x74, 0x67, 0xd7, 0x72, 0x19, 0x6b, 0x6a, 0x9e, - 0xda, 0xdb, 0x8d, 0x15, 0x47, 0x71, 0xde, 0x6e, 0x5e, 0x34, 0x51, 0x26, 0xdf, 0x43, 0xcf, 0xbc, - 0xfc, 0xec, 0x2b, 0xe8, 0x14, 0x02, 0x33, 0xbf, 0xb6, 0xa7, 0xe1, 0xaf, 0x61, 0x74, 0xff, 0xb5, - 0x98, 0x32, 0xfc, 0x9f, 0x16, 0xd8, 0xc5, 0x45, 0x08, 0x36, 0x07, 0x47, 0x57, 0x04, 0xab, 0xa7, - 0x54, 0x29, 0xb1, 0xd1, 0xf1, 0x8e, 0xd5, 0x92, 0xf7, 0x1c, 0x1c, 0x5d, 0x27, 0x5b, 0x81, 0x2a, - 0xf5, 0xb5, 0x15, 0xa8, 0x56, 0x5c, 0x7b, 0xec, 0x9c, 0xe8, 0x8e, 0x1a, 0xa8, 0x98, 0x20, 0xb7, - 0x1b, 0xd7, 0x4c, 0x88, 0x1f, 0x1c, 0xf5, 0xa3, 0xf5, 0xf0, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, - 0x52, 0x12, 0xc2, 0xdb, 0x89, 0x09, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// AuthClient is the client API for Auth service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type AuthClient interface { - Generate(ctx context.Context, in *GenerateRequest, opts ...grpc.CallOption) (*GenerateResponse, error) - Inspect(ctx context.Context, in *InspectRequest, opts ...grpc.CallOption) (*InspectResponse, error) - Token(ctx context.Context, in *TokenRequest, opts ...grpc.CallOption) (*TokenResponse, error) -} - -type authClient struct { - cc *grpc.ClientConn -} - -func NewAuthClient(cc *grpc.ClientConn) AuthClient { - return &authClient{cc} -} - -func (c *authClient) Generate(ctx context.Context, in *GenerateRequest, opts ...grpc.CallOption) (*GenerateResponse, error) { - out := new(GenerateResponse) - err := c.cc.Invoke(ctx, "/go.micro.auth.Auth/Generate", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *authClient) Inspect(ctx context.Context, in *InspectRequest, opts ...grpc.CallOption) (*InspectResponse, error) { - out := new(InspectResponse) - err := c.cc.Invoke(ctx, "/go.micro.auth.Auth/Inspect", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *authClient) Token(ctx context.Context, in *TokenRequest, opts ...grpc.CallOption) (*TokenResponse, error) { - out := new(TokenResponse) - err := c.cc.Invoke(ctx, "/go.micro.auth.Auth/Token", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// AuthServer is the server API for Auth service. -type AuthServer interface { - Generate(context.Context, *GenerateRequest) (*GenerateResponse, error) - Inspect(context.Context, *InspectRequest) (*InspectResponse, error) - Token(context.Context, *TokenRequest) (*TokenResponse, error) -} - -// UnimplementedAuthServer can be embedded to have forward compatible implementations. -type UnimplementedAuthServer struct { -} - -func (*UnimplementedAuthServer) Generate(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Generate not implemented") -} -func (*UnimplementedAuthServer) Inspect(ctx context.Context, req *InspectRequest) (*InspectResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Inspect not implemented") -} -func (*UnimplementedAuthServer) Token(ctx context.Context, req *TokenRequest) (*TokenResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Token not implemented") -} - -func RegisterAuthServer(s *grpc.Server, srv AuthServer) { - s.RegisterService(&_Auth_serviceDesc, srv) -} - -func _Auth_Generate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GenerateRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(AuthServer).Generate(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/go.micro.auth.Auth/Generate", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AuthServer).Generate(ctx, req.(*GenerateRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Auth_Inspect_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(InspectRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(AuthServer).Inspect(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/go.micro.auth.Auth/Inspect", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AuthServer).Inspect(ctx, req.(*InspectRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Auth_Token_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(TokenRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(AuthServer).Token(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/go.micro.auth.Auth/Token", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AuthServer).Token(ctx, req.(*TokenRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Auth_serviceDesc = grpc.ServiceDesc{ - ServiceName: "go.micro.auth.Auth", - HandlerType: (*AuthServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Generate", - Handler: _Auth_Generate_Handler, - }, - { - MethodName: "Inspect", - Handler: _Auth_Inspect_Handler, - }, - { - MethodName: "Token", - Handler: _Auth_Token_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "auth/service/proto/auth.proto", -} - -// AccountsClient is the client API for Accounts service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type AccountsClient interface { - List(ctx context.Context, in *ListAccountsRequest, opts ...grpc.CallOption) (*ListAccountsResponse, error) -} - -type accountsClient struct { - cc *grpc.ClientConn -} - -func NewAccountsClient(cc *grpc.ClientConn) AccountsClient { - return &accountsClient{cc} -} - -func (c *accountsClient) List(ctx context.Context, in *ListAccountsRequest, opts ...grpc.CallOption) (*ListAccountsResponse, error) { - out := new(ListAccountsResponse) - err := c.cc.Invoke(ctx, "/go.micro.auth.Accounts/List", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// AccountsServer is the server API for Accounts service. -type AccountsServer interface { - List(context.Context, *ListAccountsRequest) (*ListAccountsResponse, error) -} - -// UnimplementedAccountsServer can be embedded to have forward compatible implementations. -type UnimplementedAccountsServer struct { -} - -func (*UnimplementedAccountsServer) List(ctx context.Context, req *ListAccountsRequest) (*ListAccountsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method List not implemented") -} - -func RegisterAccountsServer(s *grpc.Server, srv AccountsServer) { - s.RegisterService(&_Accounts_serviceDesc, srv) -} - -func _Accounts_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListAccountsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(AccountsServer).List(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/go.micro.auth.Accounts/List", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AccountsServer).List(ctx, req.(*ListAccountsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Accounts_serviceDesc = grpc.ServiceDesc{ - ServiceName: "go.micro.auth.Accounts", - HandlerType: (*AccountsServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "List", - Handler: _Accounts_List_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "auth/service/proto/auth.proto", -} - -// RulesClient is the client API for Rules service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type RulesClient interface { - Create(ctx context.Context, in *CreateRequest, opts ...grpc.CallOption) (*CreateResponse, error) - Delete(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*DeleteResponse, error) - List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) -} - -type rulesClient struct { - cc *grpc.ClientConn -} - -func NewRulesClient(cc *grpc.ClientConn) RulesClient { - return &rulesClient{cc} -} - -func (c *rulesClient) Create(ctx context.Context, in *CreateRequest, opts ...grpc.CallOption) (*CreateResponse, error) { - out := new(CreateResponse) - err := c.cc.Invoke(ctx, "/go.micro.auth.Rules/Create", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *rulesClient) Delete(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*DeleteResponse, error) { - out := new(DeleteResponse) - err := c.cc.Invoke(ctx, "/go.micro.auth.Rules/Delete", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *rulesClient) List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) { - out := new(ListResponse) - err := c.cc.Invoke(ctx, "/go.micro.auth.Rules/List", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// RulesServer is the server API for Rules service. -type RulesServer interface { - Create(context.Context, *CreateRequest) (*CreateResponse, error) - Delete(context.Context, *DeleteRequest) (*DeleteResponse, error) - List(context.Context, *ListRequest) (*ListResponse, error) -} - -// UnimplementedRulesServer can be embedded to have forward compatible implementations. -type UnimplementedRulesServer struct { -} - -func (*UnimplementedRulesServer) Create(ctx context.Context, req *CreateRequest) (*CreateResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Create not implemented") -} -func (*UnimplementedRulesServer) Delete(ctx context.Context, req *DeleteRequest) (*DeleteResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented") -} -func (*UnimplementedRulesServer) List(ctx context.Context, req *ListRequest) (*ListResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method List not implemented") -} - -func RegisterRulesServer(s *grpc.Server, srv RulesServer) { - s.RegisterService(&_Rules_serviceDesc, srv) -} - -func _Rules_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RulesServer).Create(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/go.micro.auth.Rules/Create", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RulesServer).Create(ctx, req.(*CreateRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Rules_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeleteRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RulesServer).Delete(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/go.micro.auth.Rules/Delete", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RulesServer).Delete(ctx, req.(*DeleteRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Rules_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RulesServer).List(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/go.micro.auth.Rules/List", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RulesServer).List(ctx, req.(*ListRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Rules_serviceDesc = grpc.ServiceDesc{ - ServiceName: "go.micro.auth.Rules", - HandlerType: (*RulesServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Create", - Handler: _Rules_Create_Handler, - }, - { - MethodName: "Delete", - Handler: _Rules_Delete_Handler, - }, - { - MethodName: "List", - Handler: _Rules_List_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "auth/service/proto/auth.proto", -} diff --git a/auth/service/proto/auth.pb.micro.go b/auth/service/proto/auth.pb.micro.go deleted file mode 100644 index 0fcdaf74..00000000 --- a/auth/service/proto/auth.pb.micro.go +++ /dev/null @@ -1,279 +0,0 @@ -// Code generated by protoc-gen-micro. DO NOT EDIT. -// source: auth/service/proto/auth.proto - -package go_micro_auth - -import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" - math "math" -) - -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" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -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 { - Generate(ctx context.Context, in *GenerateRequest, opts ...client.CallOption) (*GenerateResponse, error) - Inspect(ctx context.Context, in *InspectRequest, opts ...client.CallOption) (*InspectResponse, error) - Token(ctx context.Context, in *TokenRequest, opts ...client.CallOption) (*TokenResponse, error) -} - -type authService struct { - c client.Client - name string -} - -func NewAuthService(name string, c client.Client) AuthService { - return &authService{ - c: c, - name: name, - } -} - -func (c *authService) Generate(ctx context.Context, in *GenerateRequest, opts ...client.CallOption) (*GenerateResponse, error) { - req := c.c.NewRequest(c.name, "Auth.Generate", in) - out := new(GenerateResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *authService) Inspect(ctx context.Context, in *InspectRequest, opts ...client.CallOption) (*InspectResponse, error) { - req := c.c.NewRequest(c.name, "Auth.Inspect", in) - out := new(InspectResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *authService) Token(ctx context.Context, in *TokenRequest, opts ...client.CallOption) (*TokenResponse, error) { - req := c.c.NewRequest(c.name, "Auth.Token", in) - out := new(TokenResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// Server API for Auth service - -type AuthHandler interface { - Generate(context.Context, *GenerateRequest, *GenerateResponse) error - Inspect(context.Context, *InspectRequest, *InspectResponse) error - Token(context.Context, *TokenRequest, *TokenResponse) error -} - -func RegisterAuthHandler(s server.Server, hdlr AuthHandler, opts ...server.HandlerOption) error { - type auth interface { - Generate(ctx context.Context, in *GenerateRequest, out *GenerateResponse) error - Inspect(ctx context.Context, in *InspectRequest, out *InspectResponse) error - Token(ctx context.Context, in *TokenRequest, out *TokenResponse) error - } - type Auth struct { - auth - } - h := &authHandler{hdlr} - return s.Handle(s.NewHandler(&Auth{h}, opts...)) -} - -type authHandler struct { - AuthHandler -} - -func (h *authHandler) Generate(ctx context.Context, in *GenerateRequest, out *GenerateResponse) error { - return h.AuthHandler.Generate(ctx, in, out) -} - -func (h *authHandler) Inspect(ctx context.Context, in *InspectRequest, out *InspectResponse) error { - return h.AuthHandler.Inspect(ctx, in, out) -} - -func (h *authHandler) Token(ctx context.Context, in *TokenRequest, out *TokenResponse) error { - 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 { - List(ctx context.Context, in *ListAccountsRequest, opts ...client.CallOption) (*ListAccountsResponse, error) -} - -type accountsService struct { - c client.Client - name string -} - -func NewAccountsService(name string, c client.Client) AccountsService { - return &accountsService{ - c: c, - name: name, - } -} - -func (c *accountsService) List(ctx context.Context, in *ListAccountsRequest, opts ...client.CallOption) (*ListAccountsResponse, error) { - req := c.c.NewRequest(c.name, "Accounts.List", in) - out := new(ListAccountsResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// Server API for Accounts service - -type AccountsHandler interface { - List(context.Context, *ListAccountsRequest, *ListAccountsResponse) error -} - -func RegisterAccountsHandler(s server.Server, hdlr AccountsHandler, opts ...server.HandlerOption) error { - type accounts interface { - List(ctx context.Context, in *ListAccountsRequest, out *ListAccountsResponse) error - } - type Accounts struct { - accounts - } - h := &accountsHandler{hdlr} - return s.Handle(s.NewHandler(&Accounts{h}, opts...)) -} - -type accountsHandler struct { - AccountsHandler -} - -func (h *accountsHandler) List(ctx context.Context, in *ListAccountsRequest, out *ListAccountsResponse) error { - 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 { - Create(ctx context.Context, in *CreateRequest, opts ...client.CallOption) (*CreateResponse, error) - Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error) - List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) -} - -type rulesService struct { - c client.Client - name string -} - -func NewRulesService(name string, c client.Client) RulesService { - return &rulesService{ - c: c, - name: name, - } -} - -func (c *rulesService) Create(ctx context.Context, in *CreateRequest, opts ...client.CallOption) (*CreateResponse, error) { - req := c.c.NewRequest(c.name, "Rules.Create", in) - out := new(CreateResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *rulesService) Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error) { - req := c.c.NewRequest(c.name, "Rules.Delete", in) - out := new(DeleteResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *rulesService) List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) { - req := c.c.NewRequest(c.name, "Rules.List", in) - out := new(ListResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// Server API for Rules service - -type RulesHandler interface { - Create(context.Context, *CreateRequest, *CreateResponse) error - Delete(context.Context, *DeleteRequest, *DeleteResponse) error - List(context.Context, *ListRequest, *ListResponse) error -} - -func RegisterRulesHandler(s server.Server, hdlr RulesHandler, opts ...server.HandlerOption) error { - type rules interface { - Create(ctx context.Context, in *CreateRequest, out *CreateResponse) error - Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error - List(ctx context.Context, in *ListRequest, out *ListResponse) error - } - type Rules struct { - rules - } - h := &rulesHandler{hdlr} - return s.Handle(s.NewHandler(&Rules{h}, opts...)) -} - -type rulesHandler struct { - RulesHandler -} - -func (h *rulesHandler) Create(ctx context.Context, in *CreateRequest, out *CreateResponse) error { - return h.RulesHandler.Create(ctx, in, out) -} - -func (h *rulesHandler) Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error { - return h.RulesHandler.Delete(ctx, in, out) -} - -func (h *rulesHandler) List(ctx context.Context, in *ListRequest, out *ListResponse) error { - return h.RulesHandler.List(ctx, in, out) -} diff --git a/auth/service/proto/auth.proto b/auth/service/proto/auth.proto deleted file mode 100644 index 5eb1d667..00000000 --- a/auth/service/proto/auth.proto +++ /dev/null @@ -1,127 +0,0 @@ -syntax = "proto3"; - -package go.micro.auth; - -service Auth { - rpc Generate(GenerateRequest) returns (GenerateResponse) {}; - rpc Inspect(InspectRequest) returns (InspectResponse) {}; - rpc Token(TokenRequest) returns (TokenResponse) {}; -} - -service Accounts { - rpc List(ListAccountsRequest) returns (ListAccountsResponse) {}; -} - -service Rules { - rpc Create(CreateRequest) returns (CreateResponse) {}; - rpc Delete(DeleteRequest) returns (DeleteResponse) {}; - rpc List(ListRequest) returns (ListResponse) {}; -} - -message ListAccountsRequest { -} - -message ListAccountsResponse { - repeated Account accounts = 1; -} - -message Token { - string access_token = 1; - string refresh_token = 2; - int64 created = 3; - int64 expiry = 4; -} - -message Account { - string id = 1; - string type = 2; - map metadata = 4; - repeated string scopes = 5; - string issuer = 6; - string secret = 7; -} - -message Resource{ - string name = 1; - string type = 2; - string endpoint = 3; -} - -message GenerateRequest { - string id = 1; - map metadata = 3; - repeated string scopes = 4; - string secret = 5; - string type = 6; - string provider = 7; -} - -message GenerateResponse { - Account account = 1; -} - -message GrantRequest { - string scope = 1; - Resource resource = 2; -} - -message GrantResponse {} - -message RevokeRequest { - string scope = 1; - Resource resource = 2; -} - -message RevokeResponse {} - -message InspectRequest { - string token = 1; -} - -message InspectResponse { - Account account = 1; -} - -message TokenRequest { - string id = 1; - string secret = 2; - string refresh_token = 3; - int64 token_expiry = 4; -} - -message TokenResponse { - Token token = 1; -} - -enum Access { - UNKNOWN = 0; - GRANTED = 1; - DENIED = 2; -} - -message Rule { - string id = 1; - string scope = 2; - Resource resource = 3; - Access access = 4; - int32 priority = 5; -} - -message CreateRequest { - Rule rule = 1; -} - -message CreateResponse {} - -message DeleteRequest { - string id = 1; -} - -message DeleteResponse {} - -message ListRequest { -} - -message ListResponse { - repeated Rule rules = 1; -} diff --git a/auth/service/service.go b/auth/service/service.go deleted file mode 100644 index 9c3bd323..00000000 --- a/auth/service/service.go +++ /dev/null @@ -1,228 +0,0 @@ -package service - -import ( - "context" - "strings" - "time" - - "github.com/micro/go-micro/v2/auth" - "github.com/micro/go-micro/v2/auth/rules" - pb "github.com/micro/go-micro/v2/auth/service/proto" - "github.com/micro/go-micro/v2/auth/token" - "github.com/micro/go-micro/v2/auth/token/jwt" - "github.com/micro/go-micro/v2/client" -) - -// svc is the service implementation of the Auth interface -type svc struct { - options auth.Options - auth pb.AuthService - rules pb.RulesService - jwt token.Provider -} - -func (s *svc) String() string { - return "service" -} - -func (s *svc) Init(opts ...auth.Option) { - for _, o := range opts { - o(&s.options) - } - - if s.options.Client == nil { - s.options.Client = client.DefaultClient - } - - s.auth = pb.NewAuthService("go.micro.auth", s.options.Client) - s.rules = pb.NewRulesService("go.micro.auth", s.options.Client) - - // if we have a JWT public key passed as an option, - // we can decode tokens with the type "JWT" locally - // and not have to make an RPC call - if key := s.options.PublicKey; len(key) > 0 { - s.jwt = jwt.NewTokenProvider(token.WithPublicKey(key)) - } -} - -func (s *svc) Options() auth.Options { - return s.options -} - -// Generate a new account -func (s *svc) Generate(id string, opts ...auth.GenerateOption) (*auth.Account, error) { - options := auth.NewGenerateOptions(opts...) - - rsp, err := s.auth.Generate(context.TODO(), &pb.GenerateRequest{ - Id: id, - Type: options.Type, - Secret: options.Secret, - Scopes: options.Scopes, - Metadata: options.Metadata, - Provider: options.Provider, - }) - if err != nil { - return nil, err - } - - return serializeAccount(rsp.Account), nil -} - -// Grant access to a resource -func (s *svc) Grant(rule *auth.Rule) error { - access := pb.Access_UNKNOWN - if rule.Access == auth.AccessGranted { - access = pb.Access_GRANTED - } else if rule.Access == auth.AccessDenied { - access = pb.Access_DENIED - } - - _, err := s.rules.Create(context.TODO(), &pb.CreateRequest{ - Rule: &pb.Rule{ - Id: rule.ID, - Scope: rule.Scope, - Priority: rule.Priority, - Access: access, - Resource: &pb.Resource{ - Type: rule.Resource.Type, - Name: rule.Resource.Name, - Endpoint: rule.Resource.Endpoint, - }, - }, - }) - - return err -} - -// Revoke access to a resource -func (s *svc) Revoke(rule *auth.Rule) error { - _, err := s.rules.Delete(context.TODO(), &pb.DeleteRequest{ - Id: rule.ID, - }) - - return err -} - -func (s *svc) Rules(opts ...auth.RulesOption) ([]*auth.Rule, error) { - var options auth.RulesOptions - for _, o := range opts { - o(&options) - } - if options.Context == nil { - options.Context = context.TODO() - } - - rsp, err := s.rules.List(options.Context, &pb.ListRequest{}, client.WithCache(time.Second*30)) - if err != nil { - return nil, err - } - - rules := make([]*auth.Rule, len(rsp.Rules)) - for i, r := range rsp.Rules { - rules[i] = serializeRule(r) - } - - return rules, nil -} - -// Verify an account has access to a resource -func (s *svc) Verify(acc *auth.Account, res *auth.Resource, opts ...auth.VerifyOption) error { - var options auth.VerifyOptions - for _, o := range opts { - o(&options) - } - - rs, err := s.Rules(auth.RulesContext(options.Context)) - if err != nil { - return err - } - - return rules.Verify(rs, acc, res) -} - -// Inspect a token -func (s *svc) Inspect(token string) (*auth.Account, error) { - // try to decode JWT locally and fall back to srv if an error occurs - if len(strings.Split(token, ".")) == 3 && s.jwt != nil { - return s.jwt.Inspect(token) - } - - // the token is not a JWT or we do not have the keys to decode it, - // fall back to the auth service - rsp, err := s.auth.Inspect(context.TODO(), &pb.InspectRequest{Token: token}) - if err != nil { - return nil, err - } - return serializeAccount(rsp.Account), nil -} - -// Token generation using an account ID and secret -func (s *svc) Token(opts ...auth.TokenOption) (*auth.Token, error) { - options := auth.NewTokenOptions(opts...) - - rsp, err := s.auth.Token(context.Background(), &pb.TokenRequest{ - Id: options.ID, - Secret: options.Secret, - RefreshToken: options.RefreshToken, - TokenExpiry: int64(options.Expiry.Seconds()), - }) - if err != nil { - return nil, err - } - - return serializeToken(rsp.Token), nil -} - -func serializeToken(t *pb.Token) *auth.Token { - return &auth.Token{ - AccessToken: t.AccessToken, - RefreshToken: t.RefreshToken, - Created: time.Unix(t.Created, 0), - Expiry: time.Unix(t.Expiry, 0), - } -} - -func serializeAccount(a *pb.Account) *auth.Account { - return &auth.Account{ - ID: a.Id, - Secret: a.Secret, - Issuer: a.Issuer, - Metadata: a.Metadata, - Scopes: a.Scopes, - } -} - -func serializeRule(r *pb.Rule) *auth.Rule { - var access auth.Access - if r.Access == pb.Access_GRANTED { - access = auth.AccessGranted - } else { - access = auth.AccessDenied - } - - return &auth.Rule{ - ID: r.Id, - Scope: r.Scope, - Access: access, - Priority: r.Priority, - Resource: &auth.Resource{ - Type: r.Resource.Type, - Name: r.Resource.Name, - Endpoint: r.Resource.Endpoint, - }, - } -} - -// NewAuth returns a new instance of the Auth service -func NewAuth(opts ...auth.Option) auth.Auth { - options := auth.NewOptions(opts...) - if options.Client == nil { - options.Client = client.DefaultClient - } - - return &svc{ - auth: pb.NewAuthService("go.micro.auth", options.Client), - rules: pb.NewRulesService("go.micro.auth", options.Client), - options: options, - } -} diff --git a/broker/service/proto/broker.pb.go b/broker/service/proto/broker.pb.go deleted file mode 100644 index cb561cc9..00000000 --- a/broker/service/proto/broker.pb.go +++ /dev/null @@ -1,374 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: broker/service/proto/broker.proto - -package go_micro_broker - -import ( - context "context" - fmt "fmt" - proto "github.com/golang/protobuf/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - math "math" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package - -type Empty struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Empty) Reset() { *m = Empty{} } -func (m *Empty) String() string { return proto.CompactTextString(m) } -func (*Empty) ProtoMessage() {} -func (*Empty) Descriptor() ([]byte, []int) { - return fileDescriptor_df4d8f04292cf3fe, []int{0} -} - -func (m *Empty) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Empty.Unmarshal(m, b) -} -func (m *Empty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Empty.Marshal(b, m, deterministic) -} -func (m *Empty) XXX_Merge(src proto.Message) { - xxx_messageInfo_Empty.Merge(m, src) -} -func (m *Empty) XXX_Size() int { - return xxx_messageInfo_Empty.Size(m) -} -func (m *Empty) XXX_DiscardUnknown() { - xxx_messageInfo_Empty.DiscardUnknown(m) -} - -var xxx_messageInfo_Empty proto.InternalMessageInfo - -type PublishRequest struct { - Topic string `protobuf:"bytes,1,opt,name=topic,proto3" json:"topic,omitempty"` - Message *Message `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *PublishRequest) Reset() { *m = PublishRequest{} } -func (m *PublishRequest) String() string { return proto.CompactTextString(m) } -func (*PublishRequest) ProtoMessage() {} -func (*PublishRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_df4d8f04292cf3fe, []int{1} -} - -func (m *PublishRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_PublishRequest.Unmarshal(m, b) -} -func (m *PublishRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_PublishRequest.Marshal(b, m, deterministic) -} -func (m *PublishRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_PublishRequest.Merge(m, src) -} -func (m *PublishRequest) XXX_Size() int { - return xxx_messageInfo_PublishRequest.Size(m) -} -func (m *PublishRequest) XXX_DiscardUnknown() { - xxx_messageInfo_PublishRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_PublishRequest proto.InternalMessageInfo - -func (m *PublishRequest) GetTopic() string { - if m != nil { - return m.Topic - } - return "" -} - -func (m *PublishRequest) GetMessage() *Message { - if m != nil { - return m.Message - } - return nil -} - -type SubscribeRequest struct { - Topic string `protobuf:"bytes,1,opt,name=topic,proto3" json:"topic,omitempty"` - Queue string `protobuf:"bytes,2,opt,name=queue,proto3" json:"queue,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SubscribeRequest) Reset() { *m = SubscribeRequest{} } -func (m *SubscribeRequest) String() string { return proto.CompactTextString(m) } -func (*SubscribeRequest) ProtoMessage() {} -func (*SubscribeRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_df4d8f04292cf3fe, []int{2} -} - -func (m *SubscribeRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_SubscribeRequest.Unmarshal(m, b) -} -func (m *SubscribeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_SubscribeRequest.Marshal(b, m, deterministic) -} -func (m *SubscribeRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_SubscribeRequest.Merge(m, src) -} -func (m *SubscribeRequest) XXX_Size() int { - return xxx_messageInfo_SubscribeRequest.Size(m) -} -func (m *SubscribeRequest) XXX_DiscardUnknown() { - xxx_messageInfo_SubscribeRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_SubscribeRequest proto.InternalMessageInfo - -func (m *SubscribeRequest) GetTopic() string { - if m != nil { - return m.Topic - } - return "" -} - -func (m *SubscribeRequest) GetQueue() string { - if m != nil { - return m.Queue - } - return "" -} - -type Message struct { - Header map[string]string `protobuf:"bytes,1,rep,name=header,proto3" json:"header,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - Body []byte `protobuf:"bytes,2,opt,name=body,proto3" json:"body,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Message) Reset() { *m = Message{} } -func (m *Message) String() string { return proto.CompactTextString(m) } -func (*Message) ProtoMessage() {} -func (*Message) Descriptor() ([]byte, []int) { - return fileDescriptor_df4d8f04292cf3fe, []int{3} -} - -func (m *Message) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Message.Unmarshal(m, b) -} -func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Message.Marshal(b, m, deterministic) -} -func (m *Message) XXX_Merge(src proto.Message) { - xxx_messageInfo_Message.Merge(m, src) -} -func (m *Message) XXX_Size() int { - return xxx_messageInfo_Message.Size(m) -} -func (m *Message) XXX_DiscardUnknown() { - xxx_messageInfo_Message.DiscardUnknown(m) -} - -var xxx_messageInfo_Message proto.InternalMessageInfo - -func (m *Message) GetHeader() map[string]string { - if m != nil { - return m.Header - } - return nil -} - -func (m *Message) GetBody() []byte { - if m != nil { - return m.Body - } - return nil -} - -func init() { - proto.RegisterType((*Empty)(nil), "go.micro.broker.Empty") - proto.RegisterType((*PublishRequest)(nil), "go.micro.broker.PublishRequest") - proto.RegisterType((*SubscribeRequest)(nil), "go.micro.broker.SubscribeRequest") - proto.RegisterType((*Message)(nil), "go.micro.broker.Message") - proto.RegisterMapType((map[string]string)(nil), "go.micro.broker.Message.HeaderEntry") -} - -func init() { proto.RegisterFile("broker/service/proto/broker.proto", fileDescriptor_df4d8f04292cf3fe) } - -var fileDescriptor_df4d8f04292cf3fe = []byte{ - // 299 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x51, 0x4d, 0x4b, 0xc3, 0x40, - 0x14, 0xec, 0xb6, 0xb6, 0xa1, 0xaf, 0xa2, 0x65, 0x29, 0x12, 0x7a, 0x31, 0x0d, 0x1e, 0x72, 0xda, - 0x48, 0xbc, 0xa8, 0x88, 0x07, 0xb1, 0xe0, 0x41, 0x41, 0xd6, 0x9b, 0xb7, 0x6c, 0xfa, 0x68, 0x43, - 0x1b, 0x37, 0xdd, 0x4d, 0x0a, 0xf9, 0x23, 0x9e, 0xfc, 0xb1, 0xd2, 0xdd, 0xf8, 0xd5, 0x50, 0x6f, - 0x6f, 0xde, 0xce, 0xce, 0x1b, 0x66, 0x60, 0x22, 0x94, 0x5c, 0xa2, 0x0a, 0x35, 0xaa, 0x4d, 0x9a, - 0x60, 0x98, 0x2b, 0x59, 0xc8, 0xd0, 0x2e, 0x99, 0x01, 0xf4, 0x78, 0x2e, 0x59, 0x96, 0x26, 0x4a, - 0x32, 0xbb, 0xf6, 0x1d, 0xe8, 0x4e, 0xb3, 0xbc, 0xa8, 0xfc, 0x57, 0x38, 0x7a, 0x2e, 0xc5, 0x2a, - 0xd5, 0x0b, 0x8e, 0xeb, 0x12, 0x75, 0x41, 0x47, 0xd0, 0x2d, 0x64, 0x9e, 0x26, 0x2e, 0xf1, 0x48, - 0xd0, 0xe7, 0x16, 0xd0, 0x08, 0x9c, 0x0c, 0xb5, 0x8e, 0xe7, 0xe8, 0xb6, 0x3d, 0x12, 0x0c, 0x22, - 0x97, 0xed, 0x68, 0xb2, 0x27, 0xfb, 0xce, 0xbf, 0x88, 0xfe, 0x2d, 0x0c, 0x5f, 0x4a, 0xa1, 0x13, - 0x95, 0x0a, 0xfc, 0x5f, 0x7d, 0x04, 0xdd, 0x75, 0x89, 0xa5, 0xd5, 0xee, 0x73, 0x0b, 0xfc, 0x77, - 0x02, 0x4e, 0x2d, 0x4a, 0x6f, 0xa0, 0xb7, 0xc0, 0x78, 0x86, 0xca, 0x25, 0x5e, 0x27, 0x18, 0x44, - 0x67, 0xfb, 0xce, 0xb3, 0x07, 0x43, 0x9b, 0xbe, 0x15, 0xaa, 0xe2, 0xf5, 0x1f, 0x4a, 0xe1, 0x40, - 0xc8, 0x59, 0x65, 0xe4, 0x0f, 0xb9, 0x99, 0xc7, 0x57, 0x30, 0xf8, 0x45, 0xa5, 0x43, 0xe8, 0x2c, - 0xb1, 0xaa, 0x6d, 0x6d, 0xc7, 0xad, 0xa9, 0x4d, 0xbc, 0xfa, 0x31, 0x65, 0xc0, 0x75, 0xfb, 0x92, - 0x44, 0x1f, 0x04, 0x7a, 0x77, 0xe6, 0x2a, 0xbd, 0x07, 0xa7, 0xce, 0x8f, 0x9e, 0x36, 0x2c, 0xfd, - 0x4d, 0x76, 0x7c, 0xd2, 0x20, 0xd8, 0x0e, 0x5a, 0xf4, 0x11, 0xfa, 0xdf, 0x49, 0xd1, 0x49, 0x83, - 0xb6, 0x9b, 0xe2, 0x78, 0x6f, 0xf8, 0x7e, 0xeb, 0x9c, 0x88, 0x9e, 0x29, 0xfd, 0xe2, 0x33, 0x00, - 0x00, 0xff, 0xff, 0x19, 0x9f, 0x10, 0x75, 0x19, 0x02, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// BrokerClient is the client API for Broker service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type BrokerClient interface { - Publish(ctx context.Context, in *PublishRequest, opts ...grpc.CallOption) (*Empty, error) - Subscribe(ctx context.Context, in *SubscribeRequest, opts ...grpc.CallOption) (Broker_SubscribeClient, error) -} - -type brokerClient struct { - cc *grpc.ClientConn -} - -func NewBrokerClient(cc *grpc.ClientConn) BrokerClient { - return &brokerClient{cc} -} - -func (c *brokerClient) Publish(ctx context.Context, in *PublishRequest, opts ...grpc.CallOption) (*Empty, error) { - out := new(Empty) - err := c.cc.Invoke(ctx, "/go.micro.broker.Broker/Publish", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *brokerClient) Subscribe(ctx context.Context, in *SubscribeRequest, opts ...grpc.CallOption) (Broker_SubscribeClient, error) { - stream, err := c.cc.NewStream(ctx, &_Broker_serviceDesc.Streams[0], "/go.micro.broker.Broker/Subscribe", opts...) - if err != nil { - return nil, err - } - x := &brokerSubscribeClient{stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - return x, nil -} - -type Broker_SubscribeClient interface { - Recv() (*Message, error) - grpc.ClientStream -} - -type brokerSubscribeClient struct { - grpc.ClientStream -} - -func (x *brokerSubscribeClient) Recv() (*Message, error) { - m := new(Message) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -// BrokerServer is the server API for Broker service. -type BrokerServer interface { - Publish(context.Context, *PublishRequest) (*Empty, error) - Subscribe(*SubscribeRequest, Broker_SubscribeServer) error -} - -// UnimplementedBrokerServer can be embedded to have forward compatible implementations. -type UnimplementedBrokerServer struct { -} - -func (*UnimplementedBrokerServer) Publish(ctx context.Context, req *PublishRequest) (*Empty, error) { - return nil, status.Errorf(codes.Unimplemented, "method Publish not implemented") -} -func (*UnimplementedBrokerServer) Subscribe(req *SubscribeRequest, srv Broker_SubscribeServer) error { - return status.Errorf(codes.Unimplemented, "method Subscribe not implemented") -} - -func RegisterBrokerServer(s *grpc.Server, srv BrokerServer) { - s.RegisterService(&_Broker_serviceDesc, srv) -} - -func _Broker_Publish_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(PublishRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(BrokerServer).Publish(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/go.micro.broker.Broker/Publish", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(BrokerServer).Publish(ctx, req.(*PublishRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Broker_Subscribe_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(SubscribeRequest) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(BrokerServer).Subscribe(m, &brokerSubscribeServer{stream}) -} - -type Broker_SubscribeServer interface { - Send(*Message) error - grpc.ServerStream -} - -type brokerSubscribeServer struct { - grpc.ServerStream -} - -func (x *brokerSubscribeServer) Send(m *Message) error { - return x.ServerStream.SendMsg(m) -} - -var _Broker_serviceDesc = grpc.ServiceDesc{ - ServiceName: "go.micro.broker.Broker", - HandlerType: (*BrokerServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Publish", - Handler: _Broker_Publish_Handler, - }, - }, - Streams: []grpc.StreamDesc{ - { - StreamName: "Subscribe", - Handler: _Broker_Subscribe_Handler, - ServerStreams: true, - }, - }, - Metadata: "broker/service/proto/broker.proto", -} diff --git a/broker/service/proto/broker.pb.micro.go b/broker/service/proto/broker.pb.micro.go deleted file mode 100644 index 01e6f938..00000000 --- a/broker/service/proto/broker.pb.micro.go +++ /dev/null @@ -1,185 +0,0 @@ -// Code generated by protoc-gen-micro. DO NOT EDIT. -// source: broker/service/proto/broker.proto - -package go_micro_broker - -import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" - math "math" -) - -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" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -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 { - Publish(ctx context.Context, in *PublishRequest, opts ...client.CallOption) (*Empty, error) - Subscribe(ctx context.Context, in *SubscribeRequest, opts ...client.CallOption) (Broker_SubscribeService, error) -} - -type brokerService struct { - c client.Client - name string -} - -func NewBrokerService(name string, c client.Client) BrokerService { - return &brokerService{ - c: c, - name: name, - } -} - -func (c *brokerService) Publish(ctx context.Context, in *PublishRequest, opts ...client.CallOption) (*Empty, error) { - req := c.c.NewRequest(c.name, "Broker.Publish", in) - out := new(Empty) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *brokerService) Subscribe(ctx context.Context, in *SubscribeRequest, opts ...client.CallOption) (Broker_SubscribeService, error) { - req := c.c.NewRequest(c.name, "Broker.Subscribe", &SubscribeRequest{}) - stream, err := c.c.Stream(ctx, req, opts...) - if err != nil { - return nil, err - } - if err := stream.Send(in); err != nil { - return nil, err - } - return &brokerServiceSubscribe{stream}, nil -} - -type Broker_SubscribeService interface { - Context() context.Context - SendMsg(interface{}) error - RecvMsg(interface{}) error - Close() error - Recv() (*Message, error) -} - -type brokerServiceSubscribe struct { - stream client.Stream -} - -func (x *brokerServiceSubscribe) Close() error { - return x.stream.Close() -} - -func (x *brokerServiceSubscribe) Context() context.Context { - return x.stream.Context() -} - -func (x *brokerServiceSubscribe) SendMsg(m interface{}) error { - return x.stream.Send(m) -} - -func (x *brokerServiceSubscribe) RecvMsg(m interface{}) error { - return x.stream.Recv(m) -} - -func (x *brokerServiceSubscribe) Recv() (*Message, error) { - m := new(Message) - err := x.stream.Recv(m) - if err != nil { - return nil, err - } - return m, nil -} - -// Server API for Broker service - -type BrokerHandler interface { - Publish(context.Context, *PublishRequest, *Empty) error - Subscribe(context.Context, *SubscribeRequest, Broker_SubscribeStream) error -} - -func RegisterBrokerHandler(s server.Server, hdlr BrokerHandler, opts ...server.HandlerOption) error { - type broker interface { - Publish(ctx context.Context, in *PublishRequest, out *Empty) error - Subscribe(ctx context.Context, stream server.Stream) error - } - type Broker struct { - broker - } - h := &brokerHandler{hdlr} - return s.Handle(s.NewHandler(&Broker{h}, opts...)) -} - -type brokerHandler struct { - BrokerHandler -} - -func (h *brokerHandler) Publish(ctx context.Context, in *PublishRequest, out *Empty) error { - return h.BrokerHandler.Publish(ctx, in, out) -} - -func (h *brokerHandler) Subscribe(ctx context.Context, stream server.Stream) error { - m := new(SubscribeRequest) - if err := stream.Recv(m); err != nil { - return err - } - return h.BrokerHandler.Subscribe(ctx, m, &brokerSubscribeStream{stream}) -} - -type Broker_SubscribeStream interface { - Context() context.Context - SendMsg(interface{}) error - RecvMsg(interface{}) error - Close() error - Send(*Message) error -} - -type brokerSubscribeStream struct { - stream server.Stream -} - -func (x *brokerSubscribeStream) Close() error { - return x.stream.Close() -} - -func (x *brokerSubscribeStream) Context() context.Context { - return x.stream.Context() -} - -func (x *brokerSubscribeStream) SendMsg(m interface{}) error { - return x.stream.Send(m) -} - -func (x *brokerSubscribeStream) RecvMsg(m interface{}) error { - return x.stream.Recv(m) -} - -func (x *brokerSubscribeStream) Send(m *Message) error { - return x.stream.Send(m) -} diff --git a/broker/service/proto/broker.proto b/broker/service/proto/broker.proto deleted file mode 100644 index 3fc877e6..00000000 --- a/broker/service/proto/broker.proto +++ /dev/null @@ -1,25 +0,0 @@ -syntax = "proto3"; - -package go.micro.broker; - -service Broker { - rpc Publish(PublishRequest) returns (Empty) {}; - rpc Subscribe(SubscribeRequest) returns (stream Message) {}; -} - -message Empty {} - -message PublishRequest { - string topic = 1; - Message message = 2; -} - -message SubscribeRequest { - string topic = 1; - string queue = 2; -} - -message Message { - map header = 1; - bytes body = 2; -} diff --git a/broker/service/service.go b/broker/service/service.go deleted file mode 100644 index 0ce2f00e..00000000 --- a/broker/service/service.go +++ /dev/null @@ -1,146 +0,0 @@ -// Package service provides the broker service client -package service - -import ( - "context" - "time" - - "github.com/micro/go-micro/v2/broker" - pb "github.com/micro/go-micro/v2/broker/service/proto" - "github.com/micro/go-micro/v2/client" - "github.com/micro/go-micro/v2/logger" -) - -type serviceBroker struct { - Addrs []string - Client pb.BrokerService - options broker.Options -} - -var ( - DefaultName = "go.micro.broker" -) - -func (b *serviceBroker) Address() string { - return b.Addrs[0] -} - -func (b *serviceBroker) Connect() error { - return nil -} - -func (b *serviceBroker) Disconnect() error { - return nil -} - -func (b *serviceBroker) Init(opts ...broker.Option) error { - for _, o := range opts { - o(&b.options) - } - return nil -} - -func (b *serviceBroker) Options() broker.Options { - return b.options -} - -func (b *serviceBroker) Publish(topic string, msg *broker.Message, opts ...broker.PublishOption) error { - if logger.V(logger.DebugLevel, logger.DefaultLogger) { - logger.Debugf("Publishing to topic %s broker %v", topic, b.Addrs) - } - _, err := b.Client.Publish(context.TODO(), &pb.PublishRequest{ - Topic: topic, - Message: &pb.Message{ - Header: msg.Header, - Body: msg.Body, - }, - }, client.WithAddress(b.Addrs...)) - return err -} - -func (b *serviceBroker) Subscribe(topic string, handler broker.Handler, opts ...broker.SubscribeOption) (broker.Subscriber, error) { - var options broker.SubscribeOptions - for _, o := range opts { - o(&options) - } - if logger.V(logger.DebugLevel, logger.DefaultLogger) { - logger.Debugf("Subscribing to topic %s queue %s broker %v", topic, options.Queue, b.Addrs) - } - stream, err := b.Client.Subscribe(context.TODO(), &pb.SubscribeRequest{ - Topic: topic, - Queue: options.Queue, - }, client.WithAddress(b.Addrs...), client.WithRequestTimeout(time.Hour)) - if err != nil { - return nil, err - } - - sub := &serviceSub{ - topic: topic, - queue: options.Queue, - handler: handler, - stream: stream, - closed: make(chan bool), - options: options, - } - - go func() { - for { - select { - case <-sub.closed: - if logger.V(logger.DebugLevel, logger.DefaultLogger) { - logger.Debugf("Unsubscribed from topic %s", topic) - } - return - default: - if logger.V(logger.DebugLevel, logger.DefaultLogger) { - // run the subscriber - logger.Debugf("Streaming from broker %v to topic [%s] queue [%s]", b.Addrs, topic, options.Queue) - } - if err := sub.run(); err != nil { - if logger.V(logger.DebugLevel, logger.DefaultLogger) { - logger.Debugf("Resubscribing to topic %s broker %v", topic, b.Addrs) - } - stream, err := b.Client.Subscribe(context.TODO(), &pb.SubscribeRequest{ - Topic: topic, - Queue: options.Queue, - }, client.WithAddress(b.Addrs...), client.WithRequestTimeout(time.Hour)) - if err != nil { - if logger.V(logger.DebugLevel, logger.DefaultLogger) { - logger.Debugf("Failed to resubscribe to topic %s: %v", topic, err) - } - time.Sleep(time.Second) - continue - } - // new stream - sub.stream = stream - } - } - } - }() - - return sub, nil -} - -func (b *serviceBroker) String() string { - return "service" -} - -func NewBroker(opts ...broker.Option) broker.Broker { - var options broker.Options - for _, o := range opts { - o(&options) - } - - addrs := options.Addrs - if len(addrs) == 0 { - addrs = []string{"127.0.0.1:8001"} - } - - cli := client.DefaultClient - - return &serviceBroker{ - Addrs: addrs, - Client: pb.NewBrokerService(DefaultName, cli), - options: options, - } -} diff --git a/broker/service/subscriber.go b/broker/service/subscriber.go deleted file mode 100644 index c11ec962..00000000 --- a/broker/service/subscriber.go +++ /dev/null @@ -1,108 +0,0 @@ -package service - -import ( - "github.com/micro/go-micro/v2/broker" - pb "github.com/micro/go-micro/v2/broker/service/proto" - "github.com/micro/go-micro/v2/logger" -) - -type serviceSub struct { - topic string - queue string - handler broker.Handler - stream pb.Broker_SubscribeService - closed chan bool - options broker.SubscribeOptions -} - -type serviceEvent struct { - topic string - err error - message *broker.Message -} - -func (s *serviceEvent) Topic() string { - return s.topic -} - -func (s *serviceEvent) Message() *broker.Message { - return s.message -} - -func (s *serviceEvent) Ack() error { - return nil -} - -func (s *serviceEvent) Error() error { - return s.err -} - -func (s *serviceSub) isClosed() bool { - select { - case <-s.closed: - return true - default: - return false - } -} - -func (s *serviceSub) run() error { - exit := make(chan bool) - go func() { - select { - case <-exit: - case <-s.closed: - } - - // close the stream - s.stream.Close() - }() - - for { - // TODO: do not fail silently - msg, err := s.stream.Recv() - if err != nil { - if logger.V(logger.DebugLevel, logger.DefaultLogger) { - logger.Debugf("Streaming error for subcription to topic %s: %v", s.Topic(), err) - } - - // close the exit channel - close(exit) - - // don't return an error if we unsubscribed - if s.isClosed() { - return nil - } - - // return stream error - return err - } - - p := &serviceEvent{ - topic: s.topic, - message: &broker.Message{ - Header: msg.Header, - Body: msg.Body, - }, - } - p.err = s.handler(p) - } -} - -func (s *serviceSub) Options() broker.SubscribeOptions { - return s.options -} - -func (s *serviceSub) Topic() string { - return s.topic -} - -func (s *serviceSub) Unsubscribe() error { - select { - case <-s.closed: - return nil - default: - close(s.closed) - } - return nil -} diff --git a/client/service/proto/client.pb.go b/client/service/proto/client.pb.go deleted file mode 100644 index 8d82354e..00000000 --- a/client/service/proto/client.pb.go +++ /dev/null @@ -1,402 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: client/service/proto/client.proto - -package go_micro_client - -import ( - context "context" - fmt "fmt" - proto "github.com/golang/protobuf/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - math "math" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package - -type Request struct { - Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` - Endpoint string `protobuf:"bytes,2,opt,name=endpoint,proto3" json:"endpoint,omitempty"` - ContentType string `protobuf:"bytes,3,opt,name=content_type,json=contentType,proto3" json:"content_type,omitempty"` - Body []byte `protobuf:"bytes,4,opt,name=body,proto3" json:"body,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Request) Reset() { *m = Request{} } -func (m *Request) String() string { return proto.CompactTextString(m) } -func (*Request) ProtoMessage() {} -func (*Request) Descriptor() ([]byte, []int) { - return fileDescriptor_27c3d425ddd1a066, []int{0} -} - -func (m *Request) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Request.Unmarshal(m, b) -} -func (m *Request) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Request.Marshal(b, m, deterministic) -} -func (m *Request) XXX_Merge(src proto.Message) { - xxx_messageInfo_Request.Merge(m, src) -} -func (m *Request) XXX_Size() int { - return xxx_messageInfo_Request.Size(m) -} -func (m *Request) XXX_DiscardUnknown() { - xxx_messageInfo_Request.DiscardUnknown(m) -} - -var xxx_messageInfo_Request proto.InternalMessageInfo - -func (m *Request) GetService() string { - if m != nil { - return m.Service - } - return "" -} - -func (m *Request) GetEndpoint() string { - if m != nil { - return m.Endpoint - } - return "" -} - -func (m *Request) GetContentType() string { - if m != nil { - return m.ContentType - } - return "" -} - -func (m *Request) GetBody() []byte { - if m != nil { - return m.Body - } - return nil -} - -type Response struct { - Body []byte `protobuf:"bytes,1,opt,name=body,proto3" json:"body,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Response) Reset() { *m = Response{} } -func (m *Response) String() string { return proto.CompactTextString(m) } -func (*Response) ProtoMessage() {} -func (*Response) Descriptor() ([]byte, []int) { - return fileDescriptor_27c3d425ddd1a066, []int{1} -} - -func (m *Response) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Response.Unmarshal(m, b) -} -func (m *Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Response.Marshal(b, m, deterministic) -} -func (m *Response) XXX_Merge(src proto.Message) { - xxx_messageInfo_Response.Merge(m, src) -} -func (m *Response) XXX_Size() int { - return xxx_messageInfo_Response.Size(m) -} -func (m *Response) XXX_DiscardUnknown() { - xxx_messageInfo_Response.DiscardUnknown(m) -} - -var xxx_messageInfo_Response proto.InternalMessageInfo - -func (m *Response) GetBody() []byte { - if m != nil { - return m.Body - } - return nil -} - -type Message struct { - Topic string `protobuf:"bytes,1,opt,name=topic,proto3" json:"topic,omitempty"` - ContentType string `protobuf:"bytes,2,opt,name=content_type,json=contentType,proto3" json:"content_type,omitempty"` - Body []byte `protobuf:"bytes,3,opt,name=body,proto3" json:"body,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Message) Reset() { *m = Message{} } -func (m *Message) String() string { return proto.CompactTextString(m) } -func (*Message) ProtoMessage() {} -func (*Message) Descriptor() ([]byte, []int) { - return fileDescriptor_27c3d425ddd1a066, []int{2} -} - -func (m *Message) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Message.Unmarshal(m, b) -} -func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Message.Marshal(b, m, deterministic) -} -func (m *Message) XXX_Merge(src proto.Message) { - xxx_messageInfo_Message.Merge(m, src) -} -func (m *Message) XXX_Size() int { - return xxx_messageInfo_Message.Size(m) -} -func (m *Message) XXX_DiscardUnknown() { - xxx_messageInfo_Message.DiscardUnknown(m) -} - -var xxx_messageInfo_Message proto.InternalMessageInfo - -func (m *Message) GetTopic() string { - if m != nil { - return m.Topic - } - return "" -} - -func (m *Message) GetContentType() string { - if m != nil { - return m.ContentType - } - return "" -} - -func (m *Message) GetBody() []byte { - if m != nil { - return m.Body - } - return nil -} - -func init() { - proto.RegisterType((*Request)(nil), "go.micro.client.Request") - proto.RegisterType((*Response)(nil), "go.micro.client.Response") - proto.RegisterType((*Message)(nil), "go.micro.client.Message") -} - -func init() { proto.RegisterFile("client/service/proto/client.proto", fileDescriptor_27c3d425ddd1a066) } - -var fileDescriptor_27c3d425ddd1a066 = []byte{ - // 267 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x91, 0xc1, 0x4b, 0xc3, 0x30, - 0x14, 0xc6, 0x97, 0x6d, 0xb6, 0xf3, 0x39, 0x10, 0x1e, 0x1e, 0x62, 0x0f, 0xb2, 0xf5, 0xd4, 0x53, - 0x2b, 0x7a, 0x16, 0x0f, 0x3d, 0x0b, 0x52, 0xc5, 0xab, 0xb4, 0xd9, 0x63, 0x06, 0xba, 0x24, 0x36, - 0xd9, 0xa0, 0x7f, 0xa4, 0xff, 0x93, 0x90, 0x46, 0x27, 0xba, 0x5d, 0xbc, 0xe5, 0xfb, 0x7e, 0xe4, - 0x7b, 0x2f, 0x5f, 0x60, 0x29, 0x5a, 0x49, 0xca, 0x15, 0x96, 0xba, 0x9d, 0x14, 0x54, 0x98, 0x4e, - 0x3b, 0x5d, 0x0c, 0x66, 0xee, 0x05, 0x9e, 0xaf, 0x75, 0xbe, 0x91, 0xa2, 0xd3, 0xf9, 0x60, 0xa7, - 0x3b, 0x88, 0x2b, 0x7a, 0xdf, 0x92, 0x75, 0xc8, 0x21, 0x0e, 0x37, 0x39, 0x5b, 0xb0, 0xec, 0xb4, - 0xfa, 0x92, 0x98, 0xc0, 0x8c, 0xd4, 0xca, 0x68, 0xa9, 0x1c, 0x1f, 0x7b, 0xf4, 0xad, 0x71, 0x09, - 0x73, 0xa1, 0x95, 0x23, 0xe5, 0x5e, 0x5d, 0x6f, 0x88, 0x4f, 0x3c, 0x3f, 0x0b, 0xde, 0x73, 0x6f, - 0x08, 0x11, 0xa6, 0x8d, 0x5e, 0xf5, 0x7c, 0xba, 0x60, 0xd9, 0xbc, 0xf2, 0xe7, 0xf4, 0x0a, 0x66, - 0x15, 0x59, 0xa3, 0x95, 0xdd, 0x73, 0xf6, 0x83, 0xbf, 0x40, 0xfc, 0x40, 0xd6, 0xd6, 0x6b, 0xc2, - 0x0b, 0x38, 0x71, 0xda, 0x48, 0x11, 0xb6, 0x1a, 0xc4, 0x9f, 0xb9, 0xe3, 0xe3, 0x73, 0x27, 0xfb, - 0xdc, 0x9b, 0x0f, 0x06, 0x51, 0xe9, 0x9f, 0x8e, 0x77, 0x30, 0x2d, 0xeb, 0xb6, 0x45, 0x9e, 0xff, - 0x2a, 0x25, 0x0f, 0x8d, 0x24, 0x97, 0x07, 0xc8, 0xb0, 0x73, 0x3a, 0xc2, 0x12, 0xa2, 0x27, 0xd7, - 0x51, 0xbd, 0xf9, 0x67, 0x40, 0xc6, 0xae, 0x19, 0xde, 0x43, 0xfc, 0xb8, 0x6d, 0x5a, 0x69, 0xdf, - 0x0e, 0xa4, 0x84, 0x02, 0x92, 0xa3, 0x24, 0x1d, 0x35, 0x91, 0xff, 0xd7, 0xdb, 0xcf, 0x00, 0x00, - 0x00, 0xff, 0xff, 0xd6, 0x3f, 0xc3, 0xa1, 0xfc, 0x01, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// ClientClient is the client API for Client service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type ClientClient interface { - // Call allows a single request to be made - Call(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) - // Stream is a bidirectional stream - Stream(ctx context.Context, opts ...grpc.CallOption) (Client_StreamClient, error) - // Publish publishes a message and returns an empty Message - Publish(ctx context.Context, in *Message, opts ...grpc.CallOption) (*Message, error) -} - -type clientClient struct { - cc *grpc.ClientConn -} - -func NewClientClient(cc *grpc.ClientConn) ClientClient { - return &clientClient{cc} -} - -func (c *clientClient) Call(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) { - out := new(Response) - err := c.cc.Invoke(ctx, "/go.micro.client.Client/Call", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *clientClient) Stream(ctx context.Context, opts ...grpc.CallOption) (Client_StreamClient, error) { - stream, err := c.cc.NewStream(ctx, &_Client_serviceDesc.Streams[0], "/go.micro.client.Client/Stream", opts...) - if err != nil { - return nil, err - } - x := &clientStreamClient{stream} - return x, nil -} - -type Client_StreamClient interface { - Send(*Request) error - Recv() (*Response, error) - grpc.ClientStream -} - -type clientStreamClient struct { - grpc.ClientStream -} - -func (x *clientStreamClient) Send(m *Request) error { - return x.ClientStream.SendMsg(m) -} - -func (x *clientStreamClient) Recv() (*Response, error) { - m := new(Response) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func (c *clientClient) Publish(ctx context.Context, in *Message, opts ...grpc.CallOption) (*Message, error) { - out := new(Message) - err := c.cc.Invoke(ctx, "/go.micro.client.Client/Publish", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// ClientServer is the server API for Client service. -type ClientServer interface { - // Call allows a single request to be made - Call(context.Context, *Request) (*Response, error) - // Stream is a bidirectional stream - Stream(Client_StreamServer) error - // Publish publishes a message and returns an empty Message - Publish(context.Context, *Message) (*Message, error) -} - -// UnimplementedClientServer can be embedded to have forward compatible implementations. -type UnimplementedClientServer struct { -} - -func (*UnimplementedClientServer) Call(ctx context.Context, req *Request) (*Response, error) { - return nil, status.Errorf(codes.Unimplemented, "method Call not implemented") -} -func (*UnimplementedClientServer) Stream(srv Client_StreamServer) error { - return status.Errorf(codes.Unimplemented, "method Stream not implemented") -} -func (*UnimplementedClientServer) Publish(ctx context.Context, req *Message) (*Message, error) { - return nil, status.Errorf(codes.Unimplemented, "method Publish not implemented") -} - -func RegisterClientServer(s *grpc.Server, srv ClientServer) { - s.RegisterService(&_Client_serviceDesc, srv) -} - -func _Client_Call_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Request) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ClientServer).Call(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/go.micro.client.Client/Call", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ClientServer).Call(ctx, req.(*Request)) - } - return interceptor(ctx, in, info, handler) -} - -func _Client_Stream_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(ClientServer).Stream(&clientStreamServer{stream}) -} - -type Client_StreamServer interface { - Send(*Response) error - Recv() (*Request, error) - grpc.ServerStream -} - -type clientStreamServer struct { - grpc.ServerStream -} - -func (x *clientStreamServer) Send(m *Response) error { - return x.ServerStream.SendMsg(m) -} - -func (x *clientStreamServer) Recv() (*Request, error) { - m := new(Request) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func _Client_Publish_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Message) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ClientServer).Publish(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/go.micro.client.Client/Publish", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ClientServer).Publish(ctx, req.(*Message)) - } - return interceptor(ctx, in, info, handler) -} - -var _Client_serviceDesc = grpc.ServiceDesc{ - ServiceName: "go.micro.client.Client", - HandlerType: (*ClientServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Call", - Handler: _Client_Call_Handler, - }, - { - MethodName: "Publish", - Handler: _Client_Publish_Handler, - }, - }, - Streams: []grpc.StreamDesc{ - { - StreamName: "Stream", - Handler: _Client_Stream_Handler, - ServerStreams: true, - ClientStreams: true, - }, - }, - Metadata: "client/service/proto/client.proto", -} diff --git a/client/service/proto/client.pb.micro.go b/client/service/proto/client.pb.micro.go deleted file mode 100644 index 0f3094bb..00000000 --- a/client/service/proto/client.pb.micro.go +++ /dev/null @@ -1,215 +0,0 @@ -// Code generated by protoc-gen-micro. DO NOT EDIT. -// source: client/service/proto/client.proto - -package go_micro_client - -import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" - math "math" -) - -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" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -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 { - // Call allows a single request to be made - Call(ctx context.Context, in *Request, opts ...client.CallOption) (*Response, error) - // Stream is a bidirectional stream - Stream(ctx context.Context, opts ...client.CallOption) (Client_StreamService, error) - // Publish publishes a message and returns an empty Message - Publish(ctx context.Context, in *Message, opts ...client.CallOption) (*Message, error) -} - -type clientService struct { - c client.Client - name string -} - -func NewClientService(name string, c client.Client) ClientService { - return &clientService{ - c: c, - name: name, - } -} - -func (c *clientService) Call(ctx context.Context, in *Request, opts ...client.CallOption) (*Response, error) { - req := c.c.NewRequest(c.name, "Client.Call", in) - out := new(Response) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *clientService) Stream(ctx context.Context, opts ...client.CallOption) (Client_StreamService, error) { - req := c.c.NewRequest(c.name, "Client.Stream", &Request{}) - stream, err := c.c.Stream(ctx, req, opts...) - if err != nil { - return nil, err - } - return &clientServiceStream{stream}, nil -} - -type Client_StreamService interface { - Context() context.Context - SendMsg(interface{}) error - RecvMsg(interface{}) error - Close() error - Send(*Request) error - Recv() (*Response, error) -} - -type clientServiceStream struct { - stream client.Stream -} - -func (x *clientServiceStream) Close() error { - return x.stream.Close() -} - -func (x *clientServiceStream) Context() context.Context { - return x.stream.Context() -} - -func (x *clientServiceStream) SendMsg(m interface{}) error { - return x.stream.Send(m) -} - -func (x *clientServiceStream) RecvMsg(m interface{}) error { - return x.stream.Recv(m) -} - -func (x *clientServiceStream) Send(m *Request) error { - return x.stream.Send(m) -} - -func (x *clientServiceStream) Recv() (*Response, error) { - m := new(Response) - err := x.stream.Recv(m) - if err != nil { - return nil, err - } - return m, nil -} - -func (c *clientService) Publish(ctx context.Context, in *Message, opts ...client.CallOption) (*Message, error) { - req := c.c.NewRequest(c.name, "Client.Publish", in) - out := new(Message) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// Server API for Client service - -type ClientHandler interface { - // Call allows a single request to be made - Call(context.Context, *Request, *Response) error - // Stream is a bidirectional stream - Stream(context.Context, Client_StreamStream) error - // Publish publishes a message and returns an empty Message - Publish(context.Context, *Message, *Message) error -} - -func RegisterClientHandler(s server.Server, hdlr ClientHandler, opts ...server.HandlerOption) error { - type client interface { - Call(ctx context.Context, in *Request, out *Response) error - Stream(ctx context.Context, stream server.Stream) error - Publish(ctx context.Context, in *Message, out *Message) error - } - type Client struct { - client - } - h := &clientHandler{hdlr} - return s.Handle(s.NewHandler(&Client{h}, opts...)) -} - -type clientHandler struct { - ClientHandler -} - -func (h *clientHandler) Call(ctx context.Context, in *Request, out *Response) error { - return h.ClientHandler.Call(ctx, in, out) -} - -func (h *clientHandler) Stream(ctx context.Context, stream server.Stream) error { - return h.ClientHandler.Stream(ctx, &clientStreamStream{stream}) -} - -type Client_StreamStream interface { - Context() context.Context - SendMsg(interface{}) error - RecvMsg(interface{}) error - Close() error - Send(*Response) error - Recv() (*Request, error) -} - -type clientStreamStream struct { - stream server.Stream -} - -func (x *clientStreamStream) Close() error { - return x.stream.Close() -} - -func (x *clientStreamStream) Context() context.Context { - return x.stream.Context() -} - -func (x *clientStreamStream) SendMsg(m interface{}) error { - return x.stream.Send(m) -} - -func (x *clientStreamStream) RecvMsg(m interface{}) error { - return x.stream.Recv(m) -} - -func (x *clientStreamStream) Send(m *Response) error { - return x.stream.Send(m) -} - -func (x *clientStreamStream) Recv() (*Request, error) { - m := new(Request) - if err := x.stream.Recv(m); err != nil { - return nil, err - } - return m, nil -} - -func (h *clientHandler) Publish(ctx context.Context, in *Message, out *Message) error { - return h.ClientHandler.Publish(ctx, in, out) -} diff --git a/client/service/proto/client.proto b/client/service/proto/client.proto deleted file mode 100644 index b5703cf2..00000000 --- a/client/service/proto/client.proto +++ /dev/null @@ -1,30 +0,0 @@ -syntax = "proto3"; - -package go.micro.client; - -// Client is the micro client interface -service Client { - // Call allows a single request to be made - rpc Call(Request) returns (Response) {}; - // Stream is a bidirectional stream - rpc Stream(stream Request) returns (stream Response) {}; - // Publish publishes a message and returns an empty Message - rpc Publish(Message) returns (Message) {}; -} - -message Request { - string service = 1; - string endpoint = 2; - string content_type = 3; - bytes body = 4; -} - -message Response { - bytes body = 1; -} - -message Message { - string topic = 1; - string content_type = 2; - bytes body = 3; -} diff --git a/cmd/cmd.go b/cmd/cmd.go index 568a0c97..2fff8da8 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -14,15 +14,12 @@ import ( "github.com/micro/go-micro/v2/client/grpc" "github.com/micro/go-micro/v2/client/selector" "github.com/micro/go-micro/v2/config" - configSrc "github.com/micro/go-micro/v2/config/source" - configSrv "github.com/micro/go-micro/v2/config/source/service" "github.com/micro/go-micro/v2/debug/profile" "github.com/micro/go-micro/v2/debug/profile/http" "github.com/micro/go-micro/v2/debug/profile/pprof" "github.com/micro/go-micro/v2/debug/trace" "github.com/micro/go-micro/v2/logger" "github.com/micro/go-micro/v2/registry" - registrySrv "github.com/micro/go-micro/v2/registry/service" "github.com/micro/go-micro/v2/runtime" "github.com/micro/go-micro/v2/server" "github.com/micro/go-micro/v2/store" @@ -44,18 +41,15 @@ import ( brokerHttp "github.com/micro/go-micro/v2/broker/http" "github.com/micro/go-micro/v2/broker/memory" "github.com/micro/go-micro/v2/broker/nats" - brokerSrv "github.com/micro/go-micro/v2/broker/service" // registries "github.com/micro/go-micro/v2/registry/etcd" "github.com/micro/go-micro/v2/registry/mdns" rmem "github.com/micro/go-micro/v2/registry/memory" - regSrv "github.com/micro/go-micro/v2/registry/service" // runtimes kRuntime "github.com/micro/go-micro/v2/runtime/kubernetes" lRuntime "github.com/micro/go-micro/v2/runtime/local" - srvRuntime "github.com/micro/go-micro/v2/runtime/service" // selectors "github.com/micro/go-micro/v2/client/selector/dns" @@ -68,7 +62,6 @@ import ( // stores memStore "github.com/micro/go-micro/v2/store/memory" - svcStore "github.com/micro/go-micro/v2/store/service" // tracers // jTracer "github.com/micro/go-micro/v2/debug/trace/jaeger" @@ -76,7 +69,6 @@ import ( // auth jwtAuth "github.com/micro/go-micro/v2/auth/jwt" - svcAuth "github.com/micro/go-micro/v2/auth/service" // auth providers "github.com/micro/go-micro/v2/auth/provider/basic" @@ -329,7 +321,6 @@ var ( } DefaultBrokers = map[string]func(...broker.Option) broker.Broker{ - "service": brokerSrv.NewBroker, "memory": memory.NewBroker, "nats": nats.NewBroker, "http": brokerHttp.NewBroker, @@ -341,7 +332,6 @@ var ( } DefaultRegistries = map[string]func(...registry.Option) registry.Registry{ - "service": regSrv.NewRegistry, "etcd": etcd.NewRegistry, "mdns": mdns.NewRegistry, "memory": rmem.NewRegistry, @@ -365,13 +355,11 @@ var ( DefaultRuntimes = map[string]func(...runtime.Option) runtime.Runtime{ "local": lRuntime.NewRuntime, - "service": srvRuntime.NewRuntime, "kubernetes": kRuntime.NewRuntime, } DefaultStores = map[string]func(...store.Option) store.Store{ "memory": memStore.NewStore, - "service": svcStore.NewStore, } DefaultTracers = map[string]func(...trace.Option) trace.Tracer{ @@ -380,7 +368,6 @@ var ( } DefaultAuths = map[string]func(...auth.Option) auth.Auth{ - "service": svcAuth.NewAuth, "jwt": jwtAuth.NewAuth, } @@ -394,9 +381,7 @@ var ( "pprof": pprof.NewProfile, } - DefaultConfigs = map[string]func(...config.Option) (config.Config, error){ - "service": config.NewConfig, - } + DefaultConfigs = map[string]func(...config.Option) (config.Config, error){} ) func init() { @@ -587,7 +572,7 @@ func (c *cmd) Before(ctx *cli.Context) error { return fmt.Errorf("Registry %s not found", name) } - *c.opts.Registry = r(registrySrv.WithClient(microClient)) + *c.opts.Registry = r() serverOpts = append(serverOpts, server.Registry(*c.opts.Registry)) clientOpts = append(clientOpts, client.Registry(*c.opts.Registry)) @@ -741,13 +726,6 @@ func (c *cmd) Before(ctx *cli.Context) error { } } - if ctx.String("config") == "service" { - opt := config.WithSource(configSrv.NewSource(configSrc.WithClient(microClient))) - if err := (*c.opts.Config).Init(opt); err != nil { - logger.Fatalf("Error configuring config: %v", err) - } - } - // client opts if r := ctx.Int("client_retries"); r >= 0 { clientOpts = append(clientOpts, client.Retries(r)) diff --git a/config/source/service/options.go b/config/source/service/options.go deleted file mode 100644 index 27565a79..00000000 --- a/config/source/service/options.go +++ /dev/null @@ -1,38 +0,0 @@ -package service - -import ( - "context" - - "github.com/micro/go-micro/v2/config/source" -) - -type serviceNameKey struct{} -type namespaceKey struct{} -type pathKey struct{} - -func ServiceName(name string) source.Option { - return func(o *source.Options) { - if o.Context == nil { - o.Context = context.Background() - } - o.Context = context.WithValue(o.Context, serviceNameKey{}, name) - } -} - -func Namespace(namespace string) source.Option { - return func(o *source.Options) { - if o.Context == nil { - o.Context = context.Background() - } - o.Context = context.WithValue(o.Context, namespaceKey{}, namespace) - } -} - -func Path(path string) source.Option { - return func(o *source.Options) { - if o.Context == nil { - o.Context = context.Background() - } - o.Context = context.WithValue(o.Context, pathKey{}, path) - } -} diff --git a/config/source/service/proto/service.pb.go b/config/source/service/proto/service.pb.go deleted file mode 100644 index 45e62cdf..00000000 --- a/config/source/service/proto/service.pb.go +++ /dev/null @@ -1,952 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: config/source/service/proto/service.proto - -package service - -import ( - context "context" - fmt "fmt" - proto "github.com/golang/protobuf/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - math "math" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package - -type ChangeSet struct { - Data string `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - Checksum string `protobuf:"bytes,2,opt,name=checksum,proto3" json:"checksum,omitempty"` - Format string `protobuf:"bytes,3,opt,name=format,proto3" json:"format,omitempty"` - Source string `protobuf:"bytes,4,opt,name=source,proto3" json:"source,omitempty"` - Timestamp int64 `protobuf:"varint,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ChangeSet) Reset() { *m = ChangeSet{} } -func (m *ChangeSet) String() string { return proto.CompactTextString(m) } -func (*ChangeSet) ProtoMessage() {} -func (*ChangeSet) Descriptor() ([]byte, []int) { - return fileDescriptor_e67338fe1f659d14, []int{0} -} - -func (m *ChangeSet) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ChangeSet.Unmarshal(m, b) -} -func (m *ChangeSet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ChangeSet.Marshal(b, m, deterministic) -} -func (m *ChangeSet) XXX_Merge(src proto.Message) { - xxx_messageInfo_ChangeSet.Merge(m, src) -} -func (m *ChangeSet) XXX_Size() int { - return xxx_messageInfo_ChangeSet.Size(m) -} -func (m *ChangeSet) XXX_DiscardUnknown() { - xxx_messageInfo_ChangeSet.DiscardUnknown(m) -} - -var xxx_messageInfo_ChangeSet proto.InternalMessageInfo - -func (m *ChangeSet) GetData() string { - if m != nil { - return m.Data - } - return "" -} - -func (m *ChangeSet) GetChecksum() string { - if m != nil { - return m.Checksum - } - return "" -} - -func (m *ChangeSet) GetFormat() string { - if m != nil { - return m.Format - } - return "" -} - -func (m *ChangeSet) GetSource() string { - if m != nil { - return m.Source - } - return "" -} - -func (m *ChangeSet) GetTimestamp() int64 { - if m != nil { - return m.Timestamp - } - return 0 -} - -type Change struct { - Namespace string `protobuf:"bytes,1,opt,name=namespace,proto3" json:"namespace,omitempty"` - Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` - ChangeSet *ChangeSet `protobuf:"bytes,3,opt,name=changeSet,proto3" json:"changeSet,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Change) Reset() { *m = Change{} } -func (m *Change) String() string { return proto.CompactTextString(m) } -func (*Change) ProtoMessage() {} -func (*Change) Descriptor() ([]byte, []int) { - return fileDescriptor_e67338fe1f659d14, []int{1} -} - -func (m *Change) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Change.Unmarshal(m, b) -} -func (m *Change) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Change.Marshal(b, m, deterministic) -} -func (m *Change) XXX_Merge(src proto.Message) { - xxx_messageInfo_Change.Merge(m, src) -} -func (m *Change) XXX_Size() int { - return xxx_messageInfo_Change.Size(m) -} -func (m *Change) XXX_DiscardUnknown() { - xxx_messageInfo_Change.DiscardUnknown(m) -} - -var xxx_messageInfo_Change proto.InternalMessageInfo - -func (m *Change) GetNamespace() string { - if m != nil { - return m.Namespace - } - return "" -} - -func (m *Change) GetPath() string { - if m != nil { - return m.Path - } - return "" -} - -func (m *Change) GetChangeSet() *ChangeSet { - if m != nil { - return m.ChangeSet - } - return nil -} - -type CreateRequest struct { - Change *Change `protobuf:"bytes,1,opt,name=change,proto3" json:"change,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CreateRequest) Reset() { *m = CreateRequest{} } -func (m *CreateRequest) String() string { return proto.CompactTextString(m) } -func (*CreateRequest) ProtoMessage() {} -func (*CreateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e67338fe1f659d14, []int{2} -} - -func (m *CreateRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CreateRequest.Unmarshal(m, b) -} -func (m *CreateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CreateRequest.Marshal(b, m, deterministic) -} -func (m *CreateRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_CreateRequest.Merge(m, src) -} -func (m *CreateRequest) XXX_Size() int { - return xxx_messageInfo_CreateRequest.Size(m) -} -func (m *CreateRequest) XXX_DiscardUnknown() { - xxx_messageInfo_CreateRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_CreateRequest proto.InternalMessageInfo - -func (m *CreateRequest) GetChange() *Change { - if m != nil { - return m.Change - } - return nil -} - -type CreateResponse struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CreateResponse) Reset() { *m = CreateResponse{} } -func (m *CreateResponse) String() string { return proto.CompactTextString(m) } -func (*CreateResponse) ProtoMessage() {} -func (*CreateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e67338fe1f659d14, []int{3} -} - -func (m *CreateResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CreateResponse.Unmarshal(m, b) -} -func (m *CreateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CreateResponse.Marshal(b, m, deterministic) -} -func (m *CreateResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_CreateResponse.Merge(m, src) -} -func (m *CreateResponse) XXX_Size() int { - return xxx_messageInfo_CreateResponse.Size(m) -} -func (m *CreateResponse) XXX_DiscardUnknown() { - xxx_messageInfo_CreateResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_CreateResponse proto.InternalMessageInfo - -type UpdateRequest struct { - Change *Change `protobuf:"bytes,1,opt,name=change,proto3" json:"change,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *UpdateRequest) Reset() { *m = UpdateRequest{} } -func (m *UpdateRequest) String() string { return proto.CompactTextString(m) } -func (*UpdateRequest) ProtoMessage() {} -func (*UpdateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e67338fe1f659d14, []int{4} -} - -func (m *UpdateRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_UpdateRequest.Unmarshal(m, b) -} -func (m *UpdateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_UpdateRequest.Marshal(b, m, deterministic) -} -func (m *UpdateRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_UpdateRequest.Merge(m, src) -} -func (m *UpdateRequest) XXX_Size() int { - return xxx_messageInfo_UpdateRequest.Size(m) -} -func (m *UpdateRequest) XXX_DiscardUnknown() { - xxx_messageInfo_UpdateRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_UpdateRequest proto.InternalMessageInfo - -func (m *UpdateRequest) GetChange() *Change { - if m != nil { - return m.Change - } - return nil -} - -type UpdateResponse struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *UpdateResponse) Reset() { *m = UpdateResponse{} } -func (m *UpdateResponse) String() string { return proto.CompactTextString(m) } -func (*UpdateResponse) ProtoMessage() {} -func (*UpdateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e67338fe1f659d14, []int{5} -} - -func (m *UpdateResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_UpdateResponse.Unmarshal(m, b) -} -func (m *UpdateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_UpdateResponse.Marshal(b, m, deterministic) -} -func (m *UpdateResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_UpdateResponse.Merge(m, src) -} -func (m *UpdateResponse) XXX_Size() int { - return xxx_messageInfo_UpdateResponse.Size(m) -} -func (m *UpdateResponse) XXX_DiscardUnknown() { - xxx_messageInfo_UpdateResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_UpdateResponse proto.InternalMessageInfo - -type DeleteRequest struct { - Change *Change `protobuf:"bytes,1,opt,name=change,proto3" json:"change,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DeleteRequest) Reset() { *m = DeleteRequest{} } -func (m *DeleteRequest) String() string { return proto.CompactTextString(m) } -func (*DeleteRequest) ProtoMessage() {} -func (*DeleteRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e67338fe1f659d14, []int{6} -} - -func (m *DeleteRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_DeleteRequest.Unmarshal(m, b) -} -func (m *DeleteRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_DeleteRequest.Marshal(b, m, deterministic) -} -func (m *DeleteRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeleteRequest.Merge(m, src) -} -func (m *DeleteRequest) XXX_Size() int { - return xxx_messageInfo_DeleteRequest.Size(m) -} -func (m *DeleteRequest) XXX_DiscardUnknown() { - xxx_messageInfo_DeleteRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_DeleteRequest proto.InternalMessageInfo - -func (m *DeleteRequest) GetChange() *Change { - if m != nil { - return m.Change - } - return nil -} - -type DeleteResponse struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DeleteResponse) Reset() { *m = DeleteResponse{} } -func (m *DeleteResponse) String() string { return proto.CompactTextString(m) } -func (*DeleteResponse) ProtoMessage() {} -func (*DeleteResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e67338fe1f659d14, []int{7} -} - -func (m *DeleteResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_DeleteResponse.Unmarshal(m, b) -} -func (m *DeleteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_DeleteResponse.Marshal(b, m, deterministic) -} -func (m *DeleteResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeleteResponse.Merge(m, src) -} -func (m *DeleteResponse) XXX_Size() int { - return xxx_messageInfo_DeleteResponse.Size(m) -} -func (m *DeleteResponse) XXX_DiscardUnknown() { - xxx_messageInfo_DeleteResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_DeleteResponse proto.InternalMessageInfo - -type ListRequest struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListRequest) Reset() { *m = ListRequest{} } -func (m *ListRequest) String() string { return proto.CompactTextString(m) } -func (*ListRequest) ProtoMessage() {} -func (*ListRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e67338fe1f659d14, []int{8} -} - -func (m *ListRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListRequest.Unmarshal(m, b) -} -func (m *ListRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListRequest.Marshal(b, m, deterministic) -} -func (m *ListRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListRequest.Merge(m, src) -} -func (m *ListRequest) XXX_Size() int { - return xxx_messageInfo_ListRequest.Size(m) -} -func (m *ListRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ListRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ListRequest proto.InternalMessageInfo - -type ListResponse struct { - Values []*Change `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListResponse) Reset() { *m = ListResponse{} } -func (m *ListResponse) String() string { return proto.CompactTextString(m) } -func (*ListResponse) ProtoMessage() {} -func (*ListResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e67338fe1f659d14, []int{9} -} - -func (m *ListResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListResponse.Unmarshal(m, b) -} -func (m *ListResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListResponse.Marshal(b, m, deterministic) -} -func (m *ListResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListResponse.Merge(m, src) -} -func (m *ListResponse) XXX_Size() int { - return xxx_messageInfo_ListResponse.Size(m) -} -func (m *ListResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ListResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_ListResponse proto.InternalMessageInfo - -func (m *ListResponse) GetValues() []*Change { - if m != nil { - return m.Values - } - return nil -} - -type ReadRequest struct { - Namespace string `protobuf:"bytes,1,opt,name=namespace,proto3" json:"namespace,omitempty"` - Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ReadRequest) Reset() { *m = ReadRequest{} } -func (m *ReadRequest) String() string { return proto.CompactTextString(m) } -func (*ReadRequest) ProtoMessage() {} -func (*ReadRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e67338fe1f659d14, []int{10} -} - -func (m *ReadRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ReadRequest.Unmarshal(m, b) -} -func (m *ReadRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ReadRequest.Marshal(b, m, deterministic) -} -func (m *ReadRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ReadRequest.Merge(m, src) -} -func (m *ReadRequest) XXX_Size() int { - return xxx_messageInfo_ReadRequest.Size(m) -} -func (m *ReadRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ReadRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ReadRequest proto.InternalMessageInfo - -func (m *ReadRequest) GetNamespace() string { - if m != nil { - return m.Namespace - } - return "" -} - -func (m *ReadRequest) GetPath() string { - if m != nil { - return m.Path - } - return "" -} - -type ReadResponse struct { - Change *Change `protobuf:"bytes,1,opt,name=change,proto3" json:"change,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ReadResponse) Reset() { *m = ReadResponse{} } -func (m *ReadResponse) String() string { return proto.CompactTextString(m) } -func (*ReadResponse) ProtoMessage() {} -func (*ReadResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e67338fe1f659d14, []int{11} -} - -func (m *ReadResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ReadResponse.Unmarshal(m, b) -} -func (m *ReadResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ReadResponse.Marshal(b, m, deterministic) -} -func (m *ReadResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ReadResponse.Merge(m, src) -} -func (m *ReadResponse) XXX_Size() int { - return xxx_messageInfo_ReadResponse.Size(m) -} -func (m *ReadResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ReadResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_ReadResponse proto.InternalMessageInfo - -func (m *ReadResponse) GetChange() *Change { - if m != nil { - return m.Change - } - return nil -} - -type WatchRequest struct { - Namespace string `protobuf:"bytes,1,opt,name=namespace,proto3" json:"namespace,omitempty"` - Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *WatchRequest) Reset() { *m = WatchRequest{} } -func (m *WatchRequest) String() string { return proto.CompactTextString(m) } -func (*WatchRequest) ProtoMessage() {} -func (*WatchRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e67338fe1f659d14, []int{12} -} - -func (m *WatchRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_WatchRequest.Unmarshal(m, b) -} -func (m *WatchRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_WatchRequest.Marshal(b, m, deterministic) -} -func (m *WatchRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_WatchRequest.Merge(m, src) -} -func (m *WatchRequest) XXX_Size() int { - return xxx_messageInfo_WatchRequest.Size(m) -} -func (m *WatchRequest) XXX_DiscardUnknown() { - xxx_messageInfo_WatchRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_WatchRequest proto.InternalMessageInfo - -func (m *WatchRequest) GetNamespace() string { - if m != nil { - return m.Namespace - } - return "" -} - -func (m *WatchRequest) GetPath() string { - if m != nil { - return m.Path - } - return "" -} - -type WatchResponse struct { - Namespace string `protobuf:"bytes,1,opt,name=namespace,proto3" json:"namespace,omitempty"` - ChangeSet *ChangeSet `protobuf:"bytes,2,opt,name=changeSet,proto3" json:"changeSet,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *WatchResponse) Reset() { *m = WatchResponse{} } -func (m *WatchResponse) String() string { return proto.CompactTextString(m) } -func (*WatchResponse) ProtoMessage() {} -func (*WatchResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e67338fe1f659d14, []int{13} -} - -func (m *WatchResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_WatchResponse.Unmarshal(m, b) -} -func (m *WatchResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_WatchResponse.Marshal(b, m, deterministic) -} -func (m *WatchResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_WatchResponse.Merge(m, src) -} -func (m *WatchResponse) XXX_Size() int { - return xxx_messageInfo_WatchResponse.Size(m) -} -func (m *WatchResponse) XXX_DiscardUnknown() { - xxx_messageInfo_WatchResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_WatchResponse proto.InternalMessageInfo - -func (m *WatchResponse) GetNamespace() string { - if m != nil { - return m.Namespace - } - return "" -} - -func (m *WatchResponse) GetChangeSet() *ChangeSet { - if m != nil { - return m.ChangeSet - } - return nil -} - -func init() { - proto.RegisterType((*ChangeSet)(nil), "ChangeSet") - proto.RegisterType((*Change)(nil), "Change") - proto.RegisterType((*CreateRequest)(nil), "CreateRequest") - proto.RegisterType((*CreateResponse)(nil), "CreateResponse") - proto.RegisterType((*UpdateRequest)(nil), "UpdateRequest") - proto.RegisterType((*UpdateResponse)(nil), "UpdateResponse") - proto.RegisterType((*DeleteRequest)(nil), "DeleteRequest") - proto.RegisterType((*DeleteResponse)(nil), "DeleteResponse") - proto.RegisterType((*ListRequest)(nil), "ListRequest") - proto.RegisterType((*ListResponse)(nil), "ListResponse") - proto.RegisterType((*ReadRequest)(nil), "ReadRequest") - proto.RegisterType((*ReadResponse)(nil), "ReadResponse") - proto.RegisterType((*WatchRequest)(nil), "WatchRequest") - proto.RegisterType((*WatchResponse)(nil), "WatchResponse") -} - -func init() { - proto.RegisterFile("config/source/service/proto/service.proto", fileDescriptor_e67338fe1f659d14) -} - -var fileDescriptor_e67338fe1f659d14 = []byte{ - // 434 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xcd, 0x8e, 0xd3, 0x30, - 0x10, 0xc7, 0x9b, 0xb6, 0x1b, 0xe8, 0xb4, 0x49, 0xd1, 0x1c, 0x50, 0x14, 0x21, 0x51, 0x59, 0x42, - 0x2a, 0x20, 0xb9, 0xab, 0xf2, 0x00, 0x20, 0x95, 0x23, 0xa7, 0x20, 0xb4, 0x67, 0xe3, 0xce, 0x6e, - 0x23, 0x36, 0x1f, 0xc4, 0xce, 0xbe, 0xc3, 0xbe, 0x35, 0xf2, 0x47, 0x36, 0x49, 0x0f, 0x95, 0xca, - 0xcd, 0xf3, 0xf5, 0x9f, 0xb1, 0x7f, 0x93, 0xc0, 0x47, 0x59, 0x95, 0xf7, 0xf9, 0xc3, 0x4e, 0x55, - 0x6d, 0x23, 0x69, 0xa7, 0xa8, 0x79, 0xca, 0x25, 0xed, 0xea, 0xa6, 0xd2, 0x55, 0x67, 0x71, 0x6b, - 0xb1, 0xe7, 0x00, 0x16, 0x87, 0x93, 0x28, 0x1f, 0xe8, 0x27, 0x69, 0x44, 0x98, 0x1f, 0x85, 0x16, - 0x49, 0xb0, 0x09, 0xb6, 0x8b, 0xcc, 0x9e, 0x31, 0x85, 0xd7, 0xf2, 0x44, 0xf2, 0x8f, 0x6a, 0x8b, - 0x64, 0x6a, 0xfd, 0x2f, 0x36, 0xbe, 0x85, 0xf0, 0xbe, 0x6a, 0x0a, 0xa1, 0x93, 0x99, 0x8d, 0x78, - 0xcb, 0xf8, 0x5d, 0xef, 0x64, 0xee, 0xfc, 0xce, 0xc2, 0x77, 0xb0, 0xd0, 0x79, 0x41, 0x4a, 0x8b, - 0xa2, 0x4e, 0x6e, 0x36, 0xc1, 0x76, 0x96, 0xf5, 0x0e, 0x76, 0x84, 0xd0, 0x8d, 0x62, 0xf2, 0x4a, - 0x51, 0x90, 0xaa, 0x85, 0x24, 0x3f, 0x4c, 0xef, 0x30, 0x53, 0xd6, 0x42, 0x9f, 0xfc, 0x34, 0xf6, - 0x8c, 0x5b, 0x58, 0xc8, 0xee, 0x1a, 0x76, 0x98, 0xe5, 0x1e, 0xf8, 0xcb, 0xc5, 0xb2, 0x3e, 0xc8, - 0x6e, 0x21, 0x3a, 0x34, 0x24, 0x34, 0x65, 0xf4, 0xb7, 0x25, 0xa5, 0xf1, 0x3d, 0x84, 0x2e, 0x6a, - 0x3b, 0x2d, 0xf7, 0xaf, 0x7c, 0x5d, 0xe6, 0xdd, 0xec, 0x0d, 0xc4, 0x5d, 0x85, 0xaa, 0xab, 0x52, - 0x91, 0xd1, 0xf8, 0x55, 0x1f, 0xaf, 0xd4, 0xe8, 0x2a, 0x7a, 0x8d, 0xef, 0xf4, 0x48, 0xd7, 0x69, - 0x74, 0x15, 0x5e, 0x23, 0x82, 0xe5, 0x8f, 0x5c, 0x69, 0xaf, 0xc0, 0x76, 0xb0, 0x72, 0xa6, 0x0b, - 0x1b, 0xc5, 0x27, 0xf1, 0xd8, 0x92, 0x4a, 0x82, 0xcd, 0x6c, 0xa4, 0xe8, 0xdc, 0xec, 0x2b, 0x2c, - 0x33, 0x12, 0xc7, 0x6e, 0x82, 0xab, 0x9f, 0xdd, 0x74, 0x74, 0x02, 0x7d, 0xc7, 0xcb, 0x77, 0xf8, - 0x06, 0xab, 0x3b, 0xa1, 0xe5, 0xe9, 0xff, 0x5b, 0xde, 0x41, 0xe4, 0x15, 0x7c, 0xcf, 0xcb, 0x12, - 0xa3, 0xc5, 0x98, 0x5e, 0x58, 0x8c, 0xfd, 0xf3, 0x14, 0xc2, 0x83, 0xfd, 0x70, 0xf0, 0x33, 0x84, - 0x8e, 0x38, 0xc6, 0x7c, 0xb4, 0x2c, 0xe9, 0x9a, 0x9f, 0xad, 0xc2, 0xc4, 0x24, 0x3b, 0xb4, 0x18, - 0xf3, 0xd1, 0x56, 0xa4, 0x6b, 0x7e, 0xc6, 0xdc, 0x26, 0x3b, 0x86, 0x18, 0xf3, 0x11, 0xfe, 0x74, - 0xcd, 0xcf, 0xe0, 0x4e, 0xf0, 0x03, 0xcc, 0x0d, 0x4f, 0x5c, 0xf1, 0x01, 0xe5, 0x34, 0xe2, 0x43, - 0xc8, 0x2e, 0xcd, 0x40, 0xc0, 0x15, 0x1f, 0xc0, 0x4c, 0x23, 0x3e, 0x24, 0xc3, 0x26, 0xf8, 0x09, - 0x6e, 0xec, 0xc3, 0x61, 0xc4, 0x87, 0x08, 0xd2, 0x98, 0x8f, 0xde, 0x93, 0x4d, 0x6e, 0x83, 0xdf, - 0xa1, 0xfd, 0x3b, 0x7c, 0xf9, 0x17, 0x00, 0x00, 0xff, 0xff, 0x05, 0xbb, 0xfd, 0xc1, 0x4a, 0x04, - 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// ConfigClient is the client API for Config service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type ConfigClient interface { - Create(ctx context.Context, in *CreateRequest, opts ...grpc.CallOption) (*CreateResponse, error) - Update(ctx context.Context, in *UpdateRequest, opts ...grpc.CallOption) (*UpdateResponse, error) - Delete(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*DeleteResponse, error) - List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) - Read(ctx context.Context, in *ReadRequest, opts ...grpc.CallOption) (*ReadResponse, error) - Watch(ctx context.Context, in *WatchRequest, opts ...grpc.CallOption) (Config_WatchClient, error) -} - -type configClient struct { - cc *grpc.ClientConn -} - -func NewConfigClient(cc *grpc.ClientConn) ConfigClient { - return &configClient{cc} -} - -func (c *configClient) Create(ctx context.Context, in *CreateRequest, opts ...grpc.CallOption) (*CreateResponse, error) { - out := new(CreateResponse) - err := c.cc.Invoke(ctx, "/Config/Create", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *configClient) Update(ctx context.Context, in *UpdateRequest, opts ...grpc.CallOption) (*UpdateResponse, error) { - out := new(UpdateResponse) - err := c.cc.Invoke(ctx, "/Config/Update", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *configClient) Delete(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*DeleteResponse, error) { - out := new(DeleteResponse) - err := c.cc.Invoke(ctx, "/Config/Delete", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *configClient) List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) { - out := new(ListResponse) - err := c.cc.Invoke(ctx, "/Config/List", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *configClient) Read(ctx context.Context, in *ReadRequest, opts ...grpc.CallOption) (*ReadResponse, error) { - out := new(ReadResponse) - err := c.cc.Invoke(ctx, "/Config/Read", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *configClient) Watch(ctx context.Context, in *WatchRequest, opts ...grpc.CallOption) (Config_WatchClient, error) { - stream, err := c.cc.NewStream(ctx, &_Config_serviceDesc.Streams[0], "/Config/Watch", opts...) - if err != nil { - return nil, err - } - x := &configWatchClient{stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - return x, nil -} - -type Config_WatchClient interface { - Recv() (*WatchResponse, error) - grpc.ClientStream -} - -type configWatchClient struct { - grpc.ClientStream -} - -func (x *configWatchClient) Recv() (*WatchResponse, error) { - m := new(WatchResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -// ConfigServer is the server API for Config service. -type ConfigServer interface { - Create(context.Context, *CreateRequest) (*CreateResponse, error) - Update(context.Context, *UpdateRequest) (*UpdateResponse, error) - Delete(context.Context, *DeleteRequest) (*DeleteResponse, error) - List(context.Context, *ListRequest) (*ListResponse, error) - Read(context.Context, *ReadRequest) (*ReadResponse, error) - Watch(*WatchRequest, Config_WatchServer) error -} - -// UnimplementedConfigServer can be embedded to have forward compatible implementations. -type UnimplementedConfigServer struct { -} - -func (*UnimplementedConfigServer) Create(ctx context.Context, req *CreateRequest) (*CreateResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Create not implemented") -} -func (*UnimplementedConfigServer) Update(ctx context.Context, req *UpdateRequest) (*UpdateResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Update not implemented") -} -func (*UnimplementedConfigServer) Delete(ctx context.Context, req *DeleteRequest) (*DeleteResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented") -} -func (*UnimplementedConfigServer) List(ctx context.Context, req *ListRequest) (*ListResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method List not implemented") -} -func (*UnimplementedConfigServer) Read(ctx context.Context, req *ReadRequest) (*ReadResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Read not implemented") -} -func (*UnimplementedConfigServer) Watch(req *WatchRequest, srv Config_WatchServer) error { - return status.Errorf(codes.Unimplemented, "method Watch not implemented") -} - -func RegisterConfigServer(s *grpc.Server, srv ConfigServer) { - s.RegisterService(&_Config_serviceDesc, srv) -} - -func _Config_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ConfigServer).Create(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/Config/Create", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ConfigServer).Create(ctx, req.(*CreateRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Config_Update_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdateRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ConfigServer).Update(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/Config/Update", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ConfigServer).Update(ctx, req.(*UpdateRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Config_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeleteRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ConfigServer).Delete(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/Config/Delete", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ConfigServer).Delete(ctx, req.(*DeleteRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Config_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ConfigServer).List(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/Config/List", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ConfigServer).List(ctx, req.(*ListRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Config_Read_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ReadRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ConfigServer).Read(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/Config/Read", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ConfigServer).Read(ctx, req.(*ReadRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Config_Watch_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(WatchRequest) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(ConfigServer).Watch(m, &configWatchServer{stream}) -} - -type Config_WatchServer interface { - Send(*WatchResponse) error - grpc.ServerStream -} - -type configWatchServer struct { - grpc.ServerStream -} - -func (x *configWatchServer) Send(m *WatchResponse) error { - return x.ServerStream.SendMsg(m) -} - -var _Config_serviceDesc = grpc.ServiceDesc{ - ServiceName: "Config", - HandlerType: (*ConfigServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Create", - Handler: _Config_Create_Handler, - }, - { - MethodName: "Update", - Handler: _Config_Update_Handler, - }, - { - MethodName: "Delete", - Handler: _Config_Delete_Handler, - }, - { - MethodName: "List", - Handler: _Config_List_Handler, - }, - { - MethodName: "Read", - Handler: _Config_Read_Handler, - }, - }, - Streams: []grpc.StreamDesc{ - { - StreamName: "Watch", - Handler: _Config_Watch_Handler, - ServerStreams: true, - }, - }, - Metadata: "config/source/service/proto/service.proto", -} diff --git a/config/source/service/proto/service.pb.micro.go b/config/source/service/proto/service.pb.micro.go deleted file mode 100644 index d37fc283..00000000 --- a/config/source/service/proto/service.pb.micro.go +++ /dev/null @@ -1,253 +0,0 @@ -// Code generated by protoc-gen-micro. DO NOT EDIT. -// source: config/source/service/proto/service.proto - -package service - -import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" - math "math" -) - -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" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -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 { - Create(ctx context.Context, in *CreateRequest, opts ...client.CallOption) (*CreateResponse, error) - Update(ctx context.Context, in *UpdateRequest, opts ...client.CallOption) (*UpdateResponse, error) - Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error) - List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) - Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error) - Watch(ctx context.Context, in *WatchRequest, opts ...client.CallOption) (Config_WatchService, error) -} - -type configService struct { - c client.Client - name string -} - -func NewConfigService(name string, c client.Client) ConfigService { - return &configService{ - c: c, - name: name, - } -} - -func (c *configService) Create(ctx context.Context, in *CreateRequest, opts ...client.CallOption) (*CreateResponse, error) { - req := c.c.NewRequest(c.name, "Config.Create", in) - out := new(CreateResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *configService) Update(ctx context.Context, in *UpdateRequest, opts ...client.CallOption) (*UpdateResponse, error) { - req := c.c.NewRequest(c.name, "Config.Update", in) - out := new(UpdateResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *configService) Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error) { - req := c.c.NewRequest(c.name, "Config.Delete", in) - out := new(DeleteResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *configService) List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) { - req := c.c.NewRequest(c.name, "Config.List", in) - out := new(ListResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *configService) Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error) { - req := c.c.NewRequest(c.name, "Config.Read", in) - out := new(ReadResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *configService) Watch(ctx context.Context, in *WatchRequest, opts ...client.CallOption) (Config_WatchService, error) { - req := c.c.NewRequest(c.name, "Config.Watch", &WatchRequest{}) - stream, err := c.c.Stream(ctx, req, opts...) - if err != nil { - return nil, err - } - if err := stream.Send(in); err != nil { - return nil, err - } - return &configServiceWatch{stream}, nil -} - -type Config_WatchService interface { - Context() context.Context - SendMsg(interface{}) error - RecvMsg(interface{}) error - Close() error - Recv() (*WatchResponse, error) -} - -type configServiceWatch struct { - stream client.Stream -} - -func (x *configServiceWatch) Close() error { - return x.stream.Close() -} - -func (x *configServiceWatch) Context() context.Context { - return x.stream.Context() -} - -func (x *configServiceWatch) SendMsg(m interface{}) error { - return x.stream.Send(m) -} - -func (x *configServiceWatch) RecvMsg(m interface{}) error { - return x.stream.Recv(m) -} - -func (x *configServiceWatch) Recv() (*WatchResponse, error) { - m := new(WatchResponse) - err := x.stream.Recv(m) - if err != nil { - return nil, err - } - return m, nil -} - -// Server API for Config service - -type ConfigHandler interface { - Create(context.Context, *CreateRequest, *CreateResponse) error - Update(context.Context, *UpdateRequest, *UpdateResponse) error - Delete(context.Context, *DeleteRequest, *DeleteResponse) error - List(context.Context, *ListRequest, *ListResponse) error - Read(context.Context, *ReadRequest, *ReadResponse) error - Watch(context.Context, *WatchRequest, Config_WatchStream) error -} - -func RegisterConfigHandler(s server.Server, hdlr ConfigHandler, opts ...server.HandlerOption) error { - type config interface { - Create(ctx context.Context, in *CreateRequest, out *CreateResponse) error - Update(ctx context.Context, in *UpdateRequest, out *UpdateResponse) error - Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error - List(ctx context.Context, in *ListRequest, out *ListResponse) error - Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error - Watch(ctx context.Context, stream server.Stream) error - } - type Config struct { - config - } - h := &configHandler{hdlr} - return s.Handle(s.NewHandler(&Config{h}, opts...)) -} - -type configHandler struct { - ConfigHandler -} - -func (h *configHandler) Create(ctx context.Context, in *CreateRequest, out *CreateResponse) error { - return h.ConfigHandler.Create(ctx, in, out) -} - -func (h *configHandler) Update(ctx context.Context, in *UpdateRequest, out *UpdateResponse) error { - return h.ConfigHandler.Update(ctx, in, out) -} - -func (h *configHandler) Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error { - return h.ConfigHandler.Delete(ctx, in, out) -} - -func (h *configHandler) List(ctx context.Context, in *ListRequest, out *ListResponse) error { - return h.ConfigHandler.List(ctx, in, out) -} - -func (h *configHandler) Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error { - return h.ConfigHandler.Read(ctx, in, out) -} - -func (h *configHandler) Watch(ctx context.Context, stream server.Stream) error { - m := new(WatchRequest) - if err := stream.Recv(m); err != nil { - return err - } - return h.ConfigHandler.Watch(ctx, m, &configWatchStream{stream}) -} - -type Config_WatchStream interface { - Context() context.Context - SendMsg(interface{}) error - RecvMsg(interface{}) error - Close() error - Send(*WatchResponse) error -} - -type configWatchStream struct { - stream server.Stream -} - -func (x *configWatchStream) Close() error { - return x.stream.Close() -} - -func (x *configWatchStream) Context() context.Context { - return x.stream.Context() -} - -func (x *configWatchStream) SendMsg(m interface{}) error { - return x.stream.Send(m) -} - -func (x *configWatchStream) RecvMsg(m interface{}) error { - return x.stream.Recv(m) -} - -func (x *configWatchStream) Send(m *WatchResponse) error { - return x.stream.Send(m) -} diff --git a/config/source/service/proto/service.proto b/config/source/service/proto/service.proto deleted file mode 100644 index 68ddabad..00000000 --- a/config/source/service/proto/service.proto +++ /dev/null @@ -1,67 +0,0 @@ -syntax = "proto3"; - -service Config { - rpc Create (CreateRequest) returns (CreateResponse) {} - rpc Update (UpdateRequest) returns (UpdateResponse) {} - rpc Delete (DeleteRequest) returns (DeleteResponse) {} - rpc List (ListRequest) returns (ListResponse) {} - rpc Read (ReadRequest) returns (ReadResponse) {} - rpc Watch (WatchRequest) returns (stream WatchResponse) {} -} - -message ChangeSet { - string data = 1; - string checksum = 2; - string format = 3; - string source = 4; - int64 timestamp = 5; -} - -message Change { - string namespace = 1; - string path = 2; - ChangeSet changeSet = 3; -} - -message CreateRequest { - Change change = 1; -} - -message CreateResponse {} - -message UpdateRequest { - Change change = 1; -} - -message UpdateResponse {} - -message DeleteRequest { - Change change = 1; -} - -message DeleteResponse {} - -message ListRequest {} - -message ListResponse { - repeated Change values = 1; -} - -message ReadRequest { - string namespace = 1; - string path = 2; -} - -message ReadResponse { - Change change = 1; -} - -message WatchRequest { - string namespace = 1; - string path = 2; -} - -message WatchResponse { - string namespace = 1; - ChangeSet changeSet = 2; -} diff --git a/config/source/service/service.go b/config/source/service/service.go deleted file mode 100644 index 25c06d52..00000000 --- a/config/source/service/service.go +++ /dev/null @@ -1,106 +0,0 @@ -package service - -import ( - "context" - "net/http" - - "github.com/micro/go-micro/v2/client" - "github.com/micro/go-micro/v2/config/source" - proto "github.com/micro/go-micro/v2/config/source/service/proto" - "github.com/micro/go-micro/v2/errors" - "github.com/micro/go-micro/v2/logger" -) - -var ( - DefaultName = "go.micro.config" - DefaultNamespace = "global" - DefaultPath = "" -) - -type service struct { - serviceName string - namespace string - path string - opts source.Options - client proto.ConfigService -} - -func (m *service) Read() (set *source.ChangeSet, err error) { - client := proto.NewConfigService(m.serviceName, m.opts.Client) - req, err := client.Read(context.Background(), &proto.ReadRequest{ - Namespace: m.namespace, - Path: m.path, - }) - if verr, ok := err.(*errors.Error); ok && verr.Code == http.StatusNotFound { - return nil, nil - } else if err != nil { - return nil, err - } - - return toChangeSet(req.Change.ChangeSet), nil -} - -func (m *service) Watch() (w source.Watcher, err error) { - client := proto.NewConfigService(m.serviceName, m.opts.Client) - stream, err := client.Watch(context.Background(), &proto.WatchRequest{ - Namespace: m.namespace, - Path: m.path, - }) - if err != nil { - if logger.V(logger.ErrorLevel, logger.DefaultLogger) { - logger.Error("watch err: ", err) - } - return - } - return newWatcher(stream) -} - -// Write is unsupported -func (m *service) Write(cs *source.ChangeSet) error { - return nil -} - -func (m *service) String() string { - return "service" -} - -func NewSource(opts ...source.Option) source.Source { - var options source.Options - for _, o := range opts { - o(&options) - } - - addr := DefaultName - namespace := DefaultNamespace - path := DefaultPath - - if options.Context != nil { - a, ok := options.Context.Value(serviceNameKey{}).(string) - if ok { - addr = a - } - - k, ok := options.Context.Value(namespaceKey{}).(string) - if ok { - namespace = k - } - - p, ok := options.Context.Value(pathKey{}).(string) - if ok { - path = p - } - } - - if options.Client == nil { - options.Client = client.DefaultClient - } - - s := &service{ - serviceName: addr, - opts: options, - namespace: namespace, - path: path, - } - - return s -} diff --git a/config/source/service/util.go b/config/source/service/util.go deleted file mode 100644 index ad301918..00000000 --- a/config/source/service/util.go +++ /dev/null @@ -1,18 +0,0 @@ -package service - -import ( - "time" - - "github.com/micro/go-micro/v2/config/source" - proto "github.com/micro/go-micro/v2/config/source/service/proto" -) - -func toChangeSet(c *proto.ChangeSet) *source.ChangeSet { - return &source.ChangeSet{ - Data: []byte(c.Data), - Checksum: c.Checksum, - Format: c.Format, - Timestamp: time.Unix(c.Timestamp, 0), - Source: c.Source, - } -} diff --git a/config/source/service/watcher.go b/config/source/service/watcher.go deleted file mode 100644 index c99e5f7c..00000000 --- a/config/source/service/watcher.go +++ /dev/null @@ -1,27 +0,0 @@ -package service - -import ( - "github.com/micro/go-micro/v2/config/source" - proto "github.com/micro/go-micro/v2/config/source/service/proto" -) - -type watcher struct { - stream proto.Config_WatchService -} - -func newWatcher(stream proto.Config_WatchService) (source.Watcher, error) { - return &watcher{stream: stream}, nil -} - -func (w *watcher) Next() (*source.ChangeSet, error) { - var rsp proto.WatchResponse - err := w.stream.RecvMsg(&rsp) - if err != nil { - return nil, err - } - return toChangeSet(rsp.ChangeSet), nil -} - -func (w *watcher) Stop() error { - return w.stream.Close() -} diff --git a/go.mod b/go.mod index 617e0e48..08c207c6 100644 --- a/go.mod +++ b/go.mod @@ -63,6 +63,6 @@ require ( golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1 google.golang.org/grpc v1.26.0 - google.golang.org/protobuf v1.22.0 + google.golang.org/protobuf v1.22.0 // indirect sigs.k8s.io/yaml v1.1.0 // indirect ) diff --git a/registry/service/options.go b/registry/service/options.go deleted file mode 100644 index fd251d77..00000000 --- a/registry/service/options.go +++ /dev/null @@ -1,21 +0,0 @@ -package service - -import ( - "context" - - "github.com/micro/go-micro/v2/client" - "github.com/micro/go-micro/v2/registry" -) - -type clientKey struct{} - -// WithClient sets the RPC client -func WithClient(c client.Client) registry.Option { - return func(o *registry.Options) { - if o.Context == nil { - o.Context = context.Background() - } - - o.Context = context.WithValue(o.Context, clientKey{}, c) - } -} diff --git a/registry/service/proto/registry.pb.go b/registry/service/proto/registry.pb.go deleted file mode 100644 index fe8063e6..00000000 --- a/registry/service/proto/registry.pb.go +++ /dev/null @@ -1,1024 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: registry/service/proto/registry.proto - -package go_micro_registry - -import ( - context "context" - fmt "fmt" - proto "github.com/golang/protobuf/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - math "math" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package - -// EventType defines the type of event -type EventType int32 - -const ( - EventType_Create EventType = 0 - EventType_Delete EventType = 1 - EventType_Update EventType = 2 -) - -var EventType_name = map[int32]string{ - 0: "Create", - 1: "Delete", - 2: "Update", -} - -var EventType_value = map[string]int32{ - "Create": 0, - "Delete": 1, - "Update": 2, -} - -func (x EventType) String() string { - return proto.EnumName(EventType_name, int32(x)) -} - -func (EventType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_3f5817c11f323eb6, []int{0} -} - -// Service represents a go-micro service -type Service struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` - Metadata map[string]string `protobuf:"bytes,3,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - Endpoints []*Endpoint `protobuf:"bytes,4,rep,name=endpoints,proto3" json:"endpoints,omitempty"` - Nodes []*Node `protobuf:"bytes,5,rep,name=nodes,proto3" json:"nodes,omitempty"` - Options *Options `protobuf:"bytes,6,opt,name=options,proto3" json:"options,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Service) Reset() { *m = Service{} } -func (m *Service) String() string { return proto.CompactTextString(m) } -func (*Service) ProtoMessage() {} -func (*Service) Descriptor() ([]byte, []int) { - return fileDescriptor_3f5817c11f323eb6, []int{0} -} - -func (m *Service) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Service.Unmarshal(m, b) -} -func (m *Service) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Service.Marshal(b, m, deterministic) -} -func (m *Service) XXX_Merge(src proto.Message) { - xxx_messageInfo_Service.Merge(m, src) -} -func (m *Service) XXX_Size() int { - return xxx_messageInfo_Service.Size(m) -} -func (m *Service) XXX_DiscardUnknown() { - xxx_messageInfo_Service.DiscardUnknown(m) -} - -var xxx_messageInfo_Service proto.InternalMessageInfo - -func (m *Service) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *Service) GetVersion() string { - if m != nil { - return m.Version - } - return "" -} - -func (m *Service) GetMetadata() map[string]string { - if m != nil { - return m.Metadata - } - return nil -} - -func (m *Service) GetEndpoints() []*Endpoint { - if m != nil { - return m.Endpoints - } - return nil -} - -func (m *Service) GetNodes() []*Node { - if m != nil { - return m.Nodes - } - return nil -} - -func (m *Service) GetOptions() *Options { - if m != nil { - return m.Options - } - return nil -} - -// Node represents the node the service is on -type Node struct { - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` - Port int64 `protobuf:"varint,3,opt,name=port,proto3" json:"port,omitempty"` - Metadata map[string]string `protobuf:"bytes,4,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Node) Reset() { *m = Node{} } -func (m *Node) String() string { return proto.CompactTextString(m) } -func (*Node) ProtoMessage() {} -func (*Node) Descriptor() ([]byte, []int) { - return fileDescriptor_3f5817c11f323eb6, []int{1} -} - -func (m *Node) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Node.Unmarshal(m, b) -} -func (m *Node) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Node.Marshal(b, m, deterministic) -} -func (m *Node) XXX_Merge(src proto.Message) { - xxx_messageInfo_Node.Merge(m, src) -} -func (m *Node) XXX_Size() int { - return xxx_messageInfo_Node.Size(m) -} -func (m *Node) XXX_DiscardUnknown() { - xxx_messageInfo_Node.DiscardUnknown(m) -} - -var xxx_messageInfo_Node proto.InternalMessageInfo - -func (m *Node) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -func (m *Node) GetAddress() string { - if m != nil { - return m.Address - } - return "" -} - -func (m *Node) GetPort() int64 { - if m != nil { - return m.Port - } - return 0 -} - -func (m *Node) GetMetadata() map[string]string { - if m != nil { - return m.Metadata - } - return nil -} - -// Endpoint is a endpoint provided by a service -type Endpoint struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Request *Value `protobuf:"bytes,2,opt,name=request,proto3" json:"request,omitempty"` - Response *Value `protobuf:"bytes,3,opt,name=response,proto3" json:"response,omitempty"` - Metadata map[string]string `protobuf:"bytes,4,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Endpoint) Reset() { *m = Endpoint{} } -func (m *Endpoint) String() string { return proto.CompactTextString(m) } -func (*Endpoint) ProtoMessage() {} -func (*Endpoint) Descriptor() ([]byte, []int) { - return fileDescriptor_3f5817c11f323eb6, []int{2} -} - -func (m *Endpoint) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Endpoint.Unmarshal(m, b) -} -func (m *Endpoint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Endpoint.Marshal(b, m, deterministic) -} -func (m *Endpoint) XXX_Merge(src proto.Message) { - xxx_messageInfo_Endpoint.Merge(m, src) -} -func (m *Endpoint) XXX_Size() int { - return xxx_messageInfo_Endpoint.Size(m) -} -func (m *Endpoint) XXX_DiscardUnknown() { - xxx_messageInfo_Endpoint.DiscardUnknown(m) -} - -var xxx_messageInfo_Endpoint proto.InternalMessageInfo - -func (m *Endpoint) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *Endpoint) GetRequest() *Value { - if m != nil { - return m.Request - } - return nil -} - -func (m *Endpoint) GetResponse() *Value { - if m != nil { - return m.Response - } - return nil -} - -func (m *Endpoint) GetMetadata() map[string]string { - if m != nil { - return m.Metadata - } - return nil -} - -// Value is an opaque value for a request or response -type Value struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` - Values []*Value `protobuf:"bytes,3,rep,name=values,proto3" json:"values,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Value) Reset() { *m = Value{} } -func (m *Value) String() string { return proto.CompactTextString(m) } -func (*Value) ProtoMessage() {} -func (*Value) Descriptor() ([]byte, []int) { - return fileDescriptor_3f5817c11f323eb6, []int{3} -} - -func (m *Value) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Value.Unmarshal(m, b) -} -func (m *Value) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Value.Marshal(b, m, deterministic) -} -func (m *Value) XXX_Merge(src proto.Message) { - xxx_messageInfo_Value.Merge(m, src) -} -func (m *Value) XXX_Size() int { - return xxx_messageInfo_Value.Size(m) -} -func (m *Value) XXX_DiscardUnknown() { - xxx_messageInfo_Value.DiscardUnknown(m) -} - -var xxx_messageInfo_Value proto.InternalMessageInfo - -func (m *Value) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *Value) GetType() string { - if m != nil { - return m.Type - } - return "" -} - -func (m *Value) GetValues() []*Value { - if m != nil { - return m.Values - } - return nil -} - -// Options are registry options -type Options struct { - Ttl int64 `protobuf:"varint,1,opt,name=ttl,proto3" json:"ttl,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Options) Reset() { *m = Options{} } -func (m *Options) String() string { return proto.CompactTextString(m) } -func (*Options) ProtoMessage() {} -func (*Options) Descriptor() ([]byte, []int) { - return fileDescriptor_3f5817c11f323eb6, []int{4} -} - -func (m *Options) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Options.Unmarshal(m, b) -} -func (m *Options) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Options.Marshal(b, m, deterministic) -} -func (m *Options) XXX_Merge(src proto.Message) { - xxx_messageInfo_Options.Merge(m, src) -} -func (m *Options) XXX_Size() int { - return xxx_messageInfo_Options.Size(m) -} -func (m *Options) XXX_DiscardUnknown() { - xxx_messageInfo_Options.DiscardUnknown(m) -} - -var xxx_messageInfo_Options proto.InternalMessageInfo - -func (m *Options) GetTtl() int64 { - if m != nil { - return m.Ttl - } - return 0 -} - -// Result is returns by the watcher -type Result struct { - Action string `protobuf:"bytes,1,opt,name=action,proto3" json:"action,omitempty"` - Service *Service `protobuf:"bytes,2,opt,name=service,proto3" json:"service,omitempty"` - Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Result) Reset() { *m = Result{} } -func (m *Result) String() string { return proto.CompactTextString(m) } -func (*Result) ProtoMessage() {} -func (*Result) Descriptor() ([]byte, []int) { - return fileDescriptor_3f5817c11f323eb6, []int{5} -} - -func (m *Result) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Result.Unmarshal(m, b) -} -func (m *Result) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Result.Marshal(b, m, deterministic) -} -func (m *Result) XXX_Merge(src proto.Message) { - xxx_messageInfo_Result.Merge(m, src) -} -func (m *Result) XXX_Size() int { - return xxx_messageInfo_Result.Size(m) -} -func (m *Result) XXX_DiscardUnknown() { - xxx_messageInfo_Result.DiscardUnknown(m) -} - -var xxx_messageInfo_Result proto.InternalMessageInfo - -func (m *Result) GetAction() string { - if m != nil { - return m.Action - } - return "" -} - -func (m *Result) GetService() *Service { - if m != nil { - return m.Service - } - return nil -} - -func (m *Result) GetTimestamp() int64 { - if m != nil { - return m.Timestamp - } - return 0 -} - -type EmptyResponse struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *EmptyResponse) Reset() { *m = EmptyResponse{} } -func (m *EmptyResponse) String() string { return proto.CompactTextString(m) } -func (*EmptyResponse) ProtoMessage() {} -func (*EmptyResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_3f5817c11f323eb6, []int{6} -} - -func (m *EmptyResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_EmptyResponse.Unmarshal(m, b) -} -func (m *EmptyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_EmptyResponse.Marshal(b, m, deterministic) -} -func (m *EmptyResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_EmptyResponse.Merge(m, src) -} -func (m *EmptyResponse) XXX_Size() int { - return xxx_messageInfo_EmptyResponse.Size(m) -} -func (m *EmptyResponse) XXX_DiscardUnknown() { - xxx_messageInfo_EmptyResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_EmptyResponse proto.InternalMessageInfo - -type GetRequest struct { - Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetRequest) Reset() { *m = GetRequest{} } -func (m *GetRequest) String() string { return proto.CompactTextString(m) } -func (*GetRequest) ProtoMessage() {} -func (*GetRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_3f5817c11f323eb6, []int{7} -} - -func (m *GetRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetRequest.Unmarshal(m, b) -} -func (m *GetRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetRequest.Marshal(b, m, deterministic) -} -func (m *GetRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetRequest.Merge(m, src) -} -func (m *GetRequest) XXX_Size() int { - return xxx_messageInfo_GetRequest.Size(m) -} -func (m *GetRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GetRequest proto.InternalMessageInfo - -func (m *GetRequest) GetService() string { - if m != nil { - return m.Service - } - return "" -} - -type GetResponse struct { - Services []*Service `protobuf:"bytes,1,rep,name=services,proto3" json:"services,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetResponse) Reset() { *m = GetResponse{} } -func (m *GetResponse) String() string { return proto.CompactTextString(m) } -func (*GetResponse) ProtoMessage() {} -func (*GetResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_3f5817c11f323eb6, []int{8} -} - -func (m *GetResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetResponse.Unmarshal(m, b) -} -func (m *GetResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetResponse.Marshal(b, m, deterministic) -} -func (m *GetResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetResponse.Merge(m, src) -} -func (m *GetResponse) XXX_Size() int { - return xxx_messageInfo_GetResponse.Size(m) -} -func (m *GetResponse) XXX_DiscardUnknown() { - xxx_messageInfo_GetResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_GetResponse proto.InternalMessageInfo - -func (m *GetResponse) GetServices() []*Service { - if m != nil { - return m.Services - } - return nil -} - -type ListRequest struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListRequest) Reset() { *m = ListRequest{} } -func (m *ListRequest) String() string { return proto.CompactTextString(m) } -func (*ListRequest) ProtoMessage() {} -func (*ListRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_3f5817c11f323eb6, []int{9} -} - -func (m *ListRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListRequest.Unmarshal(m, b) -} -func (m *ListRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListRequest.Marshal(b, m, deterministic) -} -func (m *ListRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListRequest.Merge(m, src) -} -func (m *ListRequest) XXX_Size() int { - return xxx_messageInfo_ListRequest.Size(m) -} -func (m *ListRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ListRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ListRequest proto.InternalMessageInfo - -type ListResponse struct { - Services []*Service `protobuf:"bytes,1,rep,name=services,proto3" json:"services,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListResponse) Reset() { *m = ListResponse{} } -func (m *ListResponse) String() string { return proto.CompactTextString(m) } -func (*ListResponse) ProtoMessage() {} -func (*ListResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_3f5817c11f323eb6, []int{10} -} - -func (m *ListResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListResponse.Unmarshal(m, b) -} -func (m *ListResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListResponse.Marshal(b, m, deterministic) -} -func (m *ListResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListResponse.Merge(m, src) -} -func (m *ListResponse) XXX_Size() int { - return xxx_messageInfo_ListResponse.Size(m) -} -func (m *ListResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ListResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_ListResponse proto.InternalMessageInfo - -func (m *ListResponse) GetServices() []*Service { - if m != nil { - return m.Services - } - return nil -} - -type WatchRequest struct { - // service is optional - Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *WatchRequest) Reset() { *m = WatchRequest{} } -func (m *WatchRequest) String() string { return proto.CompactTextString(m) } -func (*WatchRequest) ProtoMessage() {} -func (*WatchRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_3f5817c11f323eb6, []int{11} -} - -func (m *WatchRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_WatchRequest.Unmarshal(m, b) -} -func (m *WatchRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_WatchRequest.Marshal(b, m, deterministic) -} -func (m *WatchRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_WatchRequest.Merge(m, src) -} -func (m *WatchRequest) XXX_Size() int { - return xxx_messageInfo_WatchRequest.Size(m) -} -func (m *WatchRequest) XXX_DiscardUnknown() { - xxx_messageInfo_WatchRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_WatchRequest proto.InternalMessageInfo - -func (m *WatchRequest) GetService() string { - if m != nil { - return m.Service - } - return "" -} - -// Event is registry event -type Event struct { - // Event Id - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - // type of event - Type EventType `protobuf:"varint,2,opt,name=type,proto3,enum=go.micro.registry.EventType" json:"type,omitempty"` - // unix timestamp of event - Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - // service entry - Service *Service `protobuf:"bytes,4,opt,name=service,proto3" json:"service,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Event) Reset() { *m = Event{} } -func (m *Event) String() string { return proto.CompactTextString(m) } -func (*Event) ProtoMessage() {} -func (*Event) Descriptor() ([]byte, []int) { - return fileDescriptor_3f5817c11f323eb6, []int{12} -} - -func (m *Event) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Event.Unmarshal(m, b) -} -func (m *Event) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Event.Marshal(b, m, deterministic) -} -func (m *Event) XXX_Merge(src proto.Message) { - xxx_messageInfo_Event.Merge(m, src) -} -func (m *Event) XXX_Size() int { - return xxx_messageInfo_Event.Size(m) -} -func (m *Event) XXX_DiscardUnknown() { - xxx_messageInfo_Event.DiscardUnknown(m) -} - -var xxx_messageInfo_Event proto.InternalMessageInfo - -func (m *Event) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -func (m *Event) GetType() EventType { - if m != nil { - return m.Type - } - return EventType_Create -} - -func (m *Event) GetTimestamp() int64 { - if m != nil { - return m.Timestamp - } - return 0 -} - -func (m *Event) GetService() *Service { - if m != nil { - return m.Service - } - return nil -} - -func init() { - proto.RegisterEnum("go.micro.registry.EventType", EventType_name, EventType_value) - proto.RegisterType((*Service)(nil), "go.micro.registry.Service") - proto.RegisterMapType((map[string]string)(nil), "go.micro.registry.Service.MetadataEntry") - proto.RegisterType((*Node)(nil), "go.micro.registry.Node") - proto.RegisterMapType((map[string]string)(nil), "go.micro.registry.Node.MetadataEntry") - proto.RegisterType((*Endpoint)(nil), "go.micro.registry.Endpoint") - proto.RegisterMapType((map[string]string)(nil), "go.micro.registry.Endpoint.MetadataEntry") - proto.RegisterType((*Value)(nil), "go.micro.registry.Value") - proto.RegisterType((*Options)(nil), "go.micro.registry.Options") - proto.RegisterType((*Result)(nil), "go.micro.registry.Result") - proto.RegisterType((*EmptyResponse)(nil), "go.micro.registry.EmptyResponse") - proto.RegisterType((*GetRequest)(nil), "go.micro.registry.GetRequest") - proto.RegisterType((*GetResponse)(nil), "go.micro.registry.GetResponse") - proto.RegisterType((*ListRequest)(nil), "go.micro.registry.ListRequest") - proto.RegisterType((*ListResponse)(nil), "go.micro.registry.ListResponse") - proto.RegisterType((*WatchRequest)(nil), "go.micro.registry.WatchRequest") - proto.RegisterType((*Event)(nil), "go.micro.registry.Event") -} - -func init() { - proto.RegisterFile("registry/service/proto/registry.proto", fileDescriptor_3f5817c11f323eb6) -} - -var fileDescriptor_3f5817c11f323eb6 = []byte{ - // 675 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xdd, 0x6e, 0xd3, 0x4c, - 0x10, 0x8d, 0xed, 0xfc, 0x4e, 0xda, 0x7e, 0xfd, 0x46, 0x08, 0x8c, 0x5b, 0x20, 0xb2, 0x54, 0x14, - 0x90, 0x48, 0xaa, 0x50, 0x21, 0x7e, 0xae, 0x10, 0x0d, 0x95, 0x50, 0x0b, 0x62, 0xf9, 0xbb, 0x36, - 0xf1, 0xa8, 0x58, 0x24, 0xb6, 0xd9, 0xdd, 0x46, 0xca, 0x3b, 0x20, 0xf1, 0x04, 0xbc, 0x0d, 0x4f, - 0xc1, 0xd3, 0xa0, 0x5d, 0xef, 0x26, 0xa9, 0xea, 0x04, 0xa4, 0xc2, 0xdd, 0xcc, 0xee, 0x39, 0xb3, - 0xb3, 0x67, 0xce, 0xda, 0xb0, 0xc7, 0xe9, 0x34, 0x11, 0x92, 0xcf, 0xfa, 0x82, 0xf8, 0x34, 0x19, - 0x51, 0x3f, 0xe7, 0x99, 0xcc, 0xfa, 0x76, 0xb9, 0xa7, 0x53, 0xfc, 0xff, 0x34, 0xeb, 0x4d, 0x92, - 0x11, 0xcf, 0x7a, 0x76, 0x23, 0xfc, 0xe9, 0x42, 0xe3, 0x4d, 0xc1, 0x41, 0x84, 0x6a, 0x1a, 0x4d, - 0xc8, 0x77, 0x3a, 0x4e, 0xb7, 0xc5, 0x74, 0x8c, 0x3e, 0x34, 0xa6, 0xc4, 0x45, 0x92, 0xa5, 0xbe, - 0xab, 0x97, 0x6d, 0x8a, 0x87, 0xd0, 0x9c, 0x90, 0x8c, 0xe2, 0x48, 0x46, 0xbe, 0xd7, 0xf1, 0xba, - 0xed, 0x41, 0xb7, 0x77, 0xa1, 0x7e, 0xcf, 0xd4, 0xee, 0x9d, 0x18, 0xe8, 0x30, 0x95, 0x7c, 0xc6, - 0xe6, 0x4c, 0x7c, 0x04, 0x2d, 0x4a, 0xe3, 0x3c, 0x4b, 0x52, 0x29, 0xfc, 0xaa, 0x2e, 0xb3, 0x53, - 0x52, 0x66, 0x68, 0x30, 0x6c, 0x81, 0xc6, 0x7b, 0x50, 0x4b, 0xb3, 0x98, 0x84, 0x5f, 0xd3, 0xb4, - 0x6b, 0x25, 0xb4, 0x97, 0x59, 0x4c, 0xac, 0x40, 0xe1, 0x01, 0x34, 0xb2, 0x5c, 0x26, 0x59, 0x2a, - 0xfc, 0x7a, 0xc7, 0xe9, 0xb6, 0x07, 0x41, 0x09, 0xe1, 0x55, 0x81, 0x60, 0x16, 0x1a, 0x3c, 0x81, - 0xcd, 0x73, 0xad, 0xe3, 0x36, 0x78, 0x9f, 0x69, 0x66, 0x34, 0x52, 0x21, 0x5e, 0x81, 0xda, 0x34, - 0x1a, 0x9f, 0x91, 0x11, 0xa8, 0x48, 0x1e, 0xbb, 0x0f, 0x9d, 0xf0, 0x87, 0x03, 0x55, 0xd5, 0x02, - 0x6e, 0x81, 0x9b, 0xc4, 0x86, 0xe3, 0x26, 0xb1, 0x52, 0x35, 0x8a, 0x63, 0x4e, 0x42, 0x58, 0x55, - 0x4d, 0xaa, 0x66, 0x90, 0x67, 0x5c, 0xfa, 0x5e, 0xc7, 0xe9, 0x7a, 0x4c, 0xc7, 0xf8, 0x74, 0x49, - 0xe9, 0x42, 0xa2, 0xbd, 0x15, 0x77, 0x5d, 0x25, 0xf3, 0xe5, 0xae, 0xf1, 0xd5, 0x85, 0xa6, 0x1d, - 0x40, 0xa9, 0x49, 0x06, 0xd0, 0xe0, 0xf4, 0xe5, 0x8c, 0x84, 0xd4, 0xe4, 0xf6, 0xc0, 0x2f, 0xe9, - 0xef, 0xbd, 0xaa, 0xc7, 0x2c, 0x10, 0x0f, 0xa0, 0xc9, 0x49, 0xe4, 0x59, 0x2a, 0x48, 0x5f, 0x76, - 0x1d, 0x69, 0x8e, 0xc4, 0xe1, 0x05, 0x29, 0xee, 0xac, 0x71, 0xcb, 0xbf, 0x91, 0x23, 0x82, 0x9a, - 0x6e, 0xab, 0x54, 0x0a, 0x84, 0xaa, 0x9c, 0xe5, 0x96, 0xa5, 0x63, 0xdc, 0x87, 0xba, 0x66, 0x0b, - 0xf3, 0x4e, 0x56, 0x5f, 0xd4, 0xe0, 0xc2, 0x1d, 0x68, 0x18, 0x27, 0xaa, 0xce, 0xa4, 0x1c, 0xeb, - 0x33, 0x3c, 0xa6, 0xc2, 0x50, 0x42, 0x9d, 0x91, 0x38, 0x1b, 0x4b, 0xbc, 0x0a, 0xf5, 0x68, 0xa4, - 0x60, 0xa6, 0x05, 0x93, 0x29, 0xab, 0x9b, 0xef, 0x80, 0x99, 0x47, 0xb0, 0xfa, 0x65, 0x32, 0x0b, - 0xc5, 0x5d, 0x68, 0xc9, 0x64, 0x42, 0x42, 0x46, 0x93, 0xdc, 0xf8, 0x6f, 0xb1, 0x10, 0xfe, 0x07, - 0x9b, 0xc3, 0x49, 0x2e, 0x67, 0xcc, 0x8c, 0x22, 0xbc, 0x0d, 0x70, 0x44, 0x92, 0x99, 0x71, 0xfa, - 0x8b, 0x23, 0x8b, 0x5e, 0x6c, 0x1a, 0x0e, 0xa1, 0xad, 0x71, 0x66, 0x82, 0x0f, 0xa0, 0x69, 0x76, - 0x84, 0xef, 0x68, 0x39, 0xd6, 0x35, 0x37, 0xc7, 0x86, 0x9b, 0xd0, 0x3e, 0x4e, 0x84, 0x3d, 0x2f, - 0x7c, 0x0e, 0x1b, 0x45, 0x7a, 0xc9, 0xb2, 0x5d, 0xd8, 0xf8, 0x10, 0xc9, 0xd1, 0xa7, 0xdf, 0xdf, - 0xe3, 0xbb, 0x03, 0xb5, 0xe1, 0x94, 0x52, 0x79, 0xe1, 0x35, 0xef, 0x2f, 0xcd, 0x7c, 0x6b, 0xb0, - 0x5b, 0x66, 0x48, 0xc5, 0x7b, 0x3b, 0xcb, 0xc9, 0x38, 0x62, 0xad, 0xd4, 0xcb, 0xe3, 0xab, 0xfe, - 0xf1, 0xf8, 0xee, 0xf6, 0xa1, 0x35, 0x3f, 0x06, 0x01, 0xea, 0xcf, 0x38, 0x45, 0x92, 0xb6, 0x2b, - 0x2a, 0x3e, 0xa4, 0x31, 0x49, 0xda, 0x76, 0x54, 0xfc, 0x2e, 0x8f, 0xd5, 0xba, 0x3b, 0xf8, 0xe6, - 0x41, 0x93, 0x99, 0x72, 0x78, 0xa2, 0xa7, 0x69, 0xff, 0x04, 0x37, 0x4a, 0x0e, 0x5c, 0x0c, 0x3b, - 0xb8, 0xb9, 0x6a, 0xdb, 0x58, 0xa3, 0x82, 0x2f, 0x6c, 0x69, 0xe2, 0xb8, 0xa6, 0xfb, 0xa0, 0x53, - 0x26, 0xd6, 0x39, 0x9b, 0x55, 0xf0, 0x18, 0xe0, 0x90, 0xf8, 0xdf, 0xaa, 0xf6, 0xba, 0x30, 0x8e, - 0xa1, 0x08, 0x2c, 0xbb, 0xcb, 0x92, 0xd1, 0x82, 0x5b, 0x2b, 0xf7, 0xe7, 0x25, 0x8f, 0xa0, 0xa6, - 0x3d, 0x84, 0x65, 0xd8, 0x65, 0x77, 0x05, 0xd7, 0x4b, 0x00, 0xc5, 0x5b, 0x0e, 0x2b, 0xfb, 0xce, - 0xc7, 0xba, 0xfe, 0x4d, 0xdf, 0xff, 0x15, 0x00, 0x00, 0xff, 0xff, 0xc6, 0xa5, 0x5a, 0xc9, 0xcf, - 0x07, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// RegistryClient is the client API for Registry service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type RegistryClient interface { - GetService(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error) - Register(ctx context.Context, in *Service, opts ...grpc.CallOption) (*EmptyResponse, error) - Deregister(ctx context.Context, in *Service, opts ...grpc.CallOption) (*EmptyResponse, error) - ListServices(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) - Watch(ctx context.Context, in *WatchRequest, opts ...grpc.CallOption) (Registry_WatchClient, error) -} - -type registryClient struct { - cc *grpc.ClientConn -} - -func NewRegistryClient(cc *grpc.ClientConn) RegistryClient { - return ®istryClient{cc} -} - -func (c *registryClient) GetService(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error) { - out := new(GetResponse) - err := c.cc.Invoke(ctx, "/go.micro.registry.Registry/GetService", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *registryClient) Register(ctx context.Context, in *Service, opts ...grpc.CallOption) (*EmptyResponse, error) { - out := new(EmptyResponse) - err := c.cc.Invoke(ctx, "/go.micro.registry.Registry/Register", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *registryClient) Deregister(ctx context.Context, in *Service, opts ...grpc.CallOption) (*EmptyResponse, error) { - out := new(EmptyResponse) - err := c.cc.Invoke(ctx, "/go.micro.registry.Registry/Deregister", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *registryClient) ListServices(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) { - out := new(ListResponse) - err := c.cc.Invoke(ctx, "/go.micro.registry.Registry/ListServices", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *registryClient) Watch(ctx context.Context, in *WatchRequest, opts ...grpc.CallOption) (Registry_WatchClient, error) { - stream, err := c.cc.NewStream(ctx, &_Registry_serviceDesc.Streams[0], "/go.micro.registry.Registry/Watch", opts...) - if err != nil { - return nil, err - } - x := ®istryWatchClient{stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - return x, nil -} - -type Registry_WatchClient interface { - Recv() (*Result, error) - grpc.ClientStream -} - -type registryWatchClient struct { - grpc.ClientStream -} - -func (x *registryWatchClient) Recv() (*Result, error) { - m := new(Result) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -// RegistryServer is the server API for Registry service. -type RegistryServer interface { - GetService(context.Context, *GetRequest) (*GetResponse, error) - Register(context.Context, *Service) (*EmptyResponse, error) - Deregister(context.Context, *Service) (*EmptyResponse, error) - ListServices(context.Context, *ListRequest) (*ListResponse, error) - Watch(*WatchRequest, Registry_WatchServer) error -} - -// UnimplementedRegistryServer can be embedded to have forward compatible implementations. -type UnimplementedRegistryServer struct { -} - -func (*UnimplementedRegistryServer) GetService(ctx context.Context, req *GetRequest) (*GetResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetService not implemented") -} -func (*UnimplementedRegistryServer) Register(ctx context.Context, req *Service) (*EmptyResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Register not implemented") -} -func (*UnimplementedRegistryServer) Deregister(ctx context.Context, req *Service) (*EmptyResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Deregister not implemented") -} -func (*UnimplementedRegistryServer) ListServices(ctx context.Context, req *ListRequest) (*ListResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListServices not implemented") -} -func (*UnimplementedRegistryServer) Watch(req *WatchRequest, srv Registry_WatchServer) error { - return status.Errorf(codes.Unimplemented, "method Watch not implemented") -} - -func RegisterRegistryServer(s *grpc.Server, srv RegistryServer) { - s.RegisterService(&_Registry_serviceDesc, srv) -} - -func _Registry_GetService_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RegistryServer).GetService(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/go.micro.registry.Registry/GetService", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RegistryServer).GetService(ctx, req.(*GetRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Registry_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Service) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RegistryServer).Register(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/go.micro.registry.Registry/Register", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RegistryServer).Register(ctx, req.(*Service)) - } - return interceptor(ctx, in, info, handler) -} - -func _Registry_Deregister_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Service) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RegistryServer).Deregister(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/go.micro.registry.Registry/Deregister", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RegistryServer).Deregister(ctx, req.(*Service)) - } - return interceptor(ctx, in, info, handler) -} - -func _Registry_ListServices_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RegistryServer).ListServices(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/go.micro.registry.Registry/ListServices", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RegistryServer).ListServices(ctx, req.(*ListRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Registry_Watch_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(WatchRequest) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(RegistryServer).Watch(m, ®istryWatchServer{stream}) -} - -type Registry_WatchServer interface { - Send(*Result) error - grpc.ServerStream -} - -type registryWatchServer struct { - grpc.ServerStream -} - -func (x *registryWatchServer) Send(m *Result) error { - return x.ServerStream.SendMsg(m) -} - -var _Registry_serviceDesc = grpc.ServiceDesc{ - ServiceName: "go.micro.registry.Registry", - HandlerType: (*RegistryServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "GetService", - Handler: _Registry_GetService_Handler, - }, - { - MethodName: "Register", - Handler: _Registry_Register_Handler, - }, - { - MethodName: "Deregister", - Handler: _Registry_Deregister_Handler, - }, - { - MethodName: "ListServices", - Handler: _Registry_ListServices_Handler, - }, - }, - Streams: []grpc.StreamDesc{ - { - StreamName: "Watch", - Handler: _Registry_Watch_Handler, - ServerStreams: true, - }, - }, - Metadata: "registry/service/proto/registry.proto", -} diff --git a/registry/service/proto/registry.pb.micro.go b/registry/service/proto/registry.pb.micro.go deleted file mode 100644 index 482b2146..00000000 --- a/registry/service/proto/registry.pb.micro.go +++ /dev/null @@ -1,236 +0,0 @@ -// Code generated by protoc-gen-micro. DO NOT EDIT. -// source: registry/service/proto/registry.proto - -package go_micro_registry - -import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" - math "math" -) - -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" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -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 { - GetService(ctx context.Context, in *GetRequest, opts ...client.CallOption) (*GetResponse, error) - Register(ctx context.Context, in *Service, opts ...client.CallOption) (*EmptyResponse, error) - Deregister(ctx context.Context, in *Service, opts ...client.CallOption) (*EmptyResponse, error) - ListServices(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) - Watch(ctx context.Context, in *WatchRequest, opts ...client.CallOption) (Registry_WatchService, error) -} - -type registryService struct { - c client.Client - name string -} - -func NewRegistryService(name string, c client.Client) RegistryService { - return ®istryService{ - c: c, - name: name, - } -} - -func (c *registryService) GetService(ctx context.Context, in *GetRequest, opts ...client.CallOption) (*GetResponse, error) { - req := c.c.NewRequest(c.name, "Registry.GetService", in) - out := new(GetResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *registryService) Register(ctx context.Context, in *Service, opts ...client.CallOption) (*EmptyResponse, error) { - req := c.c.NewRequest(c.name, "Registry.Register", in) - out := new(EmptyResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *registryService) Deregister(ctx context.Context, in *Service, opts ...client.CallOption) (*EmptyResponse, error) { - req := c.c.NewRequest(c.name, "Registry.Deregister", in) - out := new(EmptyResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *registryService) ListServices(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) { - req := c.c.NewRequest(c.name, "Registry.ListServices", in) - out := new(ListResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *registryService) Watch(ctx context.Context, in *WatchRequest, opts ...client.CallOption) (Registry_WatchService, error) { - req := c.c.NewRequest(c.name, "Registry.Watch", &WatchRequest{}) - stream, err := c.c.Stream(ctx, req, opts...) - if err != nil { - return nil, err - } - if err := stream.Send(in); err != nil { - return nil, err - } - return ®istryServiceWatch{stream}, nil -} - -type Registry_WatchService interface { - Context() context.Context - SendMsg(interface{}) error - RecvMsg(interface{}) error - Close() error - Recv() (*Result, error) -} - -type registryServiceWatch struct { - stream client.Stream -} - -func (x *registryServiceWatch) Close() error { - return x.stream.Close() -} - -func (x *registryServiceWatch) Context() context.Context { - return x.stream.Context() -} - -func (x *registryServiceWatch) SendMsg(m interface{}) error { - return x.stream.Send(m) -} - -func (x *registryServiceWatch) RecvMsg(m interface{}) error { - return x.stream.Recv(m) -} - -func (x *registryServiceWatch) Recv() (*Result, error) { - m := new(Result) - err := x.stream.Recv(m) - if err != nil { - return nil, err - } - return m, nil -} - -// Server API for Registry service - -type RegistryHandler interface { - GetService(context.Context, *GetRequest, *GetResponse) error - Register(context.Context, *Service, *EmptyResponse) error - Deregister(context.Context, *Service, *EmptyResponse) error - ListServices(context.Context, *ListRequest, *ListResponse) error - Watch(context.Context, *WatchRequest, Registry_WatchStream) error -} - -func RegisterRegistryHandler(s server.Server, hdlr RegistryHandler, opts ...server.HandlerOption) error { - type registry interface { - GetService(ctx context.Context, in *GetRequest, out *GetResponse) error - Register(ctx context.Context, in *Service, out *EmptyResponse) error - Deregister(ctx context.Context, in *Service, out *EmptyResponse) error - ListServices(ctx context.Context, in *ListRequest, out *ListResponse) error - Watch(ctx context.Context, stream server.Stream) error - } - type Registry struct { - registry - } - h := ®istryHandler{hdlr} - return s.Handle(s.NewHandler(&Registry{h}, opts...)) -} - -type registryHandler struct { - RegistryHandler -} - -func (h *registryHandler) GetService(ctx context.Context, in *GetRequest, out *GetResponse) error { - return h.RegistryHandler.GetService(ctx, in, out) -} - -func (h *registryHandler) Register(ctx context.Context, in *Service, out *EmptyResponse) error { - return h.RegistryHandler.Register(ctx, in, out) -} - -func (h *registryHandler) Deregister(ctx context.Context, in *Service, out *EmptyResponse) error { - return h.RegistryHandler.Deregister(ctx, in, out) -} - -func (h *registryHandler) ListServices(ctx context.Context, in *ListRequest, out *ListResponse) error { - return h.RegistryHandler.ListServices(ctx, in, out) -} - -func (h *registryHandler) Watch(ctx context.Context, stream server.Stream) error { - m := new(WatchRequest) - if err := stream.Recv(m); err != nil { - return err - } - return h.RegistryHandler.Watch(ctx, m, ®istryWatchStream{stream}) -} - -type Registry_WatchStream interface { - Context() context.Context - SendMsg(interface{}) error - RecvMsg(interface{}) error - Close() error - Send(*Result) error -} - -type registryWatchStream struct { - stream server.Stream -} - -func (x *registryWatchStream) Close() error { - return x.stream.Close() -} - -func (x *registryWatchStream) Context() context.Context { - return x.stream.Context() -} - -func (x *registryWatchStream) SendMsg(m interface{}) error { - return x.stream.Send(m) -} - -func (x *registryWatchStream) RecvMsg(m interface{}) error { - return x.stream.Recv(m) -} - -func (x *registryWatchStream) Send(m *Result) error { - return x.stream.Send(m) -} diff --git a/registry/service/proto/registry.proto b/registry/service/proto/registry.proto deleted file mode 100644 index ddc09669..00000000 --- a/registry/service/proto/registry.proto +++ /dev/null @@ -1,98 +0,0 @@ -syntax = "proto3"; - -package go.micro.registry; - -service Registry { - rpc GetService(GetRequest) returns (GetResponse) {}; - rpc Register(Service) returns (EmptyResponse) {}; - rpc Deregister(Service) returns (EmptyResponse) {}; - rpc ListServices(ListRequest) returns (ListResponse) {}; - rpc Watch(WatchRequest) returns (stream Result) {}; -} - -// Service represents a go-micro service -message Service { - string name = 1; - string version = 2; - map metadata = 3; - repeated Endpoint endpoints = 4; - repeated Node nodes = 5; - Options options = 6; -} - -// Node represents the node the service is on -message Node { - string id = 1; - string address = 2; - int64 port = 3; - map metadata = 4; -} - -// Endpoint is a endpoint provided by a service -message Endpoint { - string name = 1; - Value request = 2; - Value response = 3; - map metadata = 4; -} - -// Value is an opaque value for a request or response -message Value { - string name = 1; - string type = 2; - repeated Value values = 3; -} - -// Options are registry options -message Options { - int64 ttl = 1; -} - -// Result is returns by the watcher -message Result { - string action = 1; // create, update, delete - Service service = 2; - int64 timestamp = 3; // unix timestamp -} - -message EmptyResponse {} - -message GetRequest { - string service = 1; -} - -message GetResponse { - repeated Service services = 1; -} - -message ListRequest { - // TODO: filtering -} - -message ListResponse { - repeated Service services = 1; -} - -message WatchRequest { - // service is optional - string service = 1; -} - -// EventType defines the type of event -enum EventType { - Create = 0; - Delete = 1; - Update = 2; -} - -// Event is registry event -message Event { - // Event Id - string id = 1; - // type of event - EventType type = 2; - // unix timestamp of event - int64 timestamp = 3; - // service entry - Service service = 4; -} diff --git a/registry/service/service.go b/registry/service/service.go deleted file mode 100644 index 3be9e97b..00000000 --- a/registry/service/service.go +++ /dev/null @@ -1,217 +0,0 @@ -// Package service uses the registry service -package service - -import ( - "context" - "time" - - "github.com/micro/go-micro/v2/client" - "github.com/micro/go-micro/v2/client/grpc" - "github.com/micro/go-micro/v2/errors" - "github.com/micro/go-micro/v2/registry" - pb "github.com/micro/go-micro/v2/registry/service/proto" -) - -var ( - // The default service name - DefaultService = "go.micro.registry" -) - -type serviceRegistry struct { - opts registry.Options - // name of the registry - name string - // address - address []string - // client to call registry - client pb.RegistryService -} - -func (s *serviceRegistry) callOpts() []client.CallOption { - var opts []client.CallOption - - // set registry address - if len(s.address) > 0 { - opts = append(opts, client.WithAddress(s.address...)) - } - - // set timeout - if s.opts.Timeout > time.Duration(0) { - opts = append(opts, client.WithRequestTimeout(s.opts.Timeout)) - } - - return opts -} - -func (s *serviceRegistry) Init(opts ...registry.Option) error { - for _, o := range opts { - o(&s.opts) - } - - if len(s.opts.Addrs) > 0 { - s.address = s.opts.Addrs - } - - // extract the client from the context, fallback to grpc - var cli client.Client - if c, ok := s.opts.Context.Value(clientKey{}).(client.Client); ok { - cli = c - } else { - cli = grpc.NewClient() - } - - s.client = pb.NewRegistryService(DefaultService, cli) - - return nil -} - -func (s *serviceRegistry) Options() registry.Options { - return s.opts -} - -func (s *serviceRegistry) Register(srv *registry.Service, opts ...registry.RegisterOption) error { - var options registry.RegisterOptions - for _, o := range opts { - o(&options) - } - if options.Context == nil { - options.Context = context.TODO() - } - - // encode srv into protobuf and pack Register TTL into it - pbSrv := ToProto(srv) - pbSrv.Options.Ttl = int64(options.TTL.Seconds()) - - // register the service - _, err := s.client.Register(options.Context, pbSrv, s.callOpts()...) - if err != nil { - return err - } - - return nil -} - -func (s *serviceRegistry) Deregister(srv *registry.Service, opts ...registry.DeregisterOption) error { - var options registry.DeregisterOptions - for _, o := range opts { - o(&options) - } - if options.Context == nil { - options.Context = context.TODO() - } - - // deregister the service - _, err := s.client.Deregister(options.Context, ToProto(srv), s.callOpts()...) - if err != nil { - return err - } - return nil -} - -func (s *serviceRegistry) GetService(name string, opts ...registry.GetOption) ([]*registry.Service, error) { - var options registry.GetOptions - for _, o := range opts { - o(&options) - } - if options.Context == nil { - options.Context = context.TODO() - } - - rsp, err := s.client.GetService(options.Context, &pb.GetRequest{ - Service: name, - }, s.callOpts()...) - - if verr, ok := err.(*errors.Error); ok && verr.Code == 404 { - return nil, registry.ErrNotFound - } else if err != nil { - return nil, err - } - - services := make([]*registry.Service, 0, len(rsp.Services)) - for _, service := range rsp.Services { - services = append(services, ToService(service)) - } - return services, nil -} - -func (s *serviceRegistry) ListServices(opts ...registry.ListOption) ([]*registry.Service, error) { - var options registry.ListOptions - for _, o := range opts { - o(&options) - } - if options.Context == nil { - options.Context = context.TODO() - } - - rsp, err := s.client.ListServices(options.Context, &pb.ListRequest{}, s.callOpts()...) - if err != nil { - return nil, err - } - - services := make([]*registry.Service, 0, len(rsp.Services)) - for _, service := range rsp.Services { - services = append(services, ToService(service)) - } - - return services, nil -} - -func (s *serviceRegistry) Watch(opts ...registry.WatchOption) (registry.Watcher, error) { - var options registry.WatchOptions - for _, o := range opts { - o(&options) - } - if options.Context == nil { - options.Context = context.TODO() - } - - stream, err := s.client.Watch(options.Context, &pb.WatchRequest{ - Service: options.Service, - }, s.callOpts()...) - - if err != nil { - return nil, err - } - - return newWatcher(stream), nil -} - -func (s *serviceRegistry) String() string { - return "service" -} - -// NewRegistry returns a new registry service client -func NewRegistry(opts ...registry.Option) registry.Registry { - var options registry.Options - for _, o := range opts { - o(&options) - } - - // the registry address - addrs := options.Addrs - if len(addrs) == 0 { - addrs = []string{"127.0.0.1:8000"} - } - - if options.Context == nil { - options.Context = context.TODO() - } - - // extract the client from the context, fallback to grpc - var cli client.Client - if c, ok := options.Context.Value(clientKey{}).(client.Client); ok { - cli = c - } else { - cli = grpc.NewClient() - } - - // service name. TODO: accept option - name := DefaultService - - return &serviceRegistry{ - opts: options, - name: name, - address: addrs, - client: pb.NewRegistryService(name, cli), - } -} diff --git a/registry/service/util.go b/registry/service/util.go deleted file mode 100644 index 4ba5f4da..00000000 --- a/registry/service/util.go +++ /dev/null @@ -1,134 +0,0 @@ -package service - -import ( - "github.com/micro/go-micro/v2/registry" - pb "github.com/micro/go-micro/v2/registry/service/proto" -) - -func values(v []*registry.Value) []*pb.Value { - if len(v) == 0 { - return []*pb.Value{} - } - - vs := make([]*pb.Value, 0, len(v)) - for _, vi := range v { - vs = append(vs, &pb.Value{ - Name: vi.Name, - Type: vi.Type, - Values: values(vi.Values), - }) - } - return vs -} - -func toValues(v []*pb.Value) []*registry.Value { - if len(v) == 0 { - return []*registry.Value{} - } - - vs := make([]*registry.Value, 0, len(v)) - for _, vi := range v { - vs = append(vs, ®istry.Value{ - Name: vi.Name, - Type: vi.Type, - Values: toValues(vi.Values), - }) - } - return vs -} - -func ToProto(s *registry.Service) *pb.Service { - endpoints := make([]*pb.Endpoint, 0, len(s.Endpoints)) - for _, ep := range s.Endpoints { - var request, response *pb.Value - - if ep.Request != nil { - request = &pb.Value{ - Name: ep.Request.Name, - Type: ep.Request.Type, - Values: values(ep.Request.Values), - } - } - - if ep.Response != nil { - response = &pb.Value{ - Name: ep.Response.Name, - Type: ep.Response.Type, - Values: values(ep.Response.Values), - } - } - - endpoints = append(endpoints, &pb.Endpoint{ - Name: ep.Name, - Request: request, - Response: response, - Metadata: ep.Metadata, - }) - } - - nodes := make([]*pb.Node, 0, len(s.Nodes)) - - for _, node := range s.Nodes { - nodes = append(nodes, &pb.Node{ - Id: node.Id, - Address: node.Address, - Metadata: node.Metadata, - }) - } - - return &pb.Service{ - Name: s.Name, - Version: s.Version, - Metadata: s.Metadata, - Endpoints: endpoints, - Nodes: nodes, - Options: new(pb.Options), - } -} - -func ToService(s *pb.Service) *registry.Service { - endpoints := make([]*registry.Endpoint, 0, len(s.Endpoints)) - for _, ep := range s.Endpoints { - var request, response *registry.Value - - if ep.Request != nil { - request = ®istry.Value{ - Name: ep.Request.Name, - Type: ep.Request.Type, - Values: toValues(ep.Request.Values), - } - } - - if ep.Response != nil { - response = ®istry.Value{ - Name: ep.Response.Name, - Type: ep.Response.Type, - Values: toValues(ep.Response.Values), - } - } - - endpoints = append(endpoints, ®istry.Endpoint{ - Name: ep.Name, - Request: request, - Response: response, - Metadata: ep.Metadata, - }) - } - - nodes := make([]*registry.Node, 0, len(s.Nodes)) - for _, node := range s.Nodes { - nodes = append(nodes, ®istry.Node{ - Id: node.Id, - Address: node.Address, - Metadata: node.Metadata, - }) - } - - return ®istry.Service{ - Name: s.Name, - Version: s.Version, - Metadata: s.Metadata, - Endpoints: endpoints, - Nodes: nodes, - } -} diff --git a/registry/service/watcher.go b/registry/service/watcher.go deleted file mode 100644 index bf998a2f..00000000 --- a/registry/service/watcher.go +++ /dev/null @@ -1,47 +0,0 @@ -package service - -import ( - "github.com/micro/go-micro/v2/registry" - pb "github.com/micro/go-micro/v2/registry/service/proto" -) - -type serviceWatcher struct { - stream pb.Registry_WatchService - closed chan bool -} - -func (s *serviceWatcher) Next() (*registry.Result, error) { - // check if closed - select { - case <-s.closed: - return nil, registry.ErrWatcherStopped - default: - } - - r, err := s.stream.Recv() - if err != nil { - return nil, err - } - - return ®istry.Result{ - Action: r.Action, - Service: ToService(r.Service), - }, nil -} - -func (s *serviceWatcher) Stop() { - select { - case <-s.closed: - return - default: - close(s.closed) - s.stream.Close() - } -} - -func newWatcher(stream pb.Registry_WatchService) registry.Watcher { - return &serviceWatcher{ - stream: stream, - closed: make(chan bool), - } -} diff --git a/runtime/service/proto/runtime.pb.go b/runtime/service/proto/runtime.pb.go deleted file mode 100644 index 0573fc6a..00000000 --- a/runtime/service/proto/runtime.pb.go +++ /dev/null @@ -1,1276 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: runtime/service/proto/runtime.proto - -package go_micro_runtime - -import ( - context "context" - fmt "fmt" - proto "github.com/golang/protobuf/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - math "math" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package - -type Service struct { - // name of the service - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - // version of the service - Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` - // git url of the source - Source string `protobuf:"bytes,3,opt,name=source,proto3" json:"source,omitempty"` - // service metadata - Metadata map[string]string `protobuf:"bytes,4,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Service) Reset() { *m = Service{} } -func (m *Service) String() string { return proto.CompactTextString(m) } -func (*Service) ProtoMessage() {} -func (*Service) Descriptor() ([]byte, []int) { - return fileDescriptor_2434d8152598889b, []int{0} -} - -func (m *Service) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Service.Unmarshal(m, b) -} -func (m *Service) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Service.Marshal(b, m, deterministic) -} -func (m *Service) XXX_Merge(src proto.Message) { - xxx_messageInfo_Service.Merge(m, src) -} -func (m *Service) XXX_Size() int { - return xxx_messageInfo_Service.Size(m) -} -func (m *Service) XXX_DiscardUnknown() { - xxx_messageInfo_Service.DiscardUnknown(m) -} - -var xxx_messageInfo_Service proto.InternalMessageInfo - -func (m *Service) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *Service) GetVersion() string { - if m != nil { - return m.Version - } - return "" -} - -func (m *Service) GetSource() string { - if m != nil { - return m.Source - } - return "" -} - -func (m *Service) GetMetadata() map[string]string { - if m != nil { - return m.Metadata - } - return nil -} - -type Event struct { - Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` - Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - Service string `protobuf:"bytes,3,opt,name=service,proto3" json:"service,omitempty"` - Version string `protobuf:"bytes,4,opt,name=version,proto3" json:"version,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Event) Reset() { *m = Event{} } -func (m *Event) String() string { return proto.CompactTextString(m) } -func (*Event) ProtoMessage() {} -func (*Event) Descriptor() ([]byte, []int) { - return fileDescriptor_2434d8152598889b, []int{1} -} - -func (m *Event) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Event.Unmarshal(m, b) -} -func (m *Event) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Event.Marshal(b, m, deterministic) -} -func (m *Event) XXX_Merge(src proto.Message) { - xxx_messageInfo_Event.Merge(m, src) -} -func (m *Event) XXX_Size() int { - return xxx_messageInfo_Event.Size(m) -} -func (m *Event) XXX_DiscardUnknown() { - xxx_messageInfo_Event.DiscardUnknown(m) -} - -var xxx_messageInfo_Event proto.InternalMessageInfo - -func (m *Event) GetType() string { - if m != nil { - return m.Type - } - return "" -} - -func (m *Event) GetTimestamp() int64 { - if m != nil { - return m.Timestamp - } - return 0 -} - -func (m *Event) GetService() string { - if m != nil { - return m.Service - } - return "" -} - -func (m *Event) GetVersion() string { - if m != nil { - return m.Version - } - return "" -} - -type CreateOptions struct { - // command to pass in - Command []string `protobuf:"bytes,1,rep,name=command,proto3" json:"command,omitempty"` - // args to pass into command - Args []string `protobuf:"bytes,2,rep,name=args,proto3" json:"args,omitempty"` - // environment to pass in - Env []string `protobuf:"bytes,3,rep,name=env,proto3" json:"env,omitempty"` - // output to send to - Output string `protobuf:"bytes,4,opt,name=output,proto3" json:"output,omitempty"` - // create type of service - Type string `protobuf:"bytes,5,opt,name=type,proto3" json:"type,omitempty"` - // image to use - Image string `protobuf:"bytes,6,opt,name=image,proto3" json:"image,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CreateOptions) Reset() { *m = CreateOptions{} } -func (m *CreateOptions) String() string { return proto.CompactTextString(m) } -func (*CreateOptions) ProtoMessage() {} -func (*CreateOptions) Descriptor() ([]byte, []int) { - return fileDescriptor_2434d8152598889b, []int{2} -} - -func (m *CreateOptions) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CreateOptions.Unmarshal(m, b) -} -func (m *CreateOptions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CreateOptions.Marshal(b, m, deterministic) -} -func (m *CreateOptions) XXX_Merge(src proto.Message) { - xxx_messageInfo_CreateOptions.Merge(m, src) -} -func (m *CreateOptions) XXX_Size() int { - return xxx_messageInfo_CreateOptions.Size(m) -} -func (m *CreateOptions) XXX_DiscardUnknown() { - xxx_messageInfo_CreateOptions.DiscardUnknown(m) -} - -var xxx_messageInfo_CreateOptions proto.InternalMessageInfo - -func (m *CreateOptions) GetCommand() []string { - if m != nil { - return m.Command - } - return nil -} - -func (m *CreateOptions) GetArgs() []string { - if m != nil { - return m.Args - } - return nil -} - -func (m *CreateOptions) GetEnv() []string { - if m != nil { - return m.Env - } - return nil -} - -func (m *CreateOptions) GetOutput() string { - if m != nil { - return m.Output - } - return "" -} - -func (m *CreateOptions) GetType() string { - if m != nil { - return m.Type - } - return "" -} - -func (m *CreateOptions) GetImage() string { - if m != nil { - return m.Image - } - return "" -} - -type CreateRequest struct { - Service *Service `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` - Options *CreateOptions `protobuf:"bytes,2,opt,name=options,proto3" json:"options,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CreateRequest) Reset() { *m = CreateRequest{} } -func (m *CreateRequest) String() string { return proto.CompactTextString(m) } -func (*CreateRequest) ProtoMessage() {} -func (*CreateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_2434d8152598889b, []int{3} -} - -func (m *CreateRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CreateRequest.Unmarshal(m, b) -} -func (m *CreateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CreateRequest.Marshal(b, m, deterministic) -} -func (m *CreateRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_CreateRequest.Merge(m, src) -} -func (m *CreateRequest) XXX_Size() int { - return xxx_messageInfo_CreateRequest.Size(m) -} -func (m *CreateRequest) XXX_DiscardUnknown() { - xxx_messageInfo_CreateRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_CreateRequest proto.InternalMessageInfo - -func (m *CreateRequest) GetService() *Service { - if m != nil { - return m.Service - } - return nil -} - -func (m *CreateRequest) GetOptions() *CreateOptions { - if m != nil { - return m.Options - } - return nil -} - -type CreateResponse struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CreateResponse) Reset() { *m = CreateResponse{} } -func (m *CreateResponse) String() string { return proto.CompactTextString(m) } -func (*CreateResponse) ProtoMessage() {} -func (*CreateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_2434d8152598889b, []int{4} -} - -func (m *CreateResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CreateResponse.Unmarshal(m, b) -} -func (m *CreateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CreateResponse.Marshal(b, m, deterministic) -} -func (m *CreateResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_CreateResponse.Merge(m, src) -} -func (m *CreateResponse) XXX_Size() int { - return xxx_messageInfo_CreateResponse.Size(m) -} -func (m *CreateResponse) XXX_DiscardUnknown() { - xxx_messageInfo_CreateResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_CreateResponse proto.InternalMessageInfo - -type ReadOptions struct { - // service name - Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` - // version of the service - Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` - // type of service - Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ReadOptions) Reset() { *m = ReadOptions{} } -func (m *ReadOptions) String() string { return proto.CompactTextString(m) } -func (*ReadOptions) ProtoMessage() {} -func (*ReadOptions) Descriptor() ([]byte, []int) { - return fileDescriptor_2434d8152598889b, []int{5} -} - -func (m *ReadOptions) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ReadOptions.Unmarshal(m, b) -} -func (m *ReadOptions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ReadOptions.Marshal(b, m, deterministic) -} -func (m *ReadOptions) XXX_Merge(src proto.Message) { - xxx_messageInfo_ReadOptions.Merge(m, src) -} -func (m *ReadOptions) XXX_Size() int { - return xxx_messageInfo_ReadOptions.Size(m) -} -func (m *ReadOptions) XXX_DiscardUnknown() { - xxx_messageInfo_ReadOptions.DiscardUnknown(m) -} - -var xxx_messageInfo_ReadOptions proto.InternalMessageInfo - -func (m *ReadOptions) GetService() string { - if m != nil { - return m.Service - } - return "" -} - -func (m *ReadOptions) GetVersion() string { - if m != nil { - return m.Version - } - return "" -} - -func (m *ReadOptions) GetType() string { - if m != nil { - return m.Type - } - return "" -} - -type ReadRequest struct { - Options *ReadOptions `protobuf:"bytes,1,opt,name=options,proto3" json:"options,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ReadRequest) Reset() { *m = ReadRequest{} } -func (m *ReadRequest) String() string { return proto.CompactTextString(m) } -func (*ReadRequest) ProtoMessage() {} -func (*ReadRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_2434d8152598889b, []int{6} -} - -func (m *ReadRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ReadRequest.Unmarshal(m, b) -} -func (m *ReadRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ReadRequest.Marshal(b, m, deterministic) -} -func (m *ReadRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ReadRequest.Merge(m, src) -} -func (m *ReadRequest) XXX_Size() int { - return xxx_messageInfo_ReadRequest.Size(m) -} -func (m *ReadRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ReadRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ReadRequest proto.InternalMessageInfo - -func (m *ReadRequest) GetOptions() *ReadOptions { - if m != nil { - return m.Options - } - return nil -} - -type ReadResponse struct { - Services []*Service `protobuf:"bytes,1,rep,name=services,proto3" json:"services,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ReadResponse) Reset() { *m = ReadResponse{} } -func (m *ReadResponse) String() string { return proto.CompactTextString(m) } -func (*ReadResponse) ProtoMessage() {} -func (*ReadResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_2434d8152598889b, []int{7} -} - -func (m *ReadResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ReadResponse.Unmarshal(m, b) -} -func (m *ReadResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ReadResponse.Marshal(b, m, deterministic) -} -func (m *ReadResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ReadResponse.Merge(m, src) -} -func (m *ReadResponse) XXX_Size() int { - return xxx_messageInfo_ReadResponse.Size(m) -} -func (m *ReadResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ReadResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_ReadResponse proto.InternalMessageInfo - -func (m *ReadResponse) GetServices() []*Service { - if m != nil { - return m.Services - } - return nil -} - -type DeleteOptions struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DeleteOptions) Reset() { *m = DeleteOptions{} } -func (m *DeleteOptions) String() string { return proto.CompactTextString(m) } -func (*DeleteOptions) ProtoMessage() {} -func (*DeleteOptions) Descriptor() ([]byte, []int) { - return fileDescriptor_2434d8152598889b, []int{8} -} - -func (m *DeleteOptions) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_DeleteOptions.Unmarshal(m, b) -} -func (m *DeleteOptions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_DeleteOptions.Marshal(b, m, deterministic) -} -func (m *DeleteOptions) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeleteOptions.Merge(m, src) -} -func (m *DeleteOptions) XXX_Size() int { - return xxx_messageInfo_DeleteOptions.Size(m) -} -func (m *DeleteOptions) XXX_DiscardUnknown() { - xxx_messageInfo_DeleteOptions.DiscardUnknown(m) -} - -var xxx_messageInfo_DeleteOptions proto.InternalMessageInfo - -type DeleteRequest struct { - Service *Service `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` - Options *DeleteOptions `protobuf:"bytes,2,opt,name=options,proto3" json:"options,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DeleteRequest) Reset() { *m = DeleteRequest{} } -func (m *DeleteRequest) String() string { return proto.CompactTextString(m) } -func (*DeleteRequest) ProtoMessage() {} -func (*DeleteRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_2434d8152598889b, []int{9} -} - -func (m *DeleteRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_DeleteRequest.Unmarshal(m, b) -} -func (m *DeleteRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_DeleteRequest.Marshal(b, m, deterministic) -} -func (m *DeleteRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeleteRequest.Merge(m, src) -} -func (m *DeleteRequest) XXX_Size() int { - return xxx_messageInfo_DeleteRequest.Size(m) -} -func (m *DeleteRequest) XXX_DiscardUnknown() { - xxx_messageInfo_DeleteRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_DeleteRequest proto.InternalMessageInfo - -func (m *DeleteRequest) GetService() *Service { - if m != nil { - return m.Service - } - return nil -} - -func (m *DeleteRequest) GetOptions() *DeleteOptions { - if m != nil { - return m.Options - } - return nil -} - -type DeleteResponse struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DeleteResponse) Reset() { *m = DeleteResponse{} } -func (m *DeleteResponse) String() string { return proto.CompactTextString(m) } -func (*DeleteResponse) ProtoMessage() {} -func (*DeleteResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_2434d8152598889b, []int{10} -} - -func (m *DeleteResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_DeleteResponse.Unmarshal(m, b) -} -func (m *DeleteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_DeleteResponse.Marshal(b, m, deterministic) -} -func (m *DeleteResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeleteResponse.Merge(m, src) -} -func (m *DeleteResponse) XXX_Size() int { - return xxx_messageInfo_DeleteResponse.Size(m) -} -func (m *DeleteResponse) XXX_DiscardUnknown() { - xxx_messageInfo_DeleteResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_DeleteResponse proto.InternalMessageInfo - -type UpdateOptions struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *UpdateOptions) Reset() { *m = UpdateOptions{} } -func (m *UpdateOptions) String() string { return proto.CompactTextString(m) } -func (*UpdateOptions) ProtoMessage() {} -func (*UpdateOptions) Descriptor() ([]byte, []int) { - return fileDescriptor_2434d8152598889b, []int{11} -} - -func (m *UpdateOptions) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_UpdateOptions.Unmarshal(m, b) -} -func (m *UpdateOptions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_UpdateOptions.Marshal(b, m, deterministic) -} -func (m *UpdateOptions) XXX_Merge(src proto.Message) { - xxx_messageInfo_UpdateOptions.Merge(m, src) -} -func (m *UpdateOptions) XXX_Size() int { - return xxx_messageInfo_UpdateOptions.Size(m) -} -func (m *UpdateOptions) XXX_DiscardUnknown() { - xxx_messageInfo_UpdateOptions.DiscardUnknown(m) -} - -var xxx_messageInfo_UpdateOptions proto.InternalMessageInfo - -type UpdateRequest struct { - Service *Service `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` - Options *UpdateOptions `protobuf:"bytes,2,opt,name=options,proto3" json:"options,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *UpdateRequest) Reset() { *m = UpdateRequest{} } -func (m *UpdateRequest) String() string { return proto.CompactTextString(m) } -func (*UpdateRequest) ProtoMessage() {} -func (*UpdateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_2434d8152598889b, []int{12} -} - -func (m *UpdateRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_UpdateRequest.Unmarshal(m, b) -} -func (m *UpdateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_UpdateRequest.Marshal(b, m, deterministic) -} -func (m *UpdateRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_UpdateRequest.Merge(m, src) -} -func (m *UpdateRequest) XXX_Size() int { - return xxx_messageInfo_UpdateRequest.Size(m) -} -func (m *UpdateRequest) XXX_DiscardUnknown() { - xxx_messageInfo_UpdateRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_UpdateRequest proto.InternalMessageInfo - -func (m *UpdateRequest) GetService() *Service { - if m != nil { - return m.Service - } - return nil -} - -func (m *UpdateRequest) GetOptions() *UpdateOptions { - if m != nil { - return m.Options - } - return nil -} - -type UpdateResponse struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *UpdateResponse) Reset() { *m = UpdateResponse{} } -func (m *UpdateResponse) String() string { return proto.CompactTextString(m) } -func (*UpdateResponse) ProtoMessage() {} -func (*UpdateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_2434d8152598889b, []int{13} -} - -func (m *UpdateResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_UpdateResponse.Unmarshal(m, b) -} -func (m *UpdateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_UpdateResponse.Marshal(b, m, deterministic) -} -func (m *UpdateResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_UpdateResponse.Merge(m, src) -} -func (m *UpdateResponse) XXX_Size() int { - return xxx_messageInfo_UpdateResponse.Size(m) -} -func (m *UpdateResponse) XXX_DiscardUnknown() { - xxx_messageInfo_UpdateResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_UpdateResponse proto.InternalMessageInfo - -type ListOptions struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListOptions) Reset() { *m = ListOptions{} } -func (m *ListOptions) String() string { return proto.CompactTextString(m) } -func (*ListOptions) ProtoMessage() {} -func (*ListOptions) Descriptor() ([]byte, []int) { - return fileDescriptor_2434d8152598889b, []int{14} -} - -func (m *ListOptions) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListOptions.Unmarshal(m, b) -} -func (m *ListOptions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListOptions.Marshal(b, m, deterministic) -} -func (m *ListOptions) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListOptions.Merge(m, src) -} -func (m *ListOptions) XXX_Size() int { - return xxx_messageInfo_ListOptions.Size(m) -} -func (m *ListOptions) XXX_DiscardUnknown() { - xxx_messageInfo_ListOptions.DiscardUnknown(m) -} - -var xxx_messageInfo_ListOptions proto.InternalMessageInfo - -type ListRequest struct { - Options *ListOptions `protobuf:"bytes,1,opt,name=options,proto3" json:"options,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListRequest) Reset() { *m = ListRequest{} } -func (m *ListRequest) String() string { return proto.CompactTextString(m) } -func (*ListRequest) ProtoMessage() {} -func (*ListRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_2434d8152598889b, []int{15} -} - -func (m *ListRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListRequest.Unmarshal(m, b) -} -func (m *ListRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListRequest.Marshal(b, m, deterministic) -} -func (m *ListRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListRequest.Merge(m, src) -} -func (m *ListRequest) XXX_Size() int { - return xxx_messageInfo_ListRequest.Size(m) -} -func (m *ListRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ListRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ListRequest proto.InternalMessageInfo - -func (m *ListRequest) GetOptions() *ListOptions { - if m != nil { - return m.Options - } - return nil -} - -type ListResponse struct { - Services []*Service `protobuf:"bytes,1,rep,name=services,proto3" json:"services,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListResponse) Reset() { *m = ListResponse{} } -func (m *ListResponse) String() string { return proto.CompactTextString(m) } -func (*ListResponse) ProtoMessage() {} -func (*ListResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_2434d8152598889b, []int{16} -} - -func (m *ListResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListResponse.Unmarshal(m, b) -} -func (m *ListResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListResponse.Marshal(b, m, deterministic) -} -func (m *ListResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListResponse.Merge(m, src) -} -func (m *ListResponse) XXX_Size() int { - return xxx_messageInfo_ListResponse.Size(m) -} -func (m *ListResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ListResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_ListResponse proto.InternalMessageInfo - -func (m *ListResponse) GetServices() []*Service { - if m != nil { - return m.Services - } - return nil -} - -type LogsOptions struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *LogsOptions) Reset() { *m = LogsOptions{} } -func (m *LogsOptions) String() string { return proto.CompactTextString(m) } -func (*LogsOptions) ProtoMessage() {} -func (*LogsOptions) Descriptor() ([]byte, []int) { - return fileDescriptor_2434d8152598889b, []int{17} -} - -func (m *LogsOptions) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_LogsOptions.Unmarshal(m, b) -} -func (m *LogsOptions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_LogsOptions.Marshal(b, m, deterministic) -} -func (m *LogsOptions) XXX_Merge(src proto.Message) { - xxx_messageInfo_LogsOptions.Merge(m, src) -} -func (m *LogsOptions) XXX_Size() int { - return xxx_messageInfo_LogsOptions.Size(m) -} -func (m *LogsOptions) XXX_DiscardUnknown() { - xxx_messageInfo_LogsOptions.DiscardUnknown(m) -} - -var xxx_messageInfo_LogsOptions proto.InternalMessageInfo - -type LogsRequest struct { - // service to request logs for - Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` - // stream records continuously - Stream bool `protobuf:"varint,2,opt,name=stream,proto3" json:"stream,omitempty"` - // count of records to request - Count int64 `protobuf:"varint,3,opt,name=count,proto3" json:"count,omitempty"` - // relative time in seconds - // before the current time - // from which to show logs - Since int64 `protobuf:"varint,4,opt,name=since,proto3" json:"since,omitempty"` - // options to use - Options *LogsOptions `protobuf:"bytes,5,opt,name=options,proto3" json:"options,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *LogsRequest) Reset() { *m = LogsRequest{} } -func (m *LogsRequest) String() string { return proto.CompactTextString(m) } -func (*LogsRequest) ProtoMessage() {} -func (*LogsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_2434d8152598889b, []int{18} -} - -func (m *LogsRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_LogsRequest.Unmarshal(m, b) -} -func (m *LogsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_LogsRequest.Marshal(b, m, deterministic) -} -func (m *LogsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_LogsRequest.Merge(m, src) -} -func (m *LogsRequest) XXX_Size() int { - return xxx_messageInfo_LogsRequest.Size(m) -} -func (m *LogsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_LogsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_LogsRequest proto.InternalMessageInfo - -func (m *LogsRequest) GetService() string { - if m != nil { - return m.Service - } - return "" -} - -func (m *LogsRequest) GetStream() bool { - if m != nil { - return m.Stream - } - return false -} - -func (m *LogsRequest) GetCount() int64 { - if m != nil { - return m.Count - } - return 0 -} - -func (m *LogsRequest) GetSince() int64 { - if m != nil { - return m.Since - } - return 0 -} - -func (m *LogsRequest) GetOptions() *LogsOptions { - if m != nil { - return m.Options - } - return nil -} - -type LogRecord struct { - // timestamp of log record - Timestamp int64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - // record metadata - Metadata map[string]string `protobuf:"bytes,2,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - // message - Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *LogRecord) Reset() { *m = LogRecord{} } -func (m *LogRecord) String() string { return proto.CompactTextString(m) } -func (*LogRecord) ProtoMessage() {} -func (*LogRecord) Descriptor() ([]byte, []int) { - return fileDescriptor_2434d8152598889b, []int{19} -} - -func (m *LogRecord) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_LogRecord.Unmarshal(m, b) -} -func (m *LogRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_LogRecord.Marshal(b, m, deterministic) -} -func (m *LogRecord) XXX_Merge(src proto.Message) { - xxx_messageInfo_LogRecord.Merge(m, src) -} -func (m *LogRecord) XXX_Size() int { - return xxx_messageInfo_LogRecord.Size(m) -} -func (m *LogRecord) XXX_DiscardUnknown() { - xxx_messageInfo_LogRecord.DiscardUnknown(m) -} - -var xxx_messageInfo_LogRecord proto.InternalMessageInfo - -func (m *LogRecord) GetTimestamp() int64 { - if m != nil { - return m.Timestamp - } - return 0 -} - -func (m *LogRecord) GetMetadata() map[string]string { - if m != nil { - return m.Metadata - } - return nil -} - -func (m *LogRecord) GetMessage() string { - if m != nil { - return m.Message - } - return "" -} - -func init() { - proto.RegisterType((*Service)(nil), "go.micro.runtime.Service") - proto.RegisterMapType((map[string]string)(nil), "go.micro.runtime.Service.MetadataEntry") - proto.RegisterType((*Event)(nil), "go.micro.runtime.Event") - proto.RegisterType((*CreateOptions)(nil), "go.micro.runtime.CreateOptions") - proto.RegisterType((*CreateRequest)(nil), "go.micro.runtime.CreateRequest") - proto.RegisterType((*CreateResponse)(nil), "go.micro.runtime.CreateResponse") - proto.RegisterType((*ReadOptions)(nil), "go.micro.runtime.ReadOptions") - proto.RegisterType((*ReadRequest)(nil), "go.micro.runtime.ReadRequest") - proto.RegisterType((*ReadResponse)(nil), "go.micro.runtime.ReadResponse") - proto.RegisterType((*DeleteOptions)(nil), "go.micro.runtime.DeleteOptions") - proto.RegisterType((*DeleteRequest)(nil), "go.micro.runtime.DeleteRequest") - proto.RegisterType((*DeleteResponse)(nil), "go.micro.runtime.DeleteResponse") - proto.RegisterType((*UpdateOptions)(nil), "go.micro.runtime.UpdateOptions") - proto.RegisterType((*UpdateRequest)(nil), "go.micro.runtime.UpdateRequest") - proto.RegisterType((*UpdateResponse)(nil), "go.micro.runtime.UpdateResponse") - proto.RegisterType((*ListOptions)(nil), "go.micro.runtime.ListOptions") - proto.RegisterType((*ListRequest)(nil), "go.micro.runtime.ListRequest") - proto.RegisterType((*ListResponse)(nil), "go.micro.runtime.ListResponse") - proto.RegisterType((*LogsOptions)(nil), "go.micro.runtime.LogsOptions") - proto.RegisterType((*LogsRequest)(nil), "go.micro.runtime.LogsRequest") - proto.RegisterType((*LogRecord)(nil), "go.micro.runtime.LogRecord") - proto.RegisterMapType((map[string]string)(nil), "go.micro.runtime.LogRecord.MetadataEntry") -} - -func init() { - proto.RegisterFile("runtime/service/proto/runtime.proto", fileDescriptor_2434d8152598889b) -} - -var fileDescriptor_2434d8152598889b = []byte{ - // 683 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xcb, 0x6e, 0xd3, 0x40, - 0x14, 0xad, 0xe3, 0x3c, 0xda, 0x1b, 0x42, 0xab, 0x51, 0x85, 0x4c, 0x79, 0x45, 0x66, 0x41, 0xd9, - 0x38, 0x28, 0x15, 0xe2, 0xb5, 0x2c, 0x09, 0x9b, 0x46, 0x48, 0x46, 0xfd, 0x80, 0xc1, 0xb9, 0x8a, - 0x2c, 0x6a, 0x8f, 0xf1, 0x8c, 0x23, 0x65, 0xc5, 0x92, 0x35, 0xff, 0xc0, 0xbf, 0xb0, 0xe6, 0x8f, - 0xd0, 0xbc, 0xfc, 0x48, 0xeb, 0x48, 0xa8, 0xea, 0x6e, 0xce, 0xf5, 0xcc, 0x9d, 0x73, 0xce, 0x9d, - 0x7b, 0x65, 0x78, 0x9e, 0x17, 0xa9, 0x88, 0x13, 0x9c, 0x70, 0xcc, 0xd7, 0x71, 0x84, 0x93, 0x2c, - 0x67, 0x82, 0x4d, 0x4c, 0x34, 0x50, 0x88, 0x1c, 0xad, 0x58, 0x90, 0xc4, 0x51, 0xce, 0x02, 0x13, - 0xf7, 0xff, 0x3a, 0x30, 0xf8, 0xa2, 0x4f, 0x10, 0x02, 0xdd, 0x94, 0x26, 0xe8, 0x39, 0x63, 0xe7, - 0xf4, 0x20, 0x54, 0x6b, 0xe2, 0xc1, 0x60, 0x8d, 0x39, 0x8f, 0x59, 0xea, 0x75, 0x54, 0xd8, 0x42, - 0xf2, 0x00, 0xfa, 0x9c, 0x15, 0x79, 0x84, 0x9e, 0xab, 0x3e, 0x18, 0x44, 0xce, 0x61, 0x3f, 0x41, - 0x41, 0x97, 0x54, 0x50, 0xaf, 0x3b, 0x76, 0x4f, 0x87, 0xd3, 0x17, 0xc1, 0xf6, 0xb5, 0x81, 0xb9, - 0x32, 0x58, 0x98, 0x9d, 0xb3, 0x54, 0xe4, 0x9b, 0xb0, 0x3c, 0x78, 0xf2, 0x01, 0x46, 0x8d, 0x4f, - 0xe4, 0x08, 0xdc, 0x6f, 0xb8, 0x31, 0xd4, 0xe4, 0x92, 0x1c, 0x43, 0x6f, 0x4d, 0xaf, 0x0a, 0x34, - 0xbc, 0x34, 0x78, 0xdf, 0x79, 0xeb, 0xf8, 0x09, 0xf4, 0x66, 0x6b, 0x4c, 0x85, 0x14, 0x24, 0x36, - 0x59, 0x29, 0x48, 0xae, 0xc9, 0x63, 0x38, 0x90, 0x0c, 0xb8, 0xa0, 0x49, 0xa6, 0x8e, 0xba, 0x61, - 0x15, 0x90, 0x72, 0x8d, 0x7f, 0x46, 0x95, 0x85, 0x75, 0x23, 0xba, 0x0d, 0x23, 0xfc, 0x5f, 0x0e, - 0x8c, 0xce, 0x73, 0xa4, 0x02, 0x3f, 0x67, 0x22, 0x66, 0x29, 0x97, 0x7b, 0x23, 0x96, 0x24, 0x34, - 0x5d, 0x7a, 0xce, 0xd8, 0x95, 0x7b, 0x0d, 0x94, 0x8c, 0x68, 0xbe, 0xe2, 0x5e, 0x47, 0x85, 0xd5, - 0x5a, 0x4a, 0xc3, 0x74, 0xed, 0xb9, 0x2a, 0x24, 0x97, 0xd2, 0x5a, 0x56, 0x88, 0xac, 0x10, 0xe6, - 0x2a, 0x83, 0x4a, 0x3d, 0xbd, 0x9a, 0x9e, 0x63, 0xe8, 0xc5, 0x09, 0x5d, 0xa1, 0xd7, 0xd7, 0x36, - 0x28, 0xe0, 0xff, 0xb0, 0x94, 0x42, 0xfc, 0x5e, 0x20, 0x17, 0xe4, 0xac, 0x12, 0x26, 0xdd, 0x18, - 0x4e, 0x1f, 0xb6, 0x16, 0xa5, 0xd2, 0xfc, 0x0e, 0x06, 0x4c, 0x4b, 0x52, 0x4e, 0x0d, 0xa7, 0xcf, - 0xae, 0x1f, 0x6a, 0x28, 0x0f, 0xed, 0x7e, 0xff, 0x08, 0xee, 0x5b, 0x02, 0x3c, 0x63, 0x29, 0x47, - 0xff, 0x12, 0x86, 0x21, 0xd2, 0x65, 0xcd, 0xa3, 0x3a, 0xa1, 0x9b, 0x9d, 0xde, 0x7a, 0x72, 0x56, - 0xbf, 0x5b, 0xe9, 0xf7, 0xe7, 0x3a, 0xad, 0xd5, 0xf9, 0xa6, 0xa2, 0xac, 0x75, 0x3e, 0xb9, 0x4e, - 0xb9, 0x46, 0xa3, 0x22, 0x3c, 0x83, 0x7b, 0x3a, 0x8f, 0xa6, 0x4b, 0x5e, 0xc3, 0xbe, 0x21, 0xc4, - 0x55, 0x11, 0x77, 0x3a, 0x56, 0x6e, 0xf5, 0x0f, 0x61, 0xf4, 0x11, 0xaf, 0xb0, 0x74, 0x44, 0x56, - 0x42, 0x07, 0xee, 0xbc, 0x12, 0x8d, 0x7b, 0x1b, 0x95, 0xb0, 0x04, 0x4c, 0x25, 0x0e, 0x61, 0x74, - 0x99, 0x2d, 0x69, 0x83, 0xa3, 0x0e, 0xdc, 0x39, 0xc7, 0xc6, 0xbd, 0x0d, 0x8e, 0x96, 0x80, 0xe1, - 0x38, 0x82, 0xe1, 0x45, 0xcc, 0x85, 0x65, 0x38, 0xd7, 0xf0, 0x7f, 0xaa, 0x5c, 0x3b, 0xde, 0xa8, - 0xb2, 0xce, 0x73, 0xbb, 0x2a, 0x4b, 0x76, 0x6c, 0xc5, 0x2d, 0xbb, 0xdf, 0x8e, 0xc6, 0x96, 0x5e, - 0xfb, 0xdb, 0x96, 0x43, 0x53, 0xe4, 0x48, 0x13, 0x65, 0xd1, 0x7e, 0x68, 0x90, 0xec, 0xe2, 0x88, - 0x15, 0xa9, 0x50, 0x4f, 0xdb, 0x0d, 0x35, 0x90, 0x51, 0x1e, 0xa7, 0x11, 0xaa, 0x31, 0xe0, 0x86, - 0x1a, 0xd4, 0xc5, 0xf7, 0x5a, 0xc5, 0x57, 0xec, 0x2a, 0xf1, 0x7f, 0x1c, 0x38, 0xb8, 0x60, 0xab, - 0x10, 0x23, 0x96, 0x2f, 0x9b, 0x83, 0xd0, 0xd9, 0x1e, 0x84, 0xb3, 0xda, 0x14, 0xef, 0x28, 0x63, - 0x5e, 0xde, 0x78, 0x8b, 0x4e, 0xd6, 0x36, 0xc7, 0xa5, 0x13, 0x09, 0x72, 0x2e, 0xe7, 0x93, 0x99, - 0xa7, 0x06, 0xde, 0x6a, 0xc2, 0x4f, 0x7f, 0xba, 0x30, 0x08, 0x35, 0x09, 0xb2, 0x80, 0xbe, 0x9e, - 0x34, 0xa4, 0x75, 0x3a, 0x99, 0xba, 0x9c, 0x8c, 0xdb, 0x37, 0x98, 0x67, 0xb7, 0x47, 0x3e, 0x41, - 0x57, 0xce, 0x01, 0xd2, 0x32, 0x37, 0x6c, 0xaa, 0xa7, 0x6d, 0x9f, 0xcb, 0x44, 0x0b, 0xe8, 0xeb, - 0xbe, 0x23, 0xad, 0xbd, 0xba, 0x83, 0xd7, 0x56, 0xcb, 0xaa, 0x74, 0xba, 0x45, 0x48, 0x6b, 0x5b, - 0xed, 0x48, 0xb7, 0xd5, 0x5d, 0x7b, 0x64, 0x0e, 0x5d, 0xf9, 0x46, 0x48, 0xcb, 0xdb, 0xb1, 0xa9, - 0x1e, 0xed, 0x28, 0xba, 0xbf, 0xf7, 0xca, 0xf9, 0xda, 0x57, 0x3f, 0x16, 0x67, 0xff, 0x02, 0x00, - 0x00, 0xff, 0xff, 0xe1, 0x5b, 0x52, 0x93, 0x7f, 0x08, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// RuntimeClient is the client API for Runtime service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type RuntimeClient interface { - Create(ctx context.Context, in *CreateRequest, opts ...grpc.CallOption) (*CreateResponse, error) - Read(ctx context.Context, in *ReadRequest, opts ...grpc.CallOption) (*ReadResponse, error) - Delete(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*DeleteResponse, error) - Update(ctx context.Context, in *UpdateRequest, opts ...grpc.CallOption) (*UpdateResponse, error) - Logs(ctx context.Context, in *LogsRequest, opts ...grpc.CallOption) (Runtime_LogsClient, error) -} - -type runtimeClient struct { - cc *grpc.ClientConn -} - -func NewRuntimeClient(cc *grpc.ClientConn) RuntimeClient { - return &runtimeClient{cc} -} - -func (c *runtimeClient) Create(ctx context.Context, in *CreateRequest, opts ...grpc.CallOption) (*CreateResponse, error) { - out := new(CreateResponse) - err := c.cc.Invoke(ctx, "/go.micro.runtime.Runtime/Create", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *runtimeClient) Read(ctx context.Context, in *ReadRequest, opts ...grpc.CallOption) (*ReadResponse, error) { - out := new(ReadResponse) - err := c.cc.Invoke(ctx, "/go.micro.runtime.Runtime/Read", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *runtimeClient) Delete(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*DeleteResponse, error) { - out := new(DeleteResponse) - err := c.cc.Invoke(ctx, "/go.micro.runtime.Runtime/Delete", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *runtimeClient) Update(ctx context.Context, in *UpdateRequest, opts ...grpc.CallOption) (*UpdateResponse, error) { - out := new(UpdateResponse) - err := c.cc.Invoke(ctx, "/go.micro.runtime.Runtime/Update", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *runtimeClient) Logs(ctx context.Context, in *LogsRequest, opts ...grpc.CallOption) (Runtime_LogsClient, error) { - stream, err := c.cc.NewStream(ctx, &_Runtime_serviceDesc.Streams[0], "/go.micro.runtime.Runtime/Logs", opts...) - if err != nil { - return nil, err - } - x := &runtimeLogsClient{stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - return x, nil -} - -type Runtime_LogsClient interface { - Recv() (*LogRecord, error) - grpc.ClientStream -} - -type runtimeLogsClient struct { - grpc.ClientStream -} - -func (x *runtimeLogsClient) Recv() (*LogRecord, error) { - m := new(LogRecord) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -// RuntimeServer is the server API for Runtime service. -type RuntimeServer interface { - Create(context.Context, *CreateRequest) (*CreateResponse, error) - Read(context.Context, *ReadRequest) (*ReadResponse, error) - Delete(context.Context, *DeleteRequest) (*DeleteResponse, error) - Update(context.Context, *UpdateRequest) (*UpdateResponse, error) - Logs(*LogsRequest, Runtime_LogsServer) error -} - -// UnimplementedRuntimeServer can be embedded to have forward compatible implementations. -type UnimplementedRuntimeServer struct { -} - -func (*UnimplementedRuntimeServer) Create(ctx context.Context, req *CreateRequest) (*CreateResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Create not implemented") -} -func (*UnimplementedRuntimeServer) Read(ctx context.Context, req *ReadRequest) (*ReadResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Read not implemented") -} -func (*UnimplementedRuntimeServer) Delete(ctx context.Context, req *DeleteRequest) (*DeleteResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented") -} -func (*UnimplementedRuntimeServer) Update(ctx context.Context, req *UpdateRequest) (*UpdateResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Update not implemented") -} -func (*UnimplementedRuntimeServer) Logs(req *LogsRequest, srv Runtime_LogsServer) error { - return status.Errorf(codes.Unimplemented, "method Logs not implemented") -} - -func RegisterRuntimeServer(s *grpc.Server, srv RuntimeServer) { - s.RegisterService(&_Runtime_serviceDesc, srv) -} - -func _Runtime_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RuntimeServer).Create(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/go.micro.runtime.Runtime/Create", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RuntimeServer).Create(ctx, req.(*CreateRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Runtime_Read_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ReadRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RuntimeServer).Read(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/go.micro.runtime.Runtime/Read", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RuntimeServer).Read(ctx, req.(*ReadRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Runtime_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeleteRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RuntimeServer).Delete(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/go.micro.runtime.Runtime/Delete", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RuntimeServer).Delete(ctx, req.(*DeleteRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Runtime_Update_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdateRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RuntimeServer).Update(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/go.micro.runtime.Runtime/Update", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RuntimeServer).Update(ctx, req.(*UpdateRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Runtime_Logs_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(LogsRequest) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(RuntimeServer).Logs(m, &runtimeLogsServer{stream}) -} - -type Runtime_LogsServer interface { - Send(*LogRecord) error - grpc.ServerStream -} - -type runtimeLogsServer struct { - grpc.ServerStream -} - -func (x *runtimeLogsServer) Send(m *LogRecord) error { - return x.ServerStream.SendMsg(m) -} - -var _Runtime_serviceDesc = grpc.ServiceDesc{ - ServiceName: "go.micro.runtime.Runtime", - HandlerType: (*RuntimeServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Create", - Handler: _Runtime_Create_Handler, - }, - { - MethodName: "Read", - Handler: _Runtime_Read_Handler, - }, - { - MethodName: "Delete", - Handler: _Runtime_Delete_Handler, - }, - { - MethodName: "Update", - Handler: _Runtime_Update_Handler, - }, - }, - Streams: []grpc.StreamDesc{ - { - StreamName: "Logs", - Handler: _Runtime_Logs_Handler, - ServerStreams: true, - }, - }, - Metadata: "runtime/service/proto/runtime.proto", -} diff --git a/runtime/service/proto/runtime.pb.micro.go b/runtime/service/proto/runtime.pb.micro.go deleted file mode 100644 index 73b7c3ca..00000000 --- a/runtime/service/proto/runtime.pb.micro.go +++ /dev/null @@ -1,236 +0,0 @@ -// Code generated by protoc-gen-micro. DO NOT EDIT. -// source: runtime/service/proto/runtime.proto - -package go_micro_runtime - -import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" - math "math" -) - -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" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -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 { - Create(ctx context.Context, in *CreateRequest, opts ...client.CallOption) (*CreateResponse, error) - Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error) - Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error) - Update(ctx context.Context, in *UpdateRequest, opts ...client.CallOption) (*UpdateResponse, error) - Logs(ctx context.Context, in *LogsRequest, opts ...client.CallOption) (Runtime_LogsService, error) -} - -type runtimeService struct { - c client.Client - name string -} - -func NewRuntimeService(name string, c client.Client) RuntimeService { - return &runtimeService{ - c: c, - name: name, - } -} - -func (c *runtimeService) Create(ctx context.Context, in *CreateRequest, opts ...client.CallOption) (*CreateResponse, error) { - req := c.c.NewRequest(c.name, "Runtime.Create", in) - out := new(CreateResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *runtimeService) Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error) { - req := c.c.NewRequest(c.name, "Runtime.Read", in) - out := new(ReadResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *runtimeService) Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error) { - req := c.c.NewRequest(c.name, "Runtime.Delete", in) - out := new(DeleteResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *runtimeService) Update(ctx context.Context, in *UpdateRequest, opts ...client.CallOption) (*UpdateResponse, error) { - req := c.c.NewRequest(c.name, "Runtime.Update", in) - out := new(UpdateResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *runtimeService) Logs(ctx context.Context, in *LogsRequest, opts ...client.CallOption) (Runtime_LogsService, error) { - req := c.c.NewRequest(c.name, "Runtime.Logs", &LogsRequest{}) - stream, err := c.c.Stream(ctx, req, opts...) - if err != nil { - return nil, err - } - if err := stream.Send(in); err != nil { - return nil, err - } - return &runtimeServiceLogs{stream}, nil -} - -type Runtime_LogsService interface { - Context() context.Context - SendMsg(interface{}) error - RecvMsg(interface{}) error - Close() error - Recv() (*LogRecord, error) -} - -type runtimeServiceLogs struct { - stream client.Stream -} - -func (x *runtimeServiceLogs) Close() error { - return x.stream.Close() -} - -func (x *runtimeServiceLogs) Context() context.Context { - return x.stream.Context() -} - -func (x *runtimeServiceLogs) SendMsg(m interface{}) error { - return x.stream.Send(m) -} - -func (x *runtimeServiceLogs) RecvMsg(m interface{}) error { - return x.stream.Recv(m) -} - -func (x *runtimeServiceLogs) Recv() (*LogRecord, error) { - m := new(LogRecord) - err := x.stream.Recv(m) - if err != nil { - return nil, err - } - return m, nil -} - -// Server API for Runtime service - -type RuntimeHandler interface { - Create(context.Context, *CreateRequest, *CreateResponse) error - Read(context.Context, *ReadRequest, *ReadResponse) error - Delete(context.Context, *DeleteRequest, *DeleteResponse) error - Update(context.Context, *UpdateRequest, *UpdateResponse) error - Logs(context.Context, *LogsRequest, Runtime_LogsStream) error -} - -func RegisterRuntimeHandler(s server.Server, hdlr RuntimeHandler, opts ...server.HandlerOption) error { - type runtime interface { - Create(ctx context.Context, in *CreateRequest, out *CreateResponse) error - Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error - Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error - Update(ctx context.Context, in *UpdateRequest, out *UpdateResponse) error - Logs(ctx context.Context, stream server.Stream) error - } - type Runtime struct { - runtime - } - h := &runtimeHandler{hdlr} - return s.Handle(s.NewHandler(&Runtime{h}, opts...)) -} - -type runtimeHandler struct { - RuntimeHandler -} - -func (h *runtimeHandler) Create(ctx context.Context, in *CreateRequest, out *CreateResponse) error { - return h.RuntimeHandler.Create(ctx, in, out) -} - -func (h *runtimeHandler) Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error { - return h.RuntimeHandler.Read(ctx, in, out) -} - -func (h *runtimeHandler) Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error { - return h.RuntimeHandler.Delete(ctx, in, out) -} - -func (h *runtimeHandler) Update(ctx context.Context, in *UpdateRequest, out *UpdateResponse) error { - return h.RuntimeHandler.Update(ctx, in, out) -} - -func (h *runtimeHandler) Logs(ctx context.Context, stream server.Stream) error { - m := new(LogsRequest) - if err := stream.Recv(m); err != nil { - return err - } - return h.RuntimeHandler.Logs(ctx, m, &runtimeLogsStream{stream}) -} - -type Runtime_LogsStream interface { - Context() context.Context - SendMsg(interface{}) error - RecvMsg(interface{}) error - Close() error - Send(*LogRecord) error -} - -type runtimeLogsStream struct { - stream server.Stream -} - -func (x *runtimeLogsStream) Close() error { - return x.stream.Close() -} - -func (x *runtimeLogsStream) Context() context.Context { - return x.stream.Context() -} - -func (x *runtimeLogsStream) SendMsg(m interface{}) error { - return x.stream.Send(m) -} - -func (x *runtimeLogsStream) RecvMsg(m interface{}) error { - return x.stream.Recv(m) -} - -func (x *runtimeLogsStream) Send(m *LogRecord) error { - return x.stream.Send(m) -} diff --git a/runtime/service/proto/runtime.proto b/runtime/service/proto/runtime.proto deleted file mode 100644 index 34b5a6df..00000000 --- a/runtime/service/proto/runtime.proto +++ /dev/null @@ -1,127 +0,0 @@ -syntax = "proto3"; - -package go.micro.runtime; - -service Runtime { - rpc Create(CreateRequest) returns (CreateResponse) {}; - rpc Read(ReadRequest) returns (ReadResponse) {}; - rpc Delete(DeleteRequest) returns (DeleteResponse) {}; - rpc Update(UpdateRequest) returns (UpdateResponse) {}; - rpc Logs(LogsRequest) returns (stream LogRecord) {}; -} - -message Service { - // name of the service - string name = 1; - // version of the service - string version = 2; - // git url of the source - string source = 3; - // service metadata - map metadata = 4; -} - -message Event { - string type = 1; - int64 timestamp = 2; - string service = 3; - string version = 4; -} - -message CreateOptions { - // command to pass in - repeated string command = 1; - // args to pass into command - repeated string args = 2; - // environment to pass in - repeated string env = 3; - // output to send to - string output = 4; - // create type of service - string type = 5; - // image to use - string image = 6; -} - -message CreateRequest { - Service service = 1; - CreateOptions options = 2; -} - -message CreateResponse {} - -message ReadOptions { - // service name - string service = 1; - // version of the service - string version = 2; - // type of service - string type = 3; -} - -message ReadRequest { - ReadOptions options = 1; -} - -message ReadResponse { - repeated Service services = 1; -} - -message DeleteOptions { -} - -message DeleteRequest { - Service service = 1; - DeleteOptions options = 2; -} - -message DeleteResponse {} - -message UpdateOptions { -} - -message UpdateRequest { - Service service = 1; - UpdateOptions options = 2; -} - -message UpdateResponse {} - -message ListOptions { -} - -message ListRequest { - ListOptions options = 1; -} - -message ListResponse { - repeated Service services = 1; -} - -message LogsOptions { -} - -message LogsRequest{ - // service to request logs for - string service = 1; - // stream records continuously - bool stream = 2; - // count of records to request - int64 count = 3; - // relative time in seconds - // before the current time - // from which to show logs - int64 since = 4; - // options to use - LogsOptions options = 5; -} - -message LogRecord { - // timestamp of log record - int64 timestamp = 1; - // record metadata - map metadata = 2; - // message - string message = 3; -} - diff --git a/runtime/service/service.go b/runtime/service/service.go deleted file mode 100644 index fb2f1c24..00000000 --- a/runtime/service/service.go +++ /dev/null @@ -1,286 +0,0 @@ -package service - -import ( - "context" - "sync" - - "github.com/micro/go-micro/v2/client" - "github.com/micro/go-micro/v2/runtime" - pb "github.com/micro/go-micro/v2/runtime/service/proto" -) - -type svc struct { - sync.RWMutex - options runtime.Options - runtime pb.RuntimeService -} - -// Init initializes runtime with given options -func (s *svc) Init(opts ...runtime.Option) error { - s.Lock() - defer s.Unlock() - - for _, o := range opts { - o(&s.options) - } - - // reset the runtime as the client could have changed - s.runtime = pb.NewRuntimeService(runtime.DefaultName, s.options.Client) - - return nil -} - -// Create registers a service in the runtime -func (s *svc) Create(svc *runtime.Service, opts ...runtime.CreateOption) error { - var options runtime.CreateOptions - for _, o := range opts { - o(&options) - } - if options.Context == nil { - options.Context = context.Background() - } - - // set the default source from MICRO_RUNTIME_SOURCE - if len(svc.Source) == 0 { - svc.Source = s.options.Source - } - - // runtime service create request - req := &pb.CreateRequest{ - Service: &pb.Service{ - Name: svc.Name, - Version: svc.Version, - Source: svc.Source, - Metadata: svc.Metadata, - }, - Options: &pb.CreateOptions{ - Command: options.Command, - Args: options.Args, - Env: options.Env, - Type: options.Type, - Image: options.Image, - }, - } - - if _, err := s.runtime.Create(options.Context, req); err != nil { - return err - } - - return nil -} - -func (s *svc) Logs(service *runtime.Service, opts ...runtime.LogsOption) (runtime.LogStream, error) { - var options runtime.LogsOptions - for _, o := range opts { - o(&options) - } - - if options.Context == nil { - options.Context = context.Background() - } - - ls, err := s.runtime.Logs(options.Context, &pb.LogsRequest{ - Service: service.Name, - Stream: options.Stream, - Count: options.Count, - }) - if err != nil { - return nil, err - } - logStream := &serviceLogStream{ - service: service.Name, - stream: make(chan runtime.LogRecord), - stop: make(chan bool), - } - - go func() { - for { - select { - // @todo this never seems to return, investigate - case <-ls.Context().Done(): - logStream.Stop() - } - } - }() - - go func() { - for { - select { - // @todo this never seems to return, investigate - case <-ls.Context().Done(): - return - case _, ok := <-logStream.stream: - if !ok { - return - } - default: - record := pb.LogRecord{} - err := ls.RecvMsg(&record) - if err != nil { - logStream.Stop() - return - } - logStream.stream <- runtime.LogRecord{ - Message: record.GetMessage(), - Metadata: record.GetMetadata(), - } - } - } - }() - return logStream, nil -} - -type serviceLogStream struct { - service string - stream chan runtime.LogRecord - sync.Mutex - stop chan bool - err error -} - -func (l *serviceLogStream) Error() error { - return l.err -} - -func (l *serviceLogStream) Chan() chan runtime.LogRecord { - return l.stream -} - -func (l *serviceLogStream) Stop() error { - l.Lock() - defer l.Unlock() - select { - case <-l.stop: - return nil - default: - close(l.stream) - close(l.stop) - } - return nil -} - -// Read returns the service with the given name from the runtime -func (s *svc) Read(opts ...runtime.ReadOption) ([]*runtime.Service, error) { - var options runtime.ReadOptions - for _, o := range opts { - o(&options) - } - if options.Context == nil { - options.Context = context.Background() - } - - // runtime service create request - req := &pb.ReadRequest{ - Options: &pb.ReadOptions{ - Service: options.Service, - Version: options.Version, - Type: options.Type, - }, - } - - resp, err := s.runtime.Read(options.Context, req) - if err != nil { - return nil, err - } - - services := make([]*runtime.Service, 0, len(resp.Services)) - for _, service := range resp.Services { - svc := &runtime.Service{ - Name: service.Name, - Version: service.Version, - Source: service.Source, - Metadata: service.Metadata, - } - services = append(services, svc) - } - - return services, nil -} - -// Update updates the running service -func (s *svc) Update(svc *runtime.Service, opts ...runtime.UpdateOption) error { - var options runtime.UpdateOptions - for _, o := range opts { - o(&options) - } - if options.Context == nil { - options.Context = context.Background() - } - - // runtime service create request - req := &pb.UpdateRequest{ - Service: &pb.Service{ - Name: svc.Name, - Version: svc.Version, - Source: svc.Source, - Metadata: svc.Metadata, - }, - } - - if _, err := s.runtime.Update(options.Context, req); err != nil { - return err - } - - return nil -} - -// Delete stops and removes the service from the runtime -func (s *svc) Delete(svc *runtime.Service, opts ...runtime.DeleteOption) error { - var options runtime.DeleteOptions - for _, o := range opts { - o(&options) - } - if options.Context == nil { - options.Context = context.Background() - } - - // runtime service create request - req := &pb.DeleteRequest{ - Service: &pb.Service{ - Name: svc.Name, - Version: svc.Version, - Source: svc.Source, - Metadata: svc.Metadata, - }, - } - - if _, err := s.runtime.Delete(options.Context, req); err != nil { - return err - } - - return nil -} - -// Start starts the runtime -func (s *svc) Start() error { - // NOTE: nothing to be done here - return nil -} - -// Stop stops the runtime -func (s *svc) Stop() error { - // NOTE: nothing to be done here - return nil -} - -// Returns the runtime service implementation -func (s *svc) String() string { - return "service" -} - -// NewRuntime creates new service runtime and returns it -func NewRuntime(opts ...runtime.Option) runtime.Runtime { - var options runtime.Options - - for _, o := range opts { - o(&options) - } - if options.Client == nil { - options.Client = client.DefaultClient - } - - return &svc{ - options: options, - runtime: pb.NewRuntimeService(runtime.DefaultName, options.Client), - } -} diff --git a/store/service/proto/store.pb.go b/store/service/proto/store.pb.go deleted file mode 100644 index f8f82515..00000000 --- a/store/service/proto/store.pb.go +++ /dev/null @@ -1,1455 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.22.0 -// protoc v3.11.4 -// source: github.com/micro/go-micro/store/service/proto/store.proto - -package go_micro_store - -import ( - proto "github.com/golang/protobuf/proto" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 - -type Field struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // type of value e.g string, int, int64, bool, float64 - Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` - // the actual value - Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` -} - -func (x *Field) Reset() { - *x = Field{} - if protoimpl.UnsafeEnabled { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Field) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Field) ProtoMessage() {} - -func (x *Field) ProtoReflect() protoreflect.Message { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Field.ProtoReflect.Descriptor instead. -func (*Field) Descriptor() ([]byte, []int) { - return file_github_com_micro_go_micro_store_service_proto_store_proto_rawDescGZIP(), []int{0} -} - -func (x *Field) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -func (x *Field) GetValue() string { - if x != nil { - return x.Value - } - return "" -} - -type Record struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // key of the record - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - // value in the record - Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` - // time.Duration (signed int64 nanoseconds) - Expiry int64 `protobuf:"varint,3,opt,name=expiry,proto3" json:"expiry,omitempty"` - // the associated metadata - Metadata map[string]*Field `protobuf:"bytes,4,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` -} - -func (x *Record) Reset() { - *x = Record{} - if protoimpl.UnsafeEnabled { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Record) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Record) ProtoMessage() {} - -func (x *Record) ProtoReflect() protoreflect.Message { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Record.ProtoReflect.Descriptor instead. -func (*Record) Descriptor() ([]byte, []int) { - return file_github_com_micro_go_micro_store_service_proto_store_proto_rawDescGZIP(), []int{1} -} - -func (x *Record) GetKey() string { - if x != nil { - return x.Key - } - return "" -} - -func (x *Record) GetValue() []byte { - if x != nil { - return x.Value - } - return nil -} - -func (x *Record) GetExpiry() int64 { - if x != nil { - return x.Expiry - } - return 0 -} - -func (x *Record) GetMetadata() map[string]*Field { - if x != nil { - return x.Metadata - } - return nil -} - -type ReadOptions struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Database string `protobuf:"bytes,1,opt,name=database,proto3" json:"database,omitempty"` - Table string `protobuf:"bytes,2,opt,name=table,proto3" json:"table,omitempty"` - Prefix bool `protobuf:"varint,3,opt,name=prefix,proto3" json:"prefix,omitempty"` - Suffix bool `protobuf:"varint,4,opt,name=suffix,proto3" json:"suffix,omitempty"` - Limit uint64 `protobuf:"varint,5,opt,name=limit,proto3" json:"limit,omitempty"` - Offset uint64 `protobuf:"varint,6,opt,name=offset,proto3" json:"offset,omitempty"` -} - -func (x *ReadOptions) Reset() { - *x = ReadOptions{} - if protoimpl.UnsafeEnabled { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ReadOptions) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ReadOptions) ProtoMessage() {} - -func (x *ReadOptions) ProtoReflect() protoreflect.Message { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ReadOptions.ProtoReflect.Descriptor instead. -func (*ReadOptions) Descriptor() ([]byte, []int) { - return file_github_com_micro_go_micro_store_service_proto_store_proto_rawDescGZIP(), []int{2} -} - -func (x *ReadOptions) GetDatabase() string { - if x != nil { - return x.Database - } - return "" -} - -func (x *ReadOptions) GetTable() string { - if x != nil { - return x.Table - } - return "" -} - -func (x *ReadOptions) GetPrefix() bool { - if x != nil { - return x.Prefix - } - return false -} - -func (x *ReadOptions) GetSuffix() bool { - if x != nil { - return x.Suffix - } - return false -} - -func (x *ReadOptions) GetLimit() uint64 { - if x != nil { - return x.Limit - } - return 0 -} - -func (x *ReadOptions) GetOffset() uint64 { - if x != nil { - return x.Offset - } - return 0 -} - -type ReadRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Options *ReadOptions `protobuf:"bytes,2,opt,name=options,proto3" json:"options,omitempty"` -} - -func (x *ReadRequest) Reset() { - *x = ReadRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ReadRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ReadRequest) ProtoMessage() {} - -func (x *ReadRequest) ProtoReflect() protoreflect.Message { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ReadRequest.ProtoReflect.Descriptor instead. -func (*ReadRequest) Descriptor() ([]byte, []int) { - return file_github_com_micro_go_micro_store_service_proto_store_proto_rawDescGZIP(), []int{3} -} - -func (x *ReadRequest) GetKey() string { - if x != nil { - return x.Key - } - return "" -} - -func (x *ReadRequest) GetOptions() *ReadOptions { - if x != nil { - return x.Options - } - return nil -} - -type ReadResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Records []*Record `protobuf:"bytes,1,rep,name=records,proto3" json:"records,omitempty"` -} - -func (x *ReadResponse) Reset() { - *x = ReadResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ReadResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ReadResponse) ProtoMessage() {} - -func (x *ReadResponse) ProtoReflect() protoreflect.Message { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ReadResponse.ProtoReflect.Descriptor instead. -func (*ReadResponse) Descriptor() ([]byte, []int) { - return file_github_com_micro_go_micro_store_service_proto_store_proto_rawDescGZIP(), []int{4} -} - -func (x *ReadResponse) GetRecords() []*Record { - if x != nil { - return x.Records - } - return nil -} - -type WriteOptions struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Database string `protobuf:"bytes,1,opt,name=database,proto3" json:"database,omitempty"` - Table string `protobuf:"bytes,2,opt,name=table,proto3" json:"table,omitempty"` - // time.Time - Expiry int64 `protobuf:"varint,3,opt,name=expiry,proto3" json:"expiry,omitempty"` - // time.Duration - Ttl int64 `protobuf:"varint,4,opt,name=ttl,proto3" json:"ttl,omitempty"` -} - -func (x *WriteOptions) Reset() { - *x = WriteOptions{} - if protoimpl.UnsafeEnabled { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *WriteOptions) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*WriteOptions) ProtoMessage() {} - -func (x *WriteOptions) ProtoReflect() protoreflect.Message { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use WriteOptions.ProtoReflect.Descriptor instead. -func (*WriteOptions) Descriptor() ([]byte, []int) { - return file_github_com_micro_go_micro_store_service_proto_store_proto_rawDescGZIP(), []int{5} -} - -func (x *WriteOptions) GetDatabase() string { - if x != nil { - return x.Database - } - return "" -} - -func (x *WriteOptions) GetTable() string { - if x != nil { - return x.Table - } - return "" -} - -func (x *WriteOptions) GetExpiry() int64 { - if x != nil { - return x.Expiry - } - return 0 -} - -func (x *WriteOptions) GetTtl() int64 { - if x != nil { - return x.Ttl - } - return 0 -} - -type WriteRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Record *Record `protobuf:"bytes,1,opt,name=record,proto3" json:"record,omitempty"` - Options *WriteOptions `protobuf:"bytes,2,opt,name=options,proto3" json:"options,omitempty"` -} - -func (x *WriteRequest) Reset() { - *x = WriteRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *WriteRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*WriteRequest) ProtoMessage() {} - -func (x *WriteRequest) ProtoReflect() protoreflect.Message { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use WriteRequest.ProtoReflect.Descriptor instead. -func (*WriteRequest) Descriptor() ([]byte, []int) { - return file_github_com_micro_go_micro_store_service_proto_store_proto_rawDescGZIP(), []int{6} -} - -func (x *WriteRequest) GetRecord() *Record { - if x != nil { - return x.Record - } - return nil -} - -func (x *WriteRequest) GetOptions() *WriteOptions { - if x != nil { - return x.Options - } - return nil -} - -type WriteResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *WriteResponse) Reset() { - *x = WriteResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *WriteResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*WriteResponse) ProtoMessage() {} - -func (x *WriteResponse) ProtoReflect() protoreflect.Message { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use WriteResponse.ProtoReflect.Descriptor instead. -func (*WriteResponse) Descriptor() ([]byte, []int) { - return file_github_com_micro_go_micro_store_service_proto_store_proto_rawDescGZIP(), []int{7} -} - -type DeleteOptions struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Database string `protobuf:"bytes,1,opt,name=database,proto3" json:"database,omitempty"` - Table string `protobuf:"bytes,2,opt,name=table,proto3" json:"table,omitempty"` -} - -func (x *DeleteOptions) Reset() { - *x = DeleteOptions{} - if protoimpl.UnsafeEnabled { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DeleteOptions) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteOptions) ProtoMessage() {} - -func (x *DeleteOptions) ProtoReflect() protoreflect.Message { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[8] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DeleteOptions.ProtoReflect.Descriptor instead. -func (*DeleteOptions) Descriptor() ([]byte, []int) { - return file_github_com_micro_go_micro_store_service_proto_store_proto_rawDescGZIP(), []int{8} -} - -func (x *DeleteOptions) GetDatabase() string { - if x != nil { - return x.Database - } - return "" -} - -func (x *DeleteOptions) GetTable() string { - if x != nil { - return x.Table - } - return "" -} - -type DeleteRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Options *DeleteOptions `protobuf:"bytes,2,opt,name=options,proto3" json:"options,omitempty"` -} - -func (x *DeleteRequest) Reset() { - *x = DeleteRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DeleteRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteRequest) ProtoMessage() {} - -func (x *DeleteRequest) ProtoReflect() protoreflect.Message { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[9] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DeleteRequest.ProtoReflect.Descriptor instead. -func (*DeleteRequest) Descriptor() ([]byte, []int) { - return file_github_com_micro_go_micro_store_service_proto_store_proto_rawDescGZIP(), []int{9} -} - -func (x *DeleteRequest) GetKey() string { - if x != nil { - return x.Key - } - return "" -} - -func (x *DeleteRequest) GetOptions() *DeleteOptions { - if x != nil { - return x.Options - } - return nil -} - -type DeleteResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *DeleteResponse) Reset() { - *x = DeleteResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DeleteResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteResponse) ProtoMessage() {} - -func (x *DeleteResponse) ProtoReflect() protoreflect.Message { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[10] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DeleteResponse.ProtoReflect.Descriptor instead. -func (*DeleteResponse) Descriptor() ([]byte, []int) { - return file_github_com_micro_go_micro_store_service_proto_store_proto_rawDescGZIP(), []int{10} -} - -type ListOptions struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Database string `protobuf:"bytes,1,opt,name=database,proto3" json:"database,omitempty"` - Table string `protobuf:"bytes,2,opt,name=table,proto3" json:"table,omitempty"` - Prefix string `protobuf:"bytes,3,opt,name=prefix,proto3" json:"prefix,omitempty"` - Suffix string `protobuf:"bytes,4,opt,name=suffix,proto3" json:"suffix,omitempty"` - Limit uint64 `protobuf:"varint,5,opt,name=limit,proto3" json:"limit,omitempty"` - Offset uint64 `protobuf:"varint,6,opt,name=offset,proto3" json:"offset,omitempty"` -} - -func (x *ListOptions) Reset() { - *x = ListOptions{} - if protoimpl.UnsafeEnabled { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListOptions) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListOptions) ProtoMessage() {} - -func (x *ListOptions) ProtoReflect() protoreflect.Message { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[11] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListOptions.ProtoReflect.Descriptor instead. -func (*ListOptions) Descriptor() ([]byte, []int) { - return file_github_com_micro_go_micro_store_service_proto_store_proto_rawDescGZIP(), []int{11} -} - -func (x *ListOptions) GetDatabase() string { - if x != nil { - return x.Database - } - return "" -} - -func (x *ListOptions) GetTable() string { - if x != nil { - return x.Table - } - return "" -} - -func (x *ListOptions) GetPrefix() string { - if x != nil { - return x.Prefix - } - return "" -} - -func (x *ListOptions) GetSuffix() string { - if x != nil { - return x.Suffix - } - return "" -} - -func (x *ListOptions) GetLimit() uint64 { - if x != nil { - return x.Limit - } - return 0 -} - -func (x *ListOptions) GetOffset() uint64 { - if x != nil { - return x.Offset - } - return 0 -} - -type ListRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Options *ListOptions `protobuf:"bytes,1,opt,name=options,proto3" json:"options,omitempty"` -} - -func (x *ListRequest) Reset() { - *x = ListRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListRequest) ProtoMessage() {} - -func (x *ListRequest) ProtoReflect() protoreflect.Message { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[12] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListRequest.ProtoReflect.Descriptor instead. -func (*ListRequest) Descriptor() ([]byte, []int) { - return file_github_com_micro_go_micro_store_service_proto_store_proto_rawDescGZIP(), []int{12} -} - -func (x *ListRequest) GetOptions() *ListOptions { - if x != nil { - return x.Options - } - return nil -} - -type ListResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Keys []string `protobuf:"bytes,2,rep,name=keys,proto3" json:"keys,omitempty"` -} - -func (x *ListResponse) Reset() { - *x = ListResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListResponse) ProtoMessage() {} - -func (x *ListResponse) ProtoReflect() protoreflect.Message { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[13] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListResponse.ProtoReflect.Descriptor instead. -func (*ListResponse) Descriptor() ([]byte, []int) { - return file_github_com_micro_go_micro_store_service_proto_store_proto_rawDescGZIP(), []int{13} -} - -func (x *ListResponse) GetKeys() []string { - if x != nil { - return x.Keys - } - return nil -} - -type DatabasesRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *DatabasesRequest) Reset() { - *x = DatabasesRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[14] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DatabasesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DatabasesRequest) ProtoMessage() {} - -func (x *DatabasesRequest) ProtoReflect() protoreflect.Message { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[14] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DatabasesRequest.ProtoReflect.Descriptor instead. -func (*DatabasesRequest) Descriptor() ([]byte, []int) { - return file_github_com_micro_go_micro_store_service_proto_store_proto_rawDescGZIP(), []int{14} -} - -type DatabasesResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Databases []string `protobuf:"bytes,1,rep,name=databases,proto3" json:"databases,omitempty"` -} - -func (x *DatabasesResponse) Reset() { - *x = DatabasesResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DatabasesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DatabasesResponse) ProtoMessage() {} - -func (x *DatabasesResponse) ProtoReflect() protoreflect.Message { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[15] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DatabasesResponse.ProtoReflect.Descriptor instead. -func (*DatabasesResponse) Descriptor() ([]byte, []int) { - return file_github_com_micro_go_micro_store_service_proto_store_proto_rawDescGZIP(), []int{15} -} - -func (x *DatabasesResponse) GetDatabases() []string { - if x != nil { - return x.Databases - } - return nil -} - -type TablesRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Database string `protobuf:"bytes,1,opt,name=database,proto3" json:"database,omitempty"` -} - -func (x *TablesRequest) Reset() { - *x = TablesRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[16] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *TablesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*TablesRequest) ProtoMessage() {} - -func (x *TablesRequest) ProtoReflect() protoreflect.Message { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[16] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use TablesRequest.ProtoReflect.Descriptor instead. -func (*TablesRequest) Descriptor() ([]byte, []int) { - return file_github_com_micro_go_micro_store_service_proto_store_proto_rawDescGZIP(), []int{16} -} - -func (x *TablesRequest) GetDatabase() string { - if x != nil { - return x.Database - } - return "" -} - -type TablesResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Tables []string `protobuf:"bytes,1,rep,name=tables,proto3" json:"tables,omitempty"` -} - -func (x *TablesResponse) Reset() { - *x = TablesResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[17] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *TablesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*TablesResponse) ProtoMessage() {} - -func (x *TablesResponse) ProtoReflect() protoreflect.Message { - mi := &file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[17] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use TablesResponse.ProtoReflect.Descriptor instead. -func (*TablesResponse) Descriptor() ([]byte, []int) { - return file_github_com_micro_go_micro_store_service_proto_store_proto_rawDescGZIP(), []int{17} -} - -func (x *TablesResponse) GetTables() []string { - if x != nil { - return x.Tables - } - return nil -} - -var File_github_com_micro_go_micro_store_service_proto_store_proto protoreflect.FileDescriptor - -var file_github_com_micro_go_micro_store_service_proto_store_proto_rawDesc = []byte{ - 0x0a, 0x39, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x69, 0x63, - 0x72, 0x6f, 0x2f, 0x67, 0x6f, 0x2d, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2f, 0x73, 0x74, 0x6f, 0x72, - 0x65, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, - 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x67, 0x6f, 0x2e, - 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x22, 0x31, 0x0a, 0x05, 0x46, - 0x69, 0x65, 0x6c, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xde, - 0x01, 0x0a, 0x06, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x78, 0x70, 0x69, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x06, 0x65, 0x78, 0x70, 0x69, 0x72, 0x79, 0x12, 0x40, 0x0a, 0x08, 0x6d, 0x65, 0x74, - 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x67, 0x6f, - 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x52, 0x65, 0x63, - 0x6f, 0x72, 0x64, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, - 0x79, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x1a, 0x52, 0x0a, 0x0d, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, - 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2b, - 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, - 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x46, - 0x69, 0x65, 0x6c, 0x64, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, - 0x9d, 0x01, 0x0a, 0x0b, 0x52, 0x65, 0x61, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, - 0x1a, 0x0a, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, - 0x61, 0x62, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x61, 0x62, 0x6c, - 0x65, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x75, 0x66, - 0x66, 0x69, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x73, 0x75, 0x66, 0x66, 0x69, - 0x78, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, - 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x22, - 0x56, 0x0a, 0x0b, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, - 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, - 0x12, 0x35, 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x74, 0x6f, - 0x72, 0x65, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x07, - 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x40, 0x0a, 0x0c, 0x52, 0x65, 0x61, 0x64, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x07, 0x72, 0x65, 0x63, 0x6f, 0x72, - 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, - 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, - 0x52, 0x07, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x73, 0x22, 0x6a, 0x0a, 0x0c, 0x57, 0x72, 0x69, - 0x74, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x61, 0x74, - 0x61, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x64, 0x61, 0x74, - 0x61, 0x62, 0x61, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x65, - 0x78, 0x70, 0x69, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x65, 0x78, 0x70, - 0x69, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x74, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x03, 0x74, 0x74, 0x6c, 0x22, 0x76, 0x0a, 0x0c, 0x57, 0x72, 0x69, 0x74, 0x65, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2e, 0x0a, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, - 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x06, 0x72, - 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x36, 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, - 0x6f, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x57, 0x72, 0x69, 0x74, 0x65, 0x4f, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x0f, 0x0a, - 0x0d, 0x57, 0x72, 0x69, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x41, - 0x0a, 0x0d, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, - 0x1a, 0x0a, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, - 0x61, 0x62, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x61, 0x62, 0x6c, - 0x65, 0x22, 0x5a, 0x0a, 0x0d, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x6b, 0x65, 0x79, 0x12, 0x37, 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, - 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4f, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x10, 0x0a, - 0x0e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x9d, 0x01, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, - 0x1a, 0x0a, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, - 0x61, 0x62, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x61, 0x62, 0x6c, - 0x65, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x75, 0x66, - 0x66, 0x69, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x75, 0x66, 0x66, 0x69, - 0x78, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, - 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x22, - 0x44, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x35, - 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x1b, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, - 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x07, 0x6f, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x28, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x18, 0x02, 0x20, - 0x03, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x22, - 0x12, 0x0a, 0x10, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x22, 0x31, 0x0a, 0x11, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x64, 0x61, 0x74, 0x61, - 0x62, 0x61, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x64, 0x61, 0x74, - 0x61, 0x62, 0x61, 0x73, 0x65, 0x73, 0x22, 0x2b, 0x0a, 0x0d, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, - 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, - 0x61, 0x73, 0x65, 0x22, 0x28, 0x0a, 0x0e, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x18, - 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x32, 0xc5, 0x03, - 0x0a, 0x05, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x12, 0x43, 0x0a, 0x04, 0x52, 0x65, 0x61, 0x64, 0x12, - 0x1b, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, - 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x67, - 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x52, 0x65, - 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x46, 0x0a, 0x05, - 0x57, 0x72, 0x69, 0x74, 0x65, 0x12, 0x1c, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, - 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x57, 0x72, 0x69, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, - 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x57, 0x72, 0x69, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x12, 0x49, 0x0a, 0x06, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x1d, - 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, - 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, - 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x44, - 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, - 0x45, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1b, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, - 0x72, 0x6f, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, - 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x52, 0x0a, 0x09, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, - 0x73, 0x65, 0x73, 0x12, 0x20, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, - 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, - 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x49, 0x0a, 0x06, 0x54, 0x61, - 0x62, 0x6c, 0x65, 0x73, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, - 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x67, 0x6f, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x73, - 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_github_com_micro_go_micro_store_service_proto_store_proto_rawDescOnce sync.Once - file_github_com_micro_go_micro_store_service_proto_store_proto_rawDescData = file_github_com_micro_go_micro_store_service_proto_store_proto_rawDesc -) - -func file_github_com_micro_go_micro_store_service_proto_store_proto_rawDescGZIP() []byte { - file_github_com_micro_go_micro_store_service_proto_store_proto_rawDescOnce.Do(func() { - file_github_com_micro_go_micro_store_service_proto_store_proto_rawDescData = protoimpl.X.CompressGZIP(file_github_com_micro_go_micro_store_service_proto_store_proto_rawDescData) - }) - return file_github_com_micro_go_micro_store_service_proto_store_proto_rawDescData -} - -var file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes = make([]protoimpl.MessageInfo, 19) -var file_github_com_micro_go_micro_store_service_proto_store_proto_goTypes = []interface{}{ - (*Field)(nil), // 0: go.micro.store.Field - (*Record)(nil), // 1: go.micro.store.Record - (*ReadOptions)(nil), // 2: go.micro.store.ReadOptions - (*ReadRequest)(nil), // 3: go.micro.store.ReadRequest - (*ReadResponse)(nil), // 4: go.micro.store.ReadResponse - (*WriteOptions)(nil), // 5: go.micro.store.WriteOptions - (*WriteRequest)(nil), // 6: go.micro.store.WriteRequest - (*WriteResponse)(nil), // 7: go.micro.store.WriteResponse - (*DeleteOptions)(nil), // 8: go.micro.store.DeleteOptions - (*DeleteRequest)(nil), // 9: go.micro.store.DeleteRequest - (*DeleteResponse)(nil), // 10: go.micro.store.DeleteResponse - (*ListOptions)(nil), // 11: go.micro.store.ListOptions - (*ListRequest)(nil), // 12: go.micro.store.ListRequest - (*ListResponse)(nil), // 13: go.micro.store.ListResponse - (*DatabasesRequest)(nil), // 14: go.micro.store.DatabasesRequest - (*DatabasesResponse)(nil), // 15: go.micro.store.DatabasesResponse - (*TablesRequest)(nil), // 16: go.micro.store.TablesRequest - (*TablesResponse)(nil), // 17: go.micro.store.TablesResponse - nil, // 18: go.micro.store.Record.MetadataEntry -} -var file_github_com_micro_go_micro_store_service_proto_store_proto_depIdxs = []int32{ - 18, // 0: go.micro.store.Record.metadata:type_name -> go.micro.store.Record.MetadataEntry - 2, // 1: go.micro.store.ReadRequest.options:type_name -> go.micro.store.ReadOptions - 1, // 2: go.micro.store.ReadResponse.records:type_name -> go.micro.store.Record - 1, // 3: go.micro.store.WriteRequest.record:type_name -> go.micro.store.Record - 5, // 4: go.micro.store.WriteRequest.options:type_name -> go.micro.store.WriteOptions - 8, // 5: go.micro.store.DeleteRequest.options:type_name -> go.micro.store.DeleteOptions - 11, // 6: go.micro.store.ListRequest.options:type_name -> go.micro.store.ListOptions - 0, // 7: go.micro.store.Record.MetadataEntry.value:type_name -> go.micro.store.Field - 3, // 8: go.micro.store.Store.Read:input_type -> go.micro.store.ReadRequest - 6, // 9: go.micro.store.Store.Write:input_type -> go.micro.store.WriteRequest - 9, // 10: go.micro.store.Store.Delete:input_type -> go.micro.store.DeleteRequest - 12, // 11: go.micro.store.Store.List:input_type -> go.micro.store.ListRequest - 14, // 12: go.micro.store.Store.Databases:input_type -> go.micro.store.DatabasesRequest - 16, // 13: go.micro.store.Store.Tables:input_type -> go.micro.store.TablesRequest - 4, // 14: go.micro.store.Store.Read:output_type -> go.micro.store.ReadResponse - 7, // 15: go.micro.store.Store.Write:output_type -> go.micro.store.WriteResponse - 10, // 16: go.micro.store.Store.Delete:output_type -> go.micro.store.DeleteResponse - 13, // 17: go.micro.store.Store.List:output_type -> go.micro.store.ListResponse - 15, // 18: go.micro.store.Store.Databases:output_type -> go.micro.store.DatabasesResponse - 17, // 19: go.micro.store.Store.Tables:output_type -> go.micro.store.TablesResponse - 14, // [14:20] is the sub-list for method output_type - 8, // [8:14] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name -} - -func init() { file_github_com_micro_go_micro_store_service_proto_store_proto_init() } -func file_github_com_micro_go_micro_store_service_proto_store_proto_init() { - if File_github_com_micro_go_micro_store_service_proto_store_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Field); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Record); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ReadOptions); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ReadRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ReadResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*WriteOptions); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*WriteRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*WriteResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteOptions); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListOptions); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DatabasesRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DatabasesResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*TablesRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*TablesResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_github_com_micro_go_micro_store_service_proto_store_proto_rawDesc, - NumEnums: 0, - NumMessages: 19, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_github_com_micro_go_micro_store_service_proto_store_proto_goTypes, - DependencyIndexes: file_github_com_micro_go_micro_store_service_proto_store_proto_depIdxs, - MessageInfos: file_github_com_micro_go_micro_store_service_proto_store_proto_msgTypes, - }.Build() - File_github_com_micro_go_micro_store_service_proto_store_proto = out.File - file_github_com_micro_go_micro_store_service_proto_store_proto_rawDesc = nil - file_github_com_micro_go_micro_store_service_proto_store_proto_goTypes = nil - file_github_com_micro_go_micro_store_service_proto_store_proto_depIdxs = nil -} diff --git a/store/service/proto/store.pb.micro.go b/store/service/proto/store.pb.micro.go deleted file mode 100644 index 668a5a87..00000000 --- a/store/service/proto/store.pb.micro.go +++ /dev/null @@ -1,253 +0,0 @@ -// Code generated by protoc-gen-micro. DO NOT EDIT. -// source: github.com/micro/go-micro/store/service/proto/store.proto - -package go_micro_store - -import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" - math "math" -) - -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" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -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 { - Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error) - Write(ctx context.Context, in *WriteRequest, opts ...client.CallOption) (*WriteResponse, error) - Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error) - List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (Store_ListService, error) - Databases(ctx context.Context, in *DatabasesRequest, opts ...client.CallOption) (*DatabasesResponse, error) - Tables(ctx context.Context, in *TablesRequest, opts ...client.CallOption) (*TablesResponse, error) -} - -type storeService struct { - c client.Client - name string -} - -func NewStoreService(name string, c client.Client) StoreService { - return &storeService{ - c: c, - name: name, - } -} - -func (c *storeService) Read(ctx context.Context, in *ReadRequest, opts ...client.CallOption) (*ReadResponse, error) { - req := c.c.NewRequest(c.name, "Store.Read", in) - out := new(ReadResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *storeService) Write(ctx context.Context, in *WriteRequest, opts ...client.CallOption) (*WriteResponse, error) { - req := c.c.NewRequest(c.name, "Store.Write", in) - out := new(WriteResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *storeService) Delete(ctx context.Context, in *DeleteRequest, opts ...client.CallOption) (*DeleteResponse, error) { - req := c.c.NewRequest(c.name, "Store.Delete", in) - out := new(DeleteResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *storeService) List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (Store_ListService, error) { - req := c.c.NewRequest(c.name, "Store.List", &ListRequest{}) - stream, err := c.c.Stream(ctx, req, opts...) - if err != nil { - return nil, err - } - if err := stream.Send(in); err != nil { - return nil, err - } - return &storeServiceList{stream}, nil -} - -type Store_ListService interface { - Context() context.Context - SendMsg(interface{}) error - RecvMsg(interface{}) error - Close() error - Recv() (*ListResponse, error) -} - -type storeServiceList struct { - stream client.Stream -} - -func (x *storeServiceList) Close() error { - return x.stream.Close() -} - -func (x *storeServiceList) Context() context.Context { - return x.stream.Context() -} - -func (x *storeServiceList) SendMsg(m interface{}) error { - return x.stream.Send(m) -} - -func (x *storeServiceList) RecvMsg(m interface{}) error { - return x.stream.Recv(m) -} - -func (x *storeServiceList) Recv() (*ListResponse, error) { - m := new(ListResponse) - err := x.stream.Recv(m) - if err != nil { - return nil, err - } - return m, nil -} - -func (c *storeService) Databases(ctx context.Context, in *DatabasesRequest, opts ...client.CallOption) (*DatabasesResponse, error) { - req := c.c.NewRequest(c.name, "Store.Databases", in) - out := new(DatabasesResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *storeService) Tables(ctx context.Context, in *TablesRequest, opts ...client.CallOption) (*TablesResponse, error) { - req := c.c.NewRequest(c.name, "Store.Tables", in) - out := new(TablesResponse) - err := c.c.Call(ctx, req, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// Server API for Store service - -type StoreHandler interface { - Read(context.Context, *ReadRequest, *ReadResponse) error - Write(context.Context, *WriteRequest, *WriteResponse) error - Delete(context.Context, *DeleteRequest, *DeleteResponse) error - List(context.Context, *ListRequest, Store_ListStream) error - Databases(context.Context, *DatabasesRequest, *DatabasesResponse) error - Tables(context.Context, *TablesRequest, *TablesResponse) error -} - -func RegisterStoreHandler(s server.Server, hdlr StoreHandler, opts ...server.HandlerOption) error { - type store interface { - Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error - Write(ctx context.Context, in *WriteRequest, out *WriteResponse) error - Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error - List(ctx context.Context, stream server.Stream) error - Databases(ctx context.Context, in *DatabasesRequest, out *DatabasesResponse) error - Tables(ctx context.Context, in *TablesRequest, out *TablesResponse) error - } - type Store struct { - store - } - h := &storeHandler{hdlr} - return s.Handle(s.NewHandler(&Store{h}, opts...)) -} - -type storeHandler struct { - StoreHandler -} - -func (h *storeHandler) Read(ctx context.Context, in *ReadRequest, out *ReadResponse) error { - return h.StoreHandler.Read(ctx, in, out) -} - -func (h *storeHandler) Write(ctx context.Context, in *WriteRequest, out *WriteResponse) error { - return h.StoreHandler.Write(ctx, in, out) -} - -func (h *storeHandler) Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error { - return h.StoreHandler.Delete(ctx, in, out) -} - -func (h *storeHandler) List(ctx context.Context, stream server.Stream) error { - m := new(ListRequest) - if err := stream.Recv(m); err != nil { - return err - } - return h.StoreHandler.List(ctx, m, &storeListStream{stream}) -} - -type Store_ListStream interface { - Context() context.Context - SendMsg(interface{}) error - RecvMsg(interface{}) error - Close() error - Send(*ListResponse) error -} - -type storeListStream struct { - stream server.Stream -} - -func (x *storeListStream) Close() error { - return x.stream.Close() -} - -func (x *storeListStream) Context() context.Context { - return x.stream.Context() -} - -func (x *storeListStream) SendMsg(m interface{}) error { - return x.stream.Send(m) -} - -func (x *storeListStream) RecvMsg(m interface{}) error { - return x.stream.Recv(m) -} - -func (x *storeListStream) Send(m *ListResponse) error { - return x.stream.Send(m) -} - -func (h *storeHandler) Databases(ctx context.Context, in *DatabasesRequest, out *DatabasesResponse) error { - return h.StoreHandler.Databases(ctx, in, out) -} - -func (h *storeHandler) Tables(ctx context.Context, in *TablesRequest, out *TablesResponse) error { - return h.StoreHandler.Tables(ctx, in, out) -} diff --git a/store/service/proto/store.proto b/store/service/proto/store.proto deleted file mode 100644 index 80fbc40f..00000000 --- a/store/service/proto/store.proto +++ /dev/null @@ -1,109 +0,0 @@ -syntax = "proto3"; - -package go.micro.store; - -service Store { - rpc Read(ReadRequest) returns (ReadResponse) {}; - rpc Write(WriteRequest) returns (WriteResponse) {}; - rpc Delete(DeleteRequest) returns (DeleteResponse) {}; - rpc List(ListRequest) returns (stream ListResponse) {}; - rpc Databases(DatabasesRequest) returns (DatabasesResponse) {}; - rpc Tables(TablesRequest) returns (TablesResponse) {}; -} - -message Field { - // type of value e.g string, int, int64, bool, float64 - string type = 1; - // the actual value - string value = 2; -} - -message Record { - // key of the record - string key = 1; - // value in the record - bytes value = 2; - // time.Duration (signed int64 nanoseconds) - int64 expiry = 3; - // the associated metadata - map metadata = 4; -} - -message ReadOptions { - string database = 1; - string table = 2; - bool prefix = 3; - bool suffix = 4; - uint64 limit = 5; - uint64 offset = 6; -} - -message ReadRequest { - string key = 1; - ReadOptions options = 2; -} - -message ReadResponse { - repeated Record records = 1; -} - -message WriteOptions { - string database = 1; - string table = 2; - // time.Time - int64 expiry = 3; - // time.Duration - int64 ttl = 4; -} - -message WriteRequest { - Record record = 1; - WriteOptions options = 2; -} - -message WriteResponse {} - -message DeleteOptions { - string database = 1; - string table = 2; -} - -message DeleteRequest { - string key = 1; - DeleteOptions options = 2; -} - -message DeleteResponse {} - -message ListOptions { - string database = 1; - string table = 2; - string prefix = 3; - string suffix = 4; - uint64 limit = 5; - uint64 offset = 6; -} - - -message ListRequest { - ListOptions options = 1; -} - -message ListResponse { - reserved 1; //repeated Record records = 1; - repeated string keys = 2; -} - -message DatabasesRequest {} - -message DatabasesResponse { - repeated string databases = 1; -} - -message TablesRequest { - string database = 1; -} - -message TablesResponse { - repeated string tables = 1; -} diff --git a/store/service/service.go b/store/service/service.go deleted file mode 100644 index 94fb7dd3..00000000 --- a/store/service/service.go +++ /dev/null @@ -1,258 +0,0 @@ -// Package service implements the store service interface -package service - -import ( - "context" - "fmt" - "io" - "reflect" - "time" - - "github.com/micro/go-micro/v2/client" - "github.com/micro/go-micro/v2/errors" - "github.com/micro/go-micro/v2/metadata" - "github.com/micro/go-micro/v2/store" - pb "github.com/micro/go-micro/v2/store/service/proto" -) - -type serviceStore struct { - options store.Options - - // The database to use - Database string - - // The table to use - Table string - - // Addresses of the nodes - Nodes []string - - // store service client - Client pb.StoreService -} - -func (s *serviceStore) Close() error { - return nil -} - -func (s *serviceStore) Init(opts ...store.Option) error { - for _, o := range opts { - o(&s.options) - } - s.Database = s.options.Database - s.Table = s.options.Table - s.Nodes = s.options.Nodes - - return nil -} - -func (s *serviceStore) Context() context.Context { - ctx := context.Background() - md := make(metadata.Metadata) - if len(s.Database) > 0 { - md["Micro-Database"] = s.Database - } - - if len(s.Table) > 0 { - md["Micro-Table"] = s.Table - } - return metadata.NewContext(ctx, md) -} - -// Sync all the known records -func (s *serviceStore) List(opts ...store.ListOption) ([]string, error) { - options := store.ListOptions{ - Database: s.Database, - Table: s.Table, - } - - for _, o := range opts { - o(&options) - } - - listOpts := &pb.ListOptions{ - Database: options.Database, - Table: options.Table, - Prefix: options.Prefix, - Suffix: options.Suffix, - Limit: uint64(options.Limit), - Offset: uint64(options.Offset), - } - - stream, err := s.Client.List(s.Context(), &pb.ListRequest{Options: listOpts}, client.WithAddress(s.Nodes...)) - if err != nil && errors.Equal(err, errors.NotFound("", "")) { - return nil, store.ErrNotFound - } else if err != nil { - return nil, err - } - defer stream.Close() - - var keys []string - - for { - rsp, err := stream.Recv() - if err == io.EOF { - break - } - if err != nil { - return keys, err - } - - for _, key := range rsp.Keys { - keys = append(keys, key) - } - } - - return keys, nil -} - -// Read a record with key -func (s *serviceStore) Read(key string, opts ...store.ReadOption) ([]*store.Record, error) { - options := store.ReadOptions{ - Database: s.Database, - Table: s.Table, - } - - for _, o := range opts { - o(&options) - } - - readOpts := &pb.ReadOptions{ - Database: options.Database, - Table: options.Table, - Prefix: options.Prefix, - Suffix: options.Suffix, - Limit: uint64(options.Limit), - Offset: uint64(options.Offset), - } - - rsp, err := s.Client.Read(s.Context(), &pb.ReadRequest{ - Key: key, - Options: readOpts, - }, client.WithAddress(s.Nodes...)) - if err != nil && errors.Equal(err, errors.NotFound("", "")) { - return nil, store.ErrNotFound - } else if err != nil { - return nil, err - } - - records := make([]*store.Record, 0, len(rsp.Records)) - - for _, val := range rsp.Records { - metadata := make(map[string]interface{}) - - for k, v := range val.Metadata { - switch v.Type { - // TODO: parse all types - default: - metadata[k] = v - } - } - - records = append(records, &store.Record{ - Key: val.Key, - Value: val.Value, - Expiry: time.Duration(val.Expiry) * time.Second, - Metadata: metadata, - }) - } - - return records, nil -} - -// Write a record -func (s *serviceStore) Write(record *store.Record, opts ...store.WriteOption) error { - options := store.WriteOptions{ - Database: s.Database, - Table: s.Table, - } - - for _, o := range opts { - o(&options) - } - - writeOpts := &pb.WriteOptions{ - Database: options.Database, - Table: options.Table, - } - - metadata := make(map[string]*pb.Field) - - for k, v := range record.Metadata { - metadata[k] = &pb.Field{ - Type: reflect.TypeOf(v).String(), - Value: fmt.Sprintf("%v", v), - } - } - - _, err := s.Client.Write(s.Context(), &pb.WriteRequest{ - Record: &pb.Record{ - Key: record.Key, - Value: record.Value, - Expiry: int64(record.Expiry.Seconds()), - Metadata: metadata, - }, - Options: writeOpts}, client.WithAddress(s.Nodes...)) - if err != nil && errors.Equal(err, errors.NotFound("", "")) { - return store.ErrNotFound - } - - return err -} - -// Delete a record with key -func (s *serviceStore) Delete(key string, opts ...store.DeleteOption) error { - options := store.DeleteOptions{ - Database: s.Database, - Table: s.Table, - } - - for _, o := range opts { - o(&options) - } - - deleteOpts := &pb.DeleteOptions{ - Database: options.Database, - Table: options.Table, - } - - _, err := s.Client.Delete(s.Context(), &pb.DeleteRequest{ - Key: key, - Options: deleteOpts, - }, client.WithAddress(s.Nodes...)) - if err != nil && errors.Equal(err, errors.NotFound("", "")) { - return store.ErrNotFound - } - - return err -} - -func (s *serviceStore) String() string { - return "service" -} - -func (s *serviceStore) Options() store.Options { - return s.options -} - -// NewStore returns a new store service implementation -func NewStore(opts ...store.Option) store.Store { - var options store.Options - for _, o := range opts { - o(&options) - } - - if options.Client == nil { - options.Client = client.DefaultClient - } - - service := &serviceStore{ - options: options, - Database: options.Database, - Table: options.Table, - Nodes: options.Nodes, - Client: pb.NewStoreService("go.micro.store", options.Client), - } - - return service -}