diff --git a/cmds/app/cmd.go b/cmds/app/cmd.go index 2a2749b2..6ff12195 100644 --- a/cmds/app/cmd.go +++ b/cmds/app/cmd.go @@ -27,8 +27,6 @@ import ( "github.com/pubgo/lava/internal/middlewares/middleware_accesslog" "github.com/pubgo/lava/internal/middlewares/middleware_metric" "github.com/pubgo/lava/pkg/cmdutil" - "github.com/pubgo/lava/services/errorservice" - "github.com/pubgo/lava/services/metadataservice" _ "github.com/pubgo/lava/core/debug/debug" // debug @@ -65,9 +63,6 @@ var defaultProviders = []any{ lifecycle.New, scheduler.New, - - metadataservice.New, - errorservice.New, } func NewBuilder(opts ...dix.Option) *dix.Dix { diff --git a/cmds/protoc-gen-lava/internal/gen.go b/cmds/protoc-gen-lava/internal/gen.go index 0982c6e3..a439b9f2 100644 --- a/cmds/protoc-gen-lava/internal/gen.go +++ b/cmds/protoc-gen-lava/internal/gen.go @@ -2,19 +2,17 @@ package internal import ( "fmt" + "reflect" "strings" "github.com/dave/jennifer/jen" - "github.com/pubgo/funk/assert" + "github.com/pubgo/lava/core/rpcmeta" "github.com/pubgo/lava/pkg/proto/lavapbv1" "google.golang.org/protobuf/compiler/protogen" - "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" ) -const protoJsonNamePkg = "google.golang.org/protobuf/encoding/protojson" -const assertNamePkg = "github.com/pubgo/funk/assert" -const lavapbv1Pkg = "github.com/pubgo/lava/pkg/proto/lavapbv1" +var rpcMetaPkg = reflect.TypeOf(rpcmeta.RpcMeta{}).PkgPath() type rpcMetaInfo struct { srv *protogen.Service @@ -28,7 +26,7 @@ func GenerateFile(gen *protogen.Plugin, file *protogen.File) (g *protogen.Genera genFile := jen.NewFile(string(file.GoPackageName)) genFile.HeaderComment("Code generated by protoc-gen-lava. DO NOT EDIT.") genFile.HeaderComment("versions:") - genFile.HeaderComment(fmt.Sprintf(" - protoc-gen-lava %s", version)) + genFile.HeaderComment(fmt.Sprintf(" - protoc-gen-lava %s", Version)) genFile.HeaderComment(fmt.Sprintf(" - protoc %s", protocVersion(gen))) if file.Proto.GetOptions().GetDeprecated() { genFile.HeaderComment(fmt.Sprintf("%s is a deprecated file.", file.Desc.Path())) @@ -74,42 +72,30 @@ func GenerateFile(gen *protogen.Plugin, file *protogen.File) (g *protogen.Genera srvInfo := meta.srv keyPrefix := strings.ReplaceAll(srvInfo.GoName, "InnerService", "") keyPrefix = strings.ReplaceAll(keyPrefix, "Inner", "") + "Service" - keyName := fmt.Sprintf("%s%sAction", keyPrefix, meta.mth.GoName) - - //func() T{return T}() - genFile.Commentf("%s %s/%s", keyName, meta.srv.GoName, meta.mth.GoName) - genFile.Commentf(strings.TrimSpace(meta.mth.Comments.Leading.String())) - genFile.Var(). - Id(keyName). - Op("="). - Func().Params().Op("*").Qual(lavapbv1Pkg, "RpcMeta"). - BlockFunc( - func(group *jen.Group) { - group.Var().Id("p").Qual(lavapbv1Pkg, "RpcMeta") - group.Var().Id("data").Op("=").Id(fmt.Sprintf("`%s`", assert.Exit1(protojson.Marshal(meta.meta)))) - group.Qual(assertNamePkg, "Exit").Call( - jen.Qual(protoJsonNamePkg, "Unmarshal").Call( - jen.Op("[]").Byte().Call(jen.Id("data")), - jen.Id("&p"), - ), - ) - group.Return(jen.Id("&p")) + + var pbPkg = "" + if file.GoImportPath != meta.mth.Input.GoIdent.GoImportPath { + pbPkg = string(meta.mth.Input.GoIdent.GoImportPath) + } + + genFile.Var().Op("_").Op("=").Qual(rpcMetaPkg, "Register").Call( + jen.Op("&").Qual(rpcMetaPkg, "RpcMeta").Values( + jen.Dict{ + jen.Id("Input"): jen.New(jen.Qual(pbPkg, meta.mth.Input.GoIdent.GoName)), + jen.Id("Output"): jen.New(jen.Qual(pbPkg, meta.mth.Output.GoIdent.GoName)), + jen.Id("Name"): jen.Lit(meta.meta.Name), + jen.Id("Method"): jen.Lit(fmt.Sprintf("%s/%s", meta.srv.Desc.FullName(), meta.mth.GoName)), + jen.Id("Tags"): jen.Map(jen.String()).String().Values( + jen.DictFunc(func(dict jen.Dict) { + for k, v := range meta.meta.Tags { + dict[jen.Lit(k)] = jen.Lit(v) + } + }), + ), }, - ).Call() + )) } g.P(genFile.GoString()) return g } - -func protocVersion(gen *protogen.Plugin) string { - v := gen.Request.GetCompilerVersion() - if v == nil { - return "(unknown)" - } - var suffix string - if s := v.GetSuffix(); s != "" { - suffix = "-" + s - } - return fmt.Sprintf("v%d.%d.%d%s", v.GetMajor(), v.GetMinor(), v.GetPatch(), suffix) -} diff --git a/cmds/protoc-gen-lava/internal/version.go b/cmds/protoc-gen-lava/internal/version.go index 9be1654c..bd3d2e13 100644 --- a/cmds/protoc-gen-lava/internal/version.go +++ b/cmds/protoc-gen-lava/internal/version.go @@ -1,3 +1,21 @@ package internal -const version = "v0.0.1" +import ( + "fmt" + + "google.golang.org/protobuf/compiler/protogen" +) + +const Version = "v0.0.2" + +func protocVersion(gen *protogen.Plugin) string { + v := gen.Request.GetCompilerVersion() + if v == nil { + return "(unknown)" + } + var suffix string + if s := v.GetSuffix(); s != "" { + suffix = "-" + s + } + return fmt.Sprintf("v%d.%d.%d%s", v.GetMajor(), v.GetMinor(), v.GetPatch(), suffix) +} diff --git a/cmds/protoc-gen-lava/main.go b/cmds/protoc-gen-lava/main.go index ee9979d6..964990e6 100644 --- a/cmds/protoc-gen-lava/main.go +++ b/cmds/protoc-gen-lava/main.go @@ -2,12 +2,14 @@ package main import ( "flag" - + "github.com/pubgo/lava/cmds/protoc-gen-lava/internal" "google.golang.org/protobuf/compiler/protogen" "google.golang.org/protobuf/types/pluginpb" ) +var _ = flag.String("version", internal.Version, "version") + func main() { flag.Parse() diff --git a/core/rpcmeta/aaa.go b/core/rpcmeta/aaa.go new file mode 100644 index 00000000..0d616136 --- /dev/null +++ b/core/rpcmeta/aaa.go @@ -0,0 +1,11 @@ +package rpcmeta + +import "google.golang.org/protobuf/proto" + +type RpcMeta struct { + Method string + Name string + Tags map[string]string + Input proto.Message + Output proto.Message +} diff --git a/core/rpcmeta/registry.go b/core/rpcmeta/registry.go new file mode 100644 index 00000000..8f849b17 --- /dev/null +++ b/core/rpcmeta/registry.go @@ -0,0 +1,21 @@ +package rpcmeta + +import ( + "github.com/pubgo/funk/assert" +) + +var rpcMetas = make(map[string]*RpcMeta) + +func Register(meta *RpcMeta) error { + assert.If(meta == nil, "rpc meta is nil") + assert.If(meta.Name == "", "rpc meta name is empty") + assert.If(meta.Method == "", "rpc meta method is nil") + assert.If(rpcMetas[meta.Name] != nil, "rpc meta name already exists") + assert.If(rpcMetas[meta.Method] != nil, "rpc meta method already exists") + + rpcMetas[meta.Name] = meta + rpcMetas[meta.Method] = meta + return nil +} + +func Get(nameOrMethod string) *RpcMeta { return rpcMetas[nameOrMethod] } diff --git a/pkg/proto/errcodepb/api.pb.go b/pkg/proto/errcodepb/api.pb.go deleted file mode 100644 index b6209786..00000000 --- a/pkg/proto/errcodepb/api.pb.go +++ /dev/null @@ -1,150 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.35.1 -// protoc v5.28.2 -// source: lava/services/errcode/api.proto - -package errcodepb - -import ( - errorpb "github.com/pubgo/funk/proto/errorpb" - _ "google.golang.org/genproto/googleapis/api/annotations" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - emptypb "google.golang.org/protobuf/types/known/emptypb" - 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) -) - -type ErrCodes struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Codes []*errorpb.ErrCode `protobuf:"bytes,1,rep,name=codes,proto3" json:"codes,omitempty"` -} - -func (x *ErrCodes) Reset() { - *x = ErrCodes{} - mi := &file_lava_services_errcode_api_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ErrCodes) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ErrCodes) ProtoMessage() {} - -func (x *ErrCodes) ProtoReflect() protoreflect.Message { - mi := &file_lava_services_errcode_api_proto_msgTypes[0] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ErrCodes.ProtoReflect.Descriptor instead. -func (*ErrCodes) Descriptor() ([]byte, []int) { - return file_lava_services_errcode_api_proto_rawDescGZIP(), []int{0} -} - -func (x *ErrCodes) GetCodes() []*errorpb.ErrCode { - if x != nil { - return x.Codes - } - return nil -} - -var File_lava_services_errcode_api_proto protoreflect.FileDescriptor - -var file_lava_services_errcode_api_proto_rawDesc = []byte{ - 0x0a, 0x1f, 0x6c, 0x61, 0x76, 0x61, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, - 0x65, 0x72, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x12, 0x0c, 0x6c, 0x61, 0x76, 0x61, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x1a, - 0x14, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x70, 0x62, 0x2f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, - 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x22, 0x31, 0x0a, 0x08, 0x45, 0x72, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x25, 0x0a, 0x05, - 0x63, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x65, 0x72, - 0x72, 0x6f, 0x72, 0x73, 0x2e, 0x45, 0x72, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x05, 0x63, 0x6f, - 0x64, 0x65, 0x73, 0x32, 0x60, 0x0a, 0x0c, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x12, 0x50, 0x0a, 0x05, 0x43, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x16, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, - 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x6c, 0x61, 0x76, 0x61, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x2e, 0x45, 0x72, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x73, 0x22, 0x17, 0x82, 0xd3, - 0xe4, 0x93, 0x02, 0x11, 0x12, 0x0f, 0x2f, 0x6c, 0x61, 0x76, 0x61, 0x2f, 0x65, 0x72, 0x72, 0x5f, - 0x63, 0x6f, 0x64, 0x65, 0x73, 0x42, 0x35, 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x75, 0x62, 0x67, 0x6f, 0x2f, 0x6c, 0x61, 0x76, 0x61, 0x2f, 0x70, - 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x72, 0x72, 0x63, 0x6f, 0x64, 0x65, - 0x70, 0x62, 0x3b, 0x65, 0x72, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_lava_services_errcode_api_proto_rawDescOnce sync.Once - file_lava_services_errcode_api_proto_rawDescData = file_lava_services_errcode_api_proto_rawDesc -) - -func file_lava_services_errcode_api_proto_rawDescGZIP() []byte { - file_lava_services_errcode_api_proto_rawDescOnce.Do(func() { - file_lava_services_errcode_api_proto_rawDescData = protoimpl.X.CompressGZIP(file_lava_services_errcode_api_proto_rawDescData) - }) - return file_lava_services_errcode_api_proto_rawDescData -} - -var file_lava_services_errcode_api_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_lava_services_errcode_api_proto_goTypes = []any{ - (*ErrCodes)(nil), // 0: lava.service.ErrCodes - (*errorpb.ErrCode)(nil), // 1: errors.ErrCode - (*emptypb.Empty)(nil), // 2: google.protobuf.Empty -} -var file_lava_services_errcode_api_proto_depIdxs = []int32{ - 1, // 0: lava.service.ErrCodes.codes:type_name -> errors.ErrCode - 2, // 1: lava.service.ErrorService.Codes:input_type -> google.protobuf.Empty - 0, // 2: lava.service.ErrorService.Codes:output_type -> lava.service.ErrCodes - 2, // [2:3] is the sub-list for method output_type - 1, // [1:2] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name -} - -func init() { file_lava_services_errcode_api_proto_init() } -func file_lava_services_errcode_api_proto_init() { - if File_lava_services_errcode_api_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_lava_services_errcode_api_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_lava_services_errcode_api_proto_goTypes, - DependencyIndexes: file_lava_services_errcode_api_proto_depIdxs, - MessageInfos: file_lava_services_errcode_api_proto_msgTypes, - }.Build() - File_lava_services_errcode_api_proto = out.File - file_lava_services_errcode_api_proto_rawDesc = nil - file_lava_services_errcode_api_proto_goTypes = nil - file_lava_services_errcode_api_proto_depIdxs = nil -} diff --git a/pkg/proto/errcodepb/api_grpc.pb.go b/pkg/proto/errcodepb/api_grpc.pb.go deleted file mode 100644 index c02d538c..00000000 --- a/pkg/proto/errcodepb/api_grpc.pb.go +++ /dev/null @@ -1,120 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc v5.28.2 -// source: lava/services/errcode/api.proto - -package errcodepb - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - emptypb "google.golang.org/protobuf/types/known/emptypb" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - ErrorService_Codes_FullMethodName = "/lava.service.ErrorService/Codes" -) - -// ErrorServiceClient is the client API for ErrorService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type ErrorServiceClient interface { - Codes(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ErrCodes, error) -} - -type errorServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewErrorServiceClient(cc grpc.ClientConnInterface) ErrorServiceClient { - return &errorServiceClient{cc} -} - -func (c *errorServiceClient) Codes(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ErrCodes, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ErrCodes) - err := c.cc.Invoke(ctx, ErrorService_Codes_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// ErrorServiceServer is the server API for ErrorService service. -// All implementations should embed UnimplementedErrorServiceServer -// for forward compatibility. -type ErrorServiceServer interface { - Codes(context.Context, *emptypb.Empty) (*ErrCodes, error) -} - -// UnimplementedErrorServiceServer should be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedErrorServiceServer struct{} - -func (UnimplementedErrorServiceServer) Codes(context.Context, *emptypb.Empty) (*ErrCodes, error) { - return nil, status.Errorf(codes.Unimplemented, "method Codes not implemented") -} -func (UnimplementedErrorServiceServer) testEmbeddedByValue() {} - -// UnsafeErrorServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to ErrorServiceServer will -// result in compilation errors. -type UnsafeErrorServiceServer interface { - mustEmbedUnimplementedErrorServiceServer() -} - -func RegisterErrorServiceServer(s grpc.ServiceRegistrar, srv ErrorServiceServer) { - // If the following call pancis, it indicates UnimplementedErrorServiceServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&ErrorService_ServiceDesc, srv) -} - -func _ErrorService_Codes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(emptypb.Empty) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ErrorServiceServer).Codes(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: ErrorService_Codes_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ErrorServiceServer).Codes(ctx, req.(*emptypb.Empty)) - } - return interceptor(ctx, in, info, handler) -} - -// ErrorService_ServiceDesc is the grpc.ServiceDesc for ErrorService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var ErrorService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "lava.service.ErrorService", - HandlerType: (*ErrorServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Codes", - Handler: _ErrorService_Codes_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "lava/services/errcode/api.proto", -} diff --git a/pkg/proto/lavapbv1/event.pb.go b/pkg/proto/lavapbv1/event.pb.go index 453a0849..10b85773 100644 --- a/pkg/proto/lavapbv1/event.pb.go +++ b/pkg/proto/lavapbv1/event.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 +// protoc-gen-go v1.35.2 // protoc v5.28.2 // source: lava/event.proto diff --git a/pkg/proto/lavapbv1/form_file.pb.go b/pkg/proto/lavapbv1/form_file.pb.go index 31667f92..b4a3be47 100644 --- a/pkg/proto/lavapbv1/form_file.pb.go +++ b/pkg/proto/lavapbv1/form_file.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 +// protoc-gen-go v1.35.2 // protoc v5.28.2 // source: lava/form_file.proto diff --git a/pkg/proto/lavapbv1/rpc.pb.go b/pkg/proto/lavapbv1/rpc.pb.go index d978d028..a212f63d 100644 --- a/pkg/proto/lavapbv1/rpc.pb.go +++ b/pkg/proto/lavapbv1/rpc.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 +// protoc-gen-go v1.35.2 // protoc v5.28.2 // source: lava/rpc.proto @@ -32,6 +32,8 @@ type RpcMeta struct { Version *string `protobuf:"bytes,2,opt,name=version,proto3,oneof" json:"version,omitempty"` // rpc tags Tags map[string]string `protobuf:"bytes,3,rep,name=tags,proto3" json:"tags,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + // grpc method name + Method *string `protobuf:"bytes,4,opt,name=method,proto3,oneof" json:"method,omitempty"` } func (x *RpcMeta) Reset() { @@ -85,6 +87,13 @@ func (x *RpcMeta) GetTags() map[string]string { return nil } +func (x *RpcMeta) GetMethod() string { + if x != nil && x.Method != nil { + return *x.Method + } + return "" +} + var file_lava_rpc_proto_extTypes = []protoimpl.ExtensionInfo{ { ExtendedType: (*descriptorpb.MethodOptions)(nil), @@ -108,27 +117,30 @@ var file_lava_rpc_proto_rawDesc = []byte{ 0x0a, 0x0e, 0x6c, 0x61, 0x76, 0x61, 0x2f, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x6c, 0x61, 0x76, 0x61, 0x2e, 0x72, 0x70, 0x63, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, - 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb2, 0x01, 0x0a, + 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xda, 0x01, 0x0a, 0x07, 0x52, 0x70, 0x63, 0x4d, 0x65, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x88, 0x01, 0x01, 0x12, 0x2f, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6c, 0x61, 0x76, 0x61, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x70, 0x63, 0x4d, 0x65, 0x74, 0x61, 0x2e, 0x54, 0x61, 0x67, - 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x1a, 0x37, 0x0a, 0x09, - 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 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, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x3a, 0x4d, 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1e, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, - 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xa4, 0x8d, 0x06, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x6c, 0x61, 0x76, 0x61, 0x2e, 0x72, 0x70, 0x63, 0x2e, - 0x52, 0x70, 0x63, 0x4d, 0x65, 0x74, 0x61, 0x52, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x42, 0x33, 0x5a, 0x31, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, - 0x75, 0x62, 0x67, 0x6f, 0x2f, 0x6c, 0x61, 0x76, 0x61, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2f, 0x6c, 0x61, 0x76, 0x61, 0x70, 0x62, 0x76, 0x31, 0x3b, 0x6c, 0x61, 0x76, - 0x61, 0x70, 0x62, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x1b, 0x0a, 0x06, + 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x06, + 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x88, 0x01, 0x01, 0x1a, 0x37, 0x0a, 0x09, 0x54, 0x61, 0x67, + 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 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, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, + 0x38, 0x01, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x09, + 0x0a, 0x07, 0x5f, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x3a, 0x4d, 0x0a, 0x07, 0x6f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xa4, 0x8d, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x6c, + 0x61, 0x76, 0x61, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x70, 0x63, 0x4d, 0x65, 0x74, 0x61, 0x52, + 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x42, 0x33, 0x5a, 0x31, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x75, 0x62, 0x67, 0x6f, 0x2f, 0x6c, 0x61, 0x76, + 0x61, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6c, 0x61, 0x76, 0x61, + 0x70, 0x62, 0x76, 0x31, 0x3b, 0x6c, 0x61, 0x76, 0x61, 0x70, 0x62, 0x76, 0x31, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pkg/proto/lavapbv1/service.pb.go b/pkg/proto/lavapbv1/service.pb.go index b693059b..2cb6e83b 100644 --- a/pkg/proto/lavapbv1/service.pb.go +++ b/pkg/proto/lavapbv1/service.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 +// protoc-gen-go v1.35.2 // protoc v5.28.2 // source: lava/service.proto diff --git a/pkg/proto/metadatapb/metadata.pb.go b/pkg/proto/metadatapb/metadata.pb.go deleted file mode 100644 index 3c33bec7..00000000 --- a/pkg/proto/metadatapb/metadata.pb.go +++ /dev/null @@ -1,308 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.35.1 -// protoc v5.28.2 -// source: lava/services/metadata/metadata.proto - -package metadatapb - -import ( - _ "google.golang.org/genproto/googleapis/api/annotations" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - descriptorpb "google.golang.org/protobuf/types/descriptorpb" - 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) -) - -type ListServicesRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *ListServicesRequest) Reset() { - *x = ListServicesRequest{} - mi := &file_lava_services_metadata_metadata_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListServicesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListServicesRequest) ProtoMessage() {} - -func (x *ListServicesRequest) ProtoReflect() protoreflect.Message { - mi := &file_lava_services_metadata_metadata_proto_msgTypes[0] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListServicesRequest.ProtoReflect.Descriptor instead. -func (*ListServicesRequest) Descriptor() ([]byte, []int) { - return file_lava_services_metadata_metadata_proto_rawDescGZIP(), []int{0} -} - -type ListServicesReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Services []string `protobuf:"bytes,1,rep,name=services,proto3" json:"services,omitempty"` - Methods []string `protobuf:"bytes,2,rep,name=methods,proto3" json:"methods,omitempty"` -} - -func (x *ListServicesReply) Reset() { - *x = ListServicesReply{} - mi := &file_lava_services_metadata_metadata_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListServicesReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListServicesReply) ProtoMessage() {} - -func (x *ListServicesReply) ProtoReflect() protoreflect.Message { - mi := &file_lava_services_metadata_metadata_proto_msgTypes[1] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListServicesReply.ProtoReflect.Descriptor instead. -func (*ListServicesReply) Descriptor() ([]byte, []int) { - return file_lava_services_metadata_metadata_proto_rawDescGZIP(), []int{1} -} - -func (x *ListServicesReply) GetServices() []string { - if x != nil { - return x.Services - } - return nil -} - -func (x *ListServicesReply) GetMethods() []string { - if x != nil { - return x.Methods - } - return nil -} - -type GetServiceDescRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` -} - -func (x *GetServiceDescRequest) Reset() { - *x = GetServiceDescRequest{} - mi := &file_lava_services_metadata_metadata_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetServiceDescRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetServiceDescRequest) ProtoMessage() {} - -func (x *GetServiceDescRequest) ProtoReflect() protoreflect.Message { - mi := &file_lava_services_metadata_metadata_proto_msgTypes[2] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetServiceDescRequest.ProtoReflect.Descriptor instead. -func (*GetServiceDescRequest) Descriptor() ([]byte, []int) { - return file_lava_services_metadata_metadata_proto_rawDescGZIP(), []int{2} -} - -func (x *GetServiceDescRequest) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -type GetServiceDescReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - FileDescSet *descriptorpb.FileDescriptorSet `protobuf:"bytes,1,opt,name=file_desc_set,json=fileDescSet,proto3" json:"file_desc_set,omitempty"` -} - -func (x *GetServiceDescReply) Reset() { - *x = GetServiceDescReply{} - mi := &file_lava_services_metadata_metadata_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetServiceDescReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetServiceDescReply) ProtoMessage() {} - -func (x *GetServiceDescReply) ProtoReflect() protoreflect.Message { - mi := &file_lava_services_metadata_metadata_proto_msgTypes[3] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetServiceDescReply.ProtoReflect.Descriptor instead. -func (*GetServiceDescReply) Descriptor() ([]byte, []int) { - return file_lava_services_metadata_metadata_proto_rawDescGZIP(), []int{3} -} - -func (x *GetServiceDescReply) GetFileDescSet() *descriptorpb.FileDescriptorSet { - if x != nil { - return x.FileDescSet - } - return nil -} - -var File_lava_services_metadata_metadata_proto protoreflect.FileDescriptor - -var file_lava_services_metadata_metadata_proto_rawDesc = []byte{ - 0x0a, 0x25, 0x6c, 0x61, 0x76, 0x61, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, - 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, - 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, 0x6c, 0x61, 0x76, 0x61, 0x2e, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, - 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x15, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x49, 0x0a, 0x11, - 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x70, 0x6c, - 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x12, 0x18, 0x0a, - 0x07, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, - 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x22, 0x2b, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x65, 0x73, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x5d, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x44, 0x65, 0x73, 0x63, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x46, 0x0a, 0x0d, 0x66, - 0x69, 0x6c, 0x65, 0x5f, 0x64, 0x65, 0x73, 0x63, 0x5f, 0x73, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, - 0x74, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x52, 0x0b, 0x66, 0x69, 0x6c, 0x65, 0x44, 0x65, 0x73, 0x63, - 0x53, 0x65, 0x74, 0x32, 0x82, 0x02, 0x0a, 0x08, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0x12, 0x73, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x12, 0x21, 0x2e, 0x6c, 0x61, 0x76, 0x61, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, - 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x6c, 0x61, 0x76, 0x61, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x52, - 0x65, 0x70, 0x6c, 0x79, 0x22, 0x1f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x19, 0x12, 0x17, 0x2f, 0x6c, - 0x61, 0x76, 0x61, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x73, 0x12, 0x80, 0x01, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x44, 0x65, 0x73, 0x63, 0x12, 0x23, 0x2e, 0x6c, 0x61, 0x76, 0x61, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x44, 0x65, 0x73, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, - 0x6c, 0x61, 0x76, 0x61, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x47, 0x65, 0x74, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x65, 0x73, 0x63, 0x52, 0x65, 0x70, 0x6c, 0x79, - 0x22, 0x26, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x20, 0x12, 0x1e, 0x2f, 0x6c, 0x61, 0x76, 0x61, 0x2f, - 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x7d, 0x42, 0x37, 0x5a, 0x35, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x75, 0x62, 0x67, 0x6f, 0x2f, 0x6c, 0x61, 0x76, - 0x61, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6d, 0x65, 0x74, 0x61, - 0x64, 0x61, 0x74, 0x61, 0x70, 0x62, 0x3b, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x70, - 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_lava_services_metadata_metadata_proto_rawDescOnce sync.Once - file_lava_services_metadata_metadata_proto_rawDescData = file_lava_services_metadata_metadata_proto_rawDesc -) - -func file_lava_services_metadata_metadata_proto_rawDescGZIP() []byte { - file_lava_services_metadata_metadata_proto_rawDescOnce.Do(func() { - file_lava_services_metadata_metadata_proto_rawDescData = protoimpl.X.CompressGZIP(file_lava_services_metadata_metadata_proto_rawDescData) - }) - return file_lava_services_metadata_metadata_proto_rawDescData -} - -var file_lava_services_metadata_metadata_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_lava_services_metadata_metadata_proto_goTypes = []any{ - (*ListServicesRequest)(nil), // 0: lava.service.ListServicesRequest - (*ListServicesReply)(nil), // 1: lava.service.ListServicesReply - (*GetServiceDescRequest)(nil), // 2: lava.service.GetServiceDescRequest - (*GetServiceDescReply)(nil), // 3: lava.service.GetServiceDescReply - (*descriptorpb.FileDescriptorSet)(nil), // 4: google.protobuf.FileDescriptorSet -} -var file_lava_services_metadata_metadata_proto_depIdxs = []int32{ - 4, // 0: lava.service.GetServiceDescReply.file_desc_set:type_name -> google.protobuf.FileDescriptorSet - 0, // 1: lava.service.Metadata.ListServices:input_type -> lava.service.ListServicesRequest - 2, // 2: lava.service.Metadata.GetServiceDesc:input_type -> lava.service.GetServiceDescRequest - 1, // 3: lava.service.Metadata.ListServices:output_type -> lava.service.ListServicesReply - 3, // 4: lava.service.Metadata.GetServiceDesc:output_type -> lava.service.GetServiceDescReply - 3, // [3:5] is the sub-list for method output_type - 1, // [1:3] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name -} - -func init() { file_lava_services_metadata_metadata_proto_init() } -func file_lava_services_metadata_metadata_proto_init() { - if File_lava_services_metadata_metadata_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_lava_services_metadata_metadata_proto_rawDesc, - NumEnums: 0, - NumMessages: 4, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_lava_services_metadata_metadata_proto_goTypes, - DependencyIndexes: file_lava_services_metadata_metadata_proto_depIdxs, - MessageInfos: file_lava_services_metadata_metadata_proto_msgTypes, - }.Build() - File_lava_services_metadata_metadata_proto = out.File - file_lava_services_metadata_metadata_proto_rawDesc = nil - file_lava_services_metadata_metadata_proto_goTypes = nil - file_lava_services_metadata_metadata_proto_depIdxs = nil -} diff --git a/pkg/proto/metadatapb/metadata_grpc.pb.go b/pkg/proto/metadatapb/metadata_grpc.pb.go deleted file mode 100644 index e3cdea4d..00000000 --- a/pkg/proto/metadatapb/metadata_grpc.pb.go +++ /dev/null @@ -1,165 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc v5.28.2 -// source: lava/services/metadata/metadata.proto - -package metadatapb - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - Metadata_ListServices_FullMethodName = "/lava.service.Metadata/ListServices" - Metadata_GetServiceDesc_FullMethodName = "/lava.service.Metadata/GetServiceDesc" -) - -// MetadataClient is the client API for Metadata service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -// -// Metadata is api definition metadata service. -type MetadataClient interface { - // ListServices list the full name of all services. - ListServices(ctx context.Context, in *ListServicesRequest, opts ...grpc.CallOption) (*ListServicesReply, error) - // GetServiceDesc get the full fileDescriptorSet of service. - GetServiceDesc(ctx context.Context, in *GetServiceDescRequest, opts ...grpc.CallOption) (*GetServiceDescReply, error) -} - -type metadataClient struct { - cc grpc.ClientConnInterface -} - -func NewMetadataClient(cc grpc.ClientConnInterface) MetadataClient { - return &metadataClient{cc} -} - -func (c *metadataClient) ListServices(ctx context.Context, in *ListServicesRequest, opts ...grpc.CallOption) (*ListServicesReply, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ListServicesReply) - err := c.cc.Invoke(ctx, Metadata_ListServices_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *metadataClient) GetServiceDesc(ctx context.Context, in *GetServiceDescRequest, opts ...grpc.CallOption) (*GetServiceDescReply, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(GetServiceDescReply) - err := c.cc.Invoke(ctx, Metadata_GetServiceDesc_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// MetadataServer is the server API for Metadata service. -// All implementations should embed UnimplementedMetadataServer -// for forward compatibility. -// -// Metadata is api definition metadata service. -type MetadataServer interface { - // ListServices list the full name of all services. - ListServices(context.Context, *ListServicesRequest) (*ListServicesReply, error) - // GetServiceDesc get the full fileDescriptorSet of service. - GetServiceDesc(context.Context, *GetServiceDescRequest) (*GetServiceDescReply, error) -} - -// UnimplementedMetadataServer should be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedMetadataServer struct{} - -func (UnimplementedMetadataServer) ListServices(context.Context, *ListServicesRequest) (*ListServicesReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListServices not implemented") -} -func (UnimplementedMetadataServer) GetServiceDesc(context.Context, *GetServiceDescRequest) (*GetServiceDescReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetServiceDesc not implemented") -} -func (UnimplementedMetadataServer) testEmbeddedByValue() {} - -// UnsafeMetadataServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to MetadataServer will -// result in compilation errors. -type UnsafeMetadataServer interface { - mustEmbedUnimplementedMetadataServer() -} - -func RegisterMetadataServer(s grpc.ServiceRegistrar, srv MetadataServer) { - // If the following call pancis, it indicates UnimplementedMetadataServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&Metadata_ServiceDesc, srv) -} - -func _Metadata_ListServices_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListServicesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MetadataServer).ListServices(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Metadata_ListServices_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MetadataServer).ListServices(ctx, req.(*ListServicesRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Metadata_GetServiceDesc_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetServiceDescRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MetadataServer).GetServiceDesc(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Metadata_GetServiceDesc_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MetadataServer).GetServiceDesc(ctx, req.(*GetServiceDescRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// Metadata_ServiceDesc is the grpc.ServiceDesc for Metadata service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Metadata_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "lava.service.Metadata", - HandlerType: (*MetadataServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "ListServices", - Handler: _Metadata_ListServices_Handler, - }, - { - MethodName: "GetServiceDesc", - Handler: _Metadata_GetServiceDesc_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "lava/services/metadata/metadata.proto", -} diff --git a/proto/lava/rpc.proto b/proto/lava/rpc.proto index 17f869e1..ddf43723 100644 --- a/proto/lava/rpc.proto +++ b/proto/lava/rpc.proto @@ -17,4 +17,6 @@ message RpcMeta { map tags = 3; } -extend google.protobuf.MethodOptions { RpcMeta options = 100004; } +extend google.protobuf.MethodOptions { + RpcMeta options = 100004; +} diff --git a/proto/lava/services/errcode/api.proto b/proto/lava/services/errcode/api.proto deleted file mode 100644 index c4f148b0..00000000 --- a/proto/lava/services/errcode/api.proto +++ /dev/null @@ -1,21 +0,0 @@ -syntax = "proto3"; - -package lava.service; - -import "errorpb/errors.proto"; -import "google/api/annotations.proto"; -import "google/protobuf/empty.proto"; - -option go_package = "github.com/pubgo/lava/pkg/proto/errcodepb;errcodepb"; - -service ErrorService { - rpc Codes (google.protobuf.Empty) returns (ErrCodes) { - option (google.api.http) = { - get: "/lava/err_codes" - }; - } -} - -message ErrCodes { - repeated errors.ErrCode codes = 1; -} \ No newline at end of file diff --git a/proto/lava/services/metadata/metadata.proto b/proto/lava/services/metadata/metadata.proto deleted file mode 100644 index 31b35f26..00000000 --- a/proto/lava/services/metadata/metadata.proto +++ /dev/null @@ -1,39 +0,0 @@ -syntax = "proto3"; - -package lava.service; - -import "google/api/annotations.proto"; -import "google/protobuf/descriptor.proto"; - -option go_package = "github.com/pubgo/lava/pkg/proto/metadatapb;metadatapb"; - -// Metadata is api definition metadata service. -service Metadata { - // ListServices list the full name of all services. - rpc ListServices (ListServicesRequest) returns (ListServicesReply) { - option (google.api.http) = { - get: "/lava/metadata/services", - }; - } - - // GetServiceDesc get the full fileDescriptorSet of service. - rpc GetServiceDesc (GetServiceDescRequest) returns (GetServiceDescReply) { - option (google.api.http) = { - get: "/lava/metadata/services/{name}", - }; - } -} - -message ListServicesRequest {} -message ListServicesReply { - repeated string services = 1; - repeated string methods = 2; -} - -message GetServiceDescRequest { - string name = 1; -} - -message GetServiceDescReply { - google.protobuf.FileDescriptorSet file_desc_set = 1; -} diff --git a/protobuf.yaml b/protobuf.yaml index 43065d23..53ecf632 100644 --- a/protobuf.yaml +++ b/protobuf.yaml @@ -1,4 +1,4 @@ -checksum: e0510f214c57f40c401509269c3bd12647e77233 +checksum: 2cb52bc4143a48e6062590082a7310ff425eff96 vendor: .proto base: out: ./pkg diff --git a/services/errorservice/service.go b/services/errorservice/service.go deleted file mode 100644 index cd5cd095..00000000 --- a/services/errorservice/service.go +++ /dev/null @@ -1,31 +0,0 @@ -package errorservice - -import ( - "context" - - "github.com/pubgo/funk/errors" - "github.com/pubgo/lava/lava" - "github.com/pubgo/lava/pkg/proto/errcodepb" - "google.golang.org/grpc" - "google.golang.org/protobuf/types/known/emptypb" -) - -func New() lava.GrpcRouter { - return new(service) -} - -type service struct{} - -func (s service) Codes(ctx context.Context, empty *emptypb.Empty) (*errcodepb.ErrCodes, error) { - return &errcodepb.ErrCodes{ - Codes: errors.GetErrCodes(), - }, nil -} - -func (s service) Middlewares() []lava.Middleware { - return nil -} - -func (s service) ServiceDesc() *grpc.ServiceDesc { - return &errcodepb.ErrorService_ServiceDesc -} diff --git a/services/metadataservice/service.go b/services/metadataservice/service.go deleted file mode 100644 index c4f714e1..00000000 --- a/services/metadataservice/service.go +++ /dev/null @@ -1,240 +0,0 @@ -package metadataservice - -import ( - "bytes" - "compress/gzip" - "context" - "errors" - "fmt" - "io" - "sort" - "sync" - - "github.com/pubgo/funk/log" - "github.com/pubgo/lava/lava" - "github.com/pubgo/lava/pkg/proto/metadatapb" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/reflect/protodesc" - "google.golang.org/protobuf/reflect/protoreflect" - "google.golang.org/protobuf/reflect/protoregistry" - dpb "google.golang.org/protobuf/types/descriptorpb" -) - -func New() lava.GrpcRouter { - srv := NewService(nil) - return srv -} - -func NewService(srv *grpc.Server) *Server { - return &Server{ - srv: srv, - services: make(map[string]*dpb.FileDescriptorSet), - methods: make(map[string][]string), - } -} - -var _ metadatapb.MetadataServer = (*Server)(nil) - -// Server is api meta server -type Server struct { - srv *grpc.Server - lock sync.Mutex - services map[string]*dpb.FileDescriptorSet - methods map[string][]string -} - -func (s *Server) Middlewares() []lava.Middleware { - return nil -} - -func (s *Server) ServiceDesc() *grpc.ServiceDesc { - return &metadatapb.Metadata_ServiceDesc -} - -func (s *Server) load() error { - if len(s.services) > 0 { - return nil - } - - if s.srv != nil { - for name, info := range s.srv.GetServiceInfo() { - fd, err := parseMetadata(info.Metadata) - if err != nil { - return fmt.Errorf("invalid service %s metadata err:%v", name, err) - } - protoSet, err := allDependency(fd) - if err != nil { - return err - } - s.services[name] = &dpb.FileDescriptorSet{File: protoSet} - for _, method := range info.Methods { - s.methods[name] = append(s.methods[name], method.Name) - } - } - return nil - } - - var err error - protoregistry.GlobalFiles.RangeFiles(func(fd protoreflect.FileDescriptor) bool { - if fd.Services() == nil { - return true - } - for i := 0; i < fd.Services().Len(); i++ { - svc := fd.Services().Get(i) - fdp, e := fileDescriptorProto(fd.Path()) - if e != nil { - err = e - return false - } - - fdps, e := allDependency(fdp) - if e != nil { - if errors.Is(e, protoregistry.NotFound) { - // Skip this service if one of its dependencies is not found. - continue - } - err = e - return false - } - - s.services[string(svc.FullName())] = &dpb.FileDescriptorSet{File: fdps} - if svc.Methods() == nil { - continue - } - - for j := 0; j < svc.Methods().Len(); j++ { - method := svc.Methods().Get(j) - s.methods[string(svc.FullName())] = append(s.methods[string(svc.FullName())], string(method.Name())) - } - } - return true - }) - return err -} - -// ListServices return all services -func (s *Server) ListServices(_ context.Context, _ *metadatapb.ListServicesRequest) (*metadatapb.ListServicesReply, error) { - s.lock.Lock() - defer s.lock.Unlock() - if err := s.load(); err != nil { - return nil, err - } - - reply := &metadatapb.ListServicesReply{ - Services: make([]string, 0, len(s.services)), - Methods: make([]string, 0, len(s.methods)), - } - - for name := range s.services { - reply.Services = append(reply.Services, name) - } - - for name, methods := range s.methods { - for _, method := range methods { - reply.Methods = append(reply.Methods, fmt.Sprintf("/%s/%s", name, method)) - } - } - - sort.Strings(reply.Services) - sort.Strings(reply.Methods) - return reply, nil -} - -// GetServiceDesc return service meta by name -func (s *Server) GetServiceDesc(_ context.Context, in *metadatapb.GetServiceDescRequest) (*metadatapb.GetServiceDescReply, error) { - s.lock.Lock() - defer s.lock.Unlock() - if err := s.load(); err != nil { - return nil, err - } - - fds, ok := s.services[in.Name] - if !ok { - return nil, status.Errorf(codes.NotFound, "service %s not found", in.Name) - } - - return &metadatapb.GetServiceDescReply{FileDescSet: fds}, nil -} - -// parseMetadata finds the file descriptor bytes specified meta. -// For SupportPackageIsVersion4, m is the name of the proto file, we -// call proto.FileDescriptor to get the byte slice. -// For SupportPackageIsVersion3, m is a byte slice itself. -func parseMetadata(meta interface{}) (*dpb.FileDescriptorProto, error) { - // Check if meta is the file name. - if fileNameForMeta, ok := meta.(string); ok { - return fileDescriptorProto(fileNameForMeta) - } - - // Check if meta is the byte slice. - if enc, ok := meta.([]byte); ok { - return decodeFileDesc(enc) - } - - return nil, fmt.Errorf("proto not sumpport metadata: %v", meta) -} - -// decodeFileDesc does decompression and unmarshalling on the given -// file descriptor byte slice. -func decodeFileDesc(enc []byte) (*dpb.FileDescriptorProto, error) { - raw, err := decompress(enc) - if err != nil { - return nil, fmt.Errorf("failed to decompress enc: %v", err) - } - - fd := new(dpb.FileDescriptorProto) - if err := proto.Unmarshal(raw, fd); err != nil { - return nil, fmt.Errorf("bad descriptor: %v", err) - } - - return fd, nil -} - -func allDependency(fd *dpb.FileDescriptorProto) ([]*dpb.FileDescriptorProto, error) { - var files []*dpb.FileDescriptorProto - for _, dep := range fd.Dependency { - fdDep, err := fileDescriptorProto(dep) - if err != nil { - log.Warn().Err(err).Msg(err.Error()) - continue - } - - temp, err := allDependency(fdDep) - if err != nil { - return nil, err - } - - files = append(files, temp...) - } - - files = append(files, fd) - return files, nil -} - -// decompress does gzip decompression. -func decompress(b []byte) ([]byte, error) { - r, err := gzip.NewReader(bytes.NewReader(b)) - if err != nil { - return nil, fmt.Errorf("bad gzipped descriptor: %v", err) - } - - out, err := io.ReadAll(r) - if err != nil { - return nil, fmt.Errorf("bad gzipped descriptor: %v", err) - } - - return out, nil -} - -func fileDescriptorProto(path string) (*dpb.FileDescriptorProto, error) { - fd, err := protoregistry.GlobalFiles.FindFileByPath(path) - if err != nil { - return nil, fmt.Errorf("find proto by path failed, path: %s, err: %s", path, err) - } - - fdpb := protodesc.ToFileDescriptorProto(fd) - return fdpb, nil -}