diff --git a/pkg/internal/grpc/stream.go b/pkg/internal/grpc/stream.go index 11d09ee..717a33f 100644 --- a/pkg/internal/grpc/stream.go +++ b/pkg/internal/grpc/stream.go @@ -3,6 +3,7 @@ package grpc import ( "context" "fmt" + "git.solsynth.dev/hypernet/nexus/pkg/internal/http/ws" "github.com/rs/zerolog/log" @@ -19,16 +20,17 @@ func (v *Server) CountStreamConnection(ctx context.Context, request *proto.Count func (v *Server) PushStream(ctx context.Context, request *proto.PushStreamRequest) (*proto.PushStreamResponse, error) { var cnt int - var success int + var successes []uint64 var errs []error if request.UserId != nil { - cnt, success, errs = ws.WebsocketPush(uint(request.GetUserId()), request.GetBody()) + cnt, successes, errs = ws.WebsocketPush(uint(request.GetUserId()), request.GetBody()) } else if request.ClientId != nil { - cnt, success, errs = ws.WebsocketPushDirect(request.GetClientId(), request.GetBody()) + cnt, successes, errs = ws.WebsocketPushDirect(request.GetClientId(), request.GetBody()) } else { return nil, fmt.Errorf("you must give one of the user id or client id") } + success := len(successes) log.Debug(). Uint64("client_id", request.GetClientId()). Uint64("user_id", request.GetUserId()). @@ -43,6 +45,7 @@ func (v *Server) PushStream(ctx context.Context, request *proto.PushStreamReques IsAllSuccess: false, AffectedCount: int64(success), FailedCount: int64(cnt - success), + SuccessList: successes, }, nil } else if cnt > 0 && success == 0 { // All fail @@ -58,10 +61,10 @@ func (v *Server) PushStream(ctx context.Context, request *proto.PushStreamReques func (v *Server) PushStreamBatch(ctx context.Context, request *proto.PushStreamBatchRequest) (*proto.PushStreamResponse, error) { var cnt int - var success int + var successes []uint64 var errs []error if len(request.UserId) != 0 { - cnt, success, errs = ws.WebsocketPushBatch( + cnt, successes, errs = ws.WebsocketPushBatch( lo.Map(request.GetUserId(), func(item uint64, idx int) uint { return uint(item) }, @@ -71,10 +74,11 @@ func (v *Server) PushStreamBatch(ctx context.Context, request *proto.PushStreamB if len(request.ClientId) != 0 { cCnt, cSuccess, cErrs := ws.WebsocketPushBatchDirect(request.GetClientId(), request.GetBody()) cnt += cCnt - success += cSuccess + successes = append(successes, cSuccess...) errs = append(errs, cErrs...) } + success := len(successes) log.Debug(). Any("client_id", request.GetClientId()). Any("user_id", request.GetUserId()). @@ -99,5 +103,6 @@ func (v *Server) PushStreamBatch(ctx context.Context, request *proto.PushStreamB IsAllSuccess: true, AffectedCount: int64(success), FailedCount: int64(cnt - success), + SuccessList: successes, }, nil } diff --git a/pkg/internal/http/ws/connections.go b/pkg/internal/http/ws/connections.go index 3985d64..91bf9a7 100644 --- a/pkg/internal/http/ws/connections.go +++ b/pkg/internal/http/ws/connections.go @@ -1,11 +1,12 @@ package ws import ( + "math/rand" + "sync" + "git.solsynth.dev/hypernet/nexus/pkg/internal/directory" "git.solsynth.dev/hypernet/nexus/pkg/nex/sec" "github.com/rs/zerolog/log" - "math/rand" - "sync" "github.com/gofiber/contrib/websocket" ) @@ -60,25 +61,25 @@ func ClientCount(uid uint) int { return len(wsConn[uid]) } -func WebsocketPush(uid uint, body []byte) (count int, success int, errs []error) { +func WebsocketPush(uid uint, body []byte) (count int, successes []uint64, errs []error) { for _, conn := range wsConn[uid] { if err := conn.WriteMessage(1, body); err != nil { errs = append(errs, err) } else { - success++ + successes = append(successes, uint64(uid)) } count++ } return } -func WebsocketPushDirect(clientId uint64, body []byte) (count int, success int, errs []error) { +func WebsocketPushDirect(clientId uint64, body []byte) (count int, successes []uint64, errs []error) { for _, m := range wsConn { if conn, ok := m[clientId]; ok { if err := conn.WriteMessage(1, body); err != nil { errs = append(errs, err) } else { - success++ + successes = append(successes, clientId) } count++ } @@ -86,13 +87,13 @@ func WebsocketPushDirect(clientId uint64, body []byte) (count int, success int, return } -func WebsocketPushBatch(uidList []uint, body []byte) (count int, success int, errs []error) { +func WebsocketPushBatch(uidList []uint, body []byte) (count int, successes []uint64, errs []error) { for _, uid := range uidList { for _, conn := range wsConn[uid] { if err := conn.WriteMessage(1, body); err != nil { errs = append(errs, err) } else { - success++ + successes = append(successes, uint64(uid)) } count++ } @@ -100,14 +101,14 @@ func WebsocketPushBatch(uidList []uint, body []byte) (count int, success int, er return } -func WebsocketPushBatchDirect(clientIdList []uint64, body []byte) (count int, success int, errs []error) { +func WebsocketPushBatchDirect(clientIdList []uint64, body []byte) (count int, successes []uint64, errs []error) { for _, clientId := range clientIdList { for _, m := range wsConn { if conn, ok := m[clientId]; ok { if err := conn.WriteMessage(1, body); err != nil { errs = append(errs, err) } else { - success++ + successes = append(successes, clientId) } count++ } diff --git a/pkg/proto/allocator.pb.go b/pkg/proto/allocator.pb.go index 9ece4b2..4479234 100644 --- a/pkg/proto/allocator.pb.go +++ b/pkg/proto/allocator.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v5.28.2 +// protoc-gen-go v1.35.1 +// protoc v5.28.3 // source: allocator.proto package proto @@ -28,11 +28,9 @@ type AllocMqRequest struct { func (x *AllocMqRequest) Reset() { *x = AllocMqRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_allocator_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_allocator_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AllocMqRequest) String() string { @@ -43,7 +41,7 @@ func (*AllocMqRequest) ProtoMessage() {} func (x *AllocMqRequest) ProtoReflect() protoreflect.Message { mi := &file_allocator_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -69,11 +67,9 @@ type AllocMqResponse struct { func (x *AllocMqResponse) Reset() { *x = AllocMqResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_allocator_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_allocator_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AllocMqResponse) String() string { @@ -84,7 +80,7 @@ func (*AllocMqResponse) ProtoMessage() {} func (x *AllocMqResponse) ProtoReflect() protoreflect.Message { mi := &file_allocator_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -121,11 +117,9 @@ type AllocKvRequest struct { func (x *AllocKvRequest) Reset() { *x = AllocKvRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_allocator_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_allocator_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AllocKvRequest) String() string { @@ -136,7 +130,7 @@ func (*AllocKvRequest) ProtoMessage() {} func (x *AllocKvRequest) ProtoReflect() protoreflect.Message { mi := &file_allocator_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -162,11 +156,9 @@ type AllocKvResponse struct { func (x *AllocKvResponse) Reset() { *x = AllocKvResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_allocator_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_allocator_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AllocKvResponse) String() string { @@ -177,7 +169,7 @@ func (*AllocKvResponse) ProtoMessage() {} func (x *AllocKvResponse) ProtoReflect() protoreflect.Message { mi := &file_allocator_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -248,7 +240,7 @@ func file_allocator_proto_rawDescGZIP() []byte { } var file_allocator_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_allocator_proto_goTypes = []interface{}{ +var file_allocator_proto_goTypes = []any{ (*AllocMqRequest)(nil), // 0: proto.AllocMqRequest (*AllocMqResponse)(nil), // 1: proto.AllocMqResponse (*AllocKvRequest)(nil), // 2: proto.AllocKvRequest @@ -271,56 +263,6 @@ func file_allocator_proto_init() { if File_allocator_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_allocator_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AllocMqRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_allocator_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AllocMqResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_allocator_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AllocKvRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_allocator_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AllocKvResponse); 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{ diff --git a/pkg/proto/allocator_grpc.pb.go b/pkg/proto/allocator_grpc.pb.go index b06fa2b..5eee932 100644 --- a/pkg/proto/allocator_grpc.pb.go +++ b/pkg/proto/allocator_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v5.28.2 +// - protoc-gen-go-grpc v1.5.1 +// - protoc v5.28.3 // source: allocator.proto package proto @@ -15,8 +15,13 @@ import ( // 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.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + AllocatorService_AllocMessageQueue_FullMethodName = "/proto.AllocatorService/AllocMessageQueue" + AllocatorService_AllocKv_FullMethodName = "/proto.AllocatorService/AllocKv" +) // AllocatorServiceClient is the client API for AllocatorService service. // @@ -35,8 +40,9 @@ func NewAllocatorServiceClient(cc grpc.ClientConnInterface) AllocatorServiceClie } func (c *allocatorServiceClient) AllocMessageQueue(ctx context.Context, in *AllocMqRequest, opts ...grpc.CallOption) (*AllocMqResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(AllocMqResponse) - err := c.cc.Invoke(ctx, "/proto.AllocatorService/AllocMessageQueue", in, out, opts...) + err := c.cc.Invoke(ctx, AllocatorService_AllocMessageQueue_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -44,8 +50,9 @@ func (c *allocatorServiceClient) AllocMessageQueue(ctx context.Context, in *Allo } func (c *allocatorServiceClient) AllocKv(ctx context.Context, in *AllocKvRequest, opts ...grpc.CallOption) (*AllocKvResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(AllocKvResponse) - err := c.cc.Invoke(ctx, "/proto.AllocatorService/AllocKv", in, out, opts...) + err := c.cc.Invoke(ctx, AllocatorService_AllocKv_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -54,16 +61,19 @@ func (c *allocatorServiceClient) AllocKv(ctx context.Context, in *AllocKvRequest // AllocatorServiceServer is the server API for AllocatorService service. // All implementations must embed UnimplementedAllocatorServiceServer -// for forward compatibility +// for forward compatibility. type AllocatorServiceServer interface { AllocMessageQueue(context.Context, *AllocMqRequest) (*AllocMqResponse, error) AllocKv(context.Context, *AllocKvRequest) (*AllocKvResponse, error) mustEmbedUnimplementedAllocatorServiceServer() } -// UnimplementedAllocatorServiceServer must be embedded to have forward compatible implementations. -type UnimplementedAllocatorServiceServer struct { -} +// UnimplementedAllocatorServiceServer must 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 UnimplementedAllocatorServiceServer struct{} func (UnimplementedAllocatorServiceServer) AllocMessageQueue(context.Context, *AllocMqRequest) (*AllocMqResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AllocMessageQueue not implemented") @@ -72,6 +82,7 @@ func (UnimplementedAllocatorServiceServer) AllocKv(context.Context, *AllocKvRequ return nil, status.Errorf(codes.Unimplemented, "method AllocKv not implemented") } func (UnimplementedAllocatorServiceServer) mustEmbedUnimplementedAllocatorServiceServer() {} +func (UnimplementedAllocatorServiceServer) testEmbeddedByValue() {} // UnsafeAllocatorServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to AllocatorServiceServer will @@ -81,6 +92,13 @@ type UnsafeAllocatorServiceServer interface { } func RegisterAllocatorServiceServer(s grpc.ServiceRegistrar, srv AllocatorServiceServer) { + // If the following call pancis, it indicates UnimplementedAllocatorServiceServer 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(&AllocatorService_ServiceDesc, srv) } @@ -94,7 +112,7 @@ func _AllocatorService_AllocMessageQueue_Handler(srv interface{}, ctx context.Co } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/proto.AllocatorService/AllocMessageQueue", + FullMethod: AllocatorService_AllocMessageQueue_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(AllocatorServiceServer).AllocMessageQueue(ctx, req.(*AllocMqRequest)) @@ -112,7 +130,7 @@ func _AllocatorService_AllocKv_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/proto.AllocatorService/AllocKv", + FullMethod: AllocatorService_AllocKv_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(AllocatorServiceServer).AllocKv(ctx, req.(*AllocKvRequest)) diff --git a/pkg/proto/authenticate.pb.go b/pkg/proto/authenticate.pb.go index b819963..9e55a46 100644 --- a/pkg/proto/authenticate.pb.go +++ b/pkg/proto/authenticate.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v5.28.2 +// protoc-gen-go v1.35.1 +// protoc v5.28.3 // source: authenticate.proto package proto @@ -31,11 +31,9 @@ type AuthInfo struct { func (x *AuthInfo) Reset() { *x = AuthInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_authenticate_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_authenticate_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AuthInfo) String() string { @@ -46,7 +44,7 @@ func (*AuthInfo) ProtoMessage() {} func (x *AuthInfo) ProtoReflect() protoreflect.Message { mi := &file_authenticate_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -85,11 +83,9 @@ type AuthRequest struct { func (x *AuthRequest) Reset() { *x = AuthRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_authenticate_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_authenticate_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AuthRequest) String() string { @@ -100,7 +96,7 @@ func (*AuthRequest) ProtoMessage() {} func (x *AuthRequest) ProtoReflect() protoreflect.Message { mi := &file_authenticate_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -133,11 +129,9 @@ type AuthReply struct { func (x *AuthReply) Reset() { *x = AuthReply{} - if protoimpl.UnsafeEnabled { - mi := &file_authenticate_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_authenticate_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AuthReply) String() string { @@ -148,7 +142,7 @@ func (*AuthReply) ProtoMessage() {} func (x *AuthReply) ProtoReflect() protoreflect.Message { mi := &file_authenticate_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -189,11 +183,9 @@ type CheckPermRequest struct { func (x *CheckPermRequest) Reset() { *x = CheckPermRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_authenticate_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_authenticate_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *CheckPermRequest) String() string { @@ -204,7 +196,7 @@ func (*CheckPermRequest) ProtoMessage() {} func (x *CheckPermRequest) ProtoReflect() protoreflect.Message { mi := &file_authenticate_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -250,11 +242,9 @@ type CheckPermResponse struct { func (x *CheckPermResponse) Reset() { *x = CheckPermResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_authenticate_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_authenticate_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *CheckPermResponse) String() string { @@ -265,7 +255,7 @@ func (*CheckPermResponse) ProtoMessage() {} func (x *CheckPermResponse) ProtoReflect() protoreflect.Message { mi := &file_authenticate_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -300,11 +290,9 @@ type CheckUserPermRequest struct { func (x *CheckUserPermRequest) Reset() { *x = CheckUserPermRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_authenticate_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_authenticate_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *CheckUserPermRequest) String() string { @@ -315,7 +303,7 @@ func (*CheckUserPermRequest) ProtoMessage() {} func (x *CheckUserPermRequest) ProtoReflect() protoreflect.Message { mi := &file_authenticate_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -368,11 +356,9 @@ type CheckUserPermResponse struct { func (x *CheckUserPermResponse) Reset() { *x = CheckUserPermResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_authenticate_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_authenticate_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *CheckUserPermResponse) String() string { @@ -383,7 +369,7 @@ func (*CheckUserPermResponse) ProtoMessage() {} func (x *CheckUserPermResponse) ProtoReflect() protoreflect.Message { mi := &file_authenticate_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -474,7 +460,7 @@ func file_authenticate_proto_rawDescGZIP() []byte { } var file_authenticate_proto_msgTypes = make([]protoimpl.MessageInfo, 7) -var file_authenticate_proto_goTypes = []interface{}{ +var file_authenticate_proto_goTypes = []any{ (*AuthInfo)(nil), // 0: proto.AuthInfo (*AuthRequest)(nil), // 1: proto.AuthRequest (*AuthReply)(nil), // 2: proto.AuthReply @@ -506,93 +492,7 @@ func file_authenticate_proto_init() { return } file_user_proto_init() - if !protoimpl.UnsafeEnabled { - file_authenticate_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AuthInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_authenticate_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AuthRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_authenticate_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AuthReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_authenticate_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CheckPermRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_authenticate_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CheckPermResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_authenticate_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CheckUserPermRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_authenticate_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CheckUserPermResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_authenticate_proto_msgTypes[2].OneofWrappers = []interface{}{} + file_authenticate_proto_msgTypes[2].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/pkg/proto/authenticate_grpc.pb.go b/pkg/proto/authenticate_grpc.pb.go index 13ad6a5..db89709 100644 --- a/pkg/proto/authenticate_grpc.pb.go +++ b/pkg/proto/authenticate_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v5.28.2 +// - protoc-gen-go-grpc v1.5.1 +// - protoc v5.28.3 // source: authenticate.proto package proto @@ -15,8 +15,14 @@ import ( // 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.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + AuthService_Authenticate_FullMethodName = "/proto.AuthService/Authenticate" + AuthService_EnsurePermGranted_FullMethodName = "/proto.AuthService/EnsurePermGranted" + AuthService_EnsureUserPermGranted_FullMethodName = "/proto.AuthService/EnsureUserPermGranted" +) // AuthServiceClient is the client API for AuthService service. // @@ -36,8 +42,9 @@ func NewAuthServiceClient(cc grpc.ClientConnInterface) AuthServiceClient { } func (c *authServiceClient) Authenticate(ctx context.Context, in *AuthRequest, opts ...grpc.CallOption) (*AuthReply, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(AuthReply) - err := c.cc.Invoke(ctx, "/proto.AuthService/Authenticate", in, out, opts...) + err := c.cc.Invoke(ctx, AuthService_Authenticate_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -45,8 +52,9 @@ func (c *authServiceClient) Authenticate(ctx context.Context, in *AuthRequest, o } func (c *authServiceClient) EnsurePermGranted(ctx context.Context, in *CheckPermRequest, opts ...grpc.CallOption) (*CheckPermResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(CheckPermResponse) - err := c.cc.Invoke(ctx, "/proto.AuthService/EnsurePermGranted", in, out, opts...) + err := c.cc.Invoke(ctx, AuthService_EnsurePermGranted_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -54,8 +62,9 @@ func (c *authServiceClient) EnsurePermGranted(ctx context.Context, in *CheckPerm } func (c *authServiceClient) EnsureUserPermGranted(ctx context.Context, in *CheckUserPermRequest, opts ...grpc.CallOption) (*CheckUserPermResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(CheckUserPermResponse) - err := c.cc.Invoke(ctx, "/proto.AuthService/EnsureUserPermGranted", in, out, opts...) + err := c.cc.Invoke(ctx, AuthService_EnsureUserPermGranted_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -64,7 +73,7 @@ func (c *authServiceClient) EnsureUserPermGranted(ctx context.Context, in *Check // AuthServiceServer is the server API for AuthService service. // All implementations must embed UnimplementedAuthServiceServer -// for forward compatibility +// for forward compatibility. type AuthServiceServer interface { Authenticate(context.Context, *AuthRequest) (*AuthReply, error) EnsurePermGranted(context.Context, *CheckPermRequest) (*CheckPermResponse, error) @@ -72,9 +81,12 @@ type AuthServiceServer interface { mustEmbedUnimplementedAuthServiceServer() } -// UnimplementedAuthServiceServer must be embedded to have forward compatible implementations. -type UnimplementedAuthServiceServer struct { -} +// UnimplementedAuthServiceServer must 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 UnimplementedAuthServiceServer struct{} func (UnimplementedAuthServiceServer) Authenticate(context.Context, *AuthRequest) (*AuthReply, error) { return nil, status.Errorf(codes.Unimplemented, "method Authenticate not implemented") @@ -86,6 +98,7 @@ func (UnimplementedAuthServiceServer) EnsureUserPermGranted(context.Context, *Ch return nil, status.Errorf(codes.Unimplemented, "method EnsureUserPermGranted not implemented") } func (UnimplementedAuthServiceServer) mustEmbedUnimplementedAuthServiceServer() {} +func (UnimplementedAuthServiceServer) testEmbeddedByValue() {} // UnsafeAuthServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to AuthServiceServer will @@ -95,6 +108,13 @@ type UnsafeAuthServiceServer interface { } func RegisterAuthServiceServer(s grpc.ServiceRegistrar, srv AuthServiceServer) { + // If the following call pancis, it indicates UnimplementedAuthServiceServer 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(&AuthService_ServiceDesc, srv) } @@ -108,7 +128,7 @@ func _AuthService_Authenticate_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/proto.AuthService/Authenticate", + FullMethod: AuthService_Authenticate_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(AuthServiceServer).Authenticate(ctx, req.(*AuthRequest)) @@ -126,7 +146,7 @@ func _AuthService_EnsurePermGranted_Handler(srv interface{}, ctx context.Context } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/proto.AuthService/EnsurePermGranted", + FullMethod: AuthService_EnsurePermGranted_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(AuthServiceServer).EnsurePermGranted(ctx, req.(*CheckPermRequest)) @@ -144,7 +164,7 @@ func _AuthService_EnsureUserPermGranted_Handler(srv interface{}, ctx context.Con } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/proto.AuthService/EnsureUserPermGranted", + FullMethod: AuthService_EnsureUserPermGranted_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(AuthServiceServer).EnsureUserPermGranted(ctx, req.(*CheckUserPermRequest)) diff --git a/pkg/proto/command.pb.go b/pkg/proto/command.pb.go index 0139ab9..2e733e1 100644 --- a/pkg/proto/command.pb.go +++ b/pkg/proto/command.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v5.28.2 +// protoc-gen-go v1.35.1 +// protoc v5.28.3 // source: command.proto package proto @@ -32,11 +32,9 @@ type CommandInfo struct { func (x *CommandInfo) Reset() { *x = CommandInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_command_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_command_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *CommandInfo) String() string { @@ -47,7 +45,7 @@ func (*CommandInfo) ProtoMessage() {} func (x *CommandInfo) ProtoReflect() protoreflect.Message { mi := &file_command_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -94,11 +92,9 @@ type CommandLookupRequest struct { func (x *CommandLookupRequest) Reset() { *x = CommandLookupRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_command_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_command_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *CommandLookupRequest) String() string { @@ -109,7 +105,7 @@ func (*CommandLookupRequest) ProtoMessage() {} func (x *CommandLookupRequest) ProtoReflect() protoreflect.Message { mi := &file_command_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -148,11 +144,9 @@ type AddCommandResponse struct { func (x *AddCommandResponse) Reset() { *x = AddCommandResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_command_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_command_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AddCommandResponse) String() string { @@ -163,7 +157,7 @@ func (*AddCommandResponse) ProtoMessage() {} func (x *AddCommandResponse) ProtoReflect() protoreflect.Message { mi := &file_command_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -195,11 +189,9 @@ type RemoveCommandResponse struct { func (x *RemoveCommandResponse) Reset() { *x = RemoveCommandResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_command_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_command_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *RemoveCommandResponse) String() string { @@ -210,7 +202,7 @@ func (*RemoveCommandResponse) ProtoMessage() {} func (x *RemoveCommandResponse) ProtoReflect() protoreflect.Message { mi := &file_command_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -244,11 +236,9 @@ type CommandArgument struct { func (x *CommandArgument) Reset() { *x = CommandArgument{} - if protoimpl.UnsafeEnabled { - mi := &file_command_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_command_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *CommandArgument) String() string { @@ -259,7 +249,7 @@ func (*CommandArgument) ProtoMessage() {} func (x *CommandArgument) ProtoReflect() protoreflect.Message { mi := &file_command_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -308,11 +298,9 @@ type CommandReturn struct { func (x *CommandReturn) Reset() { *x = CommandReturn{} - if protoimpl.UnsafeEnabled { - mi := &file_command_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_command_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *CommandReturn) String() string { @@ -323,7 +311,7 @@ func (*CommandReturn) ProtoMessage() {} func (x *CommandReturn) ProtoReflect() protoreflect.Message { mi := &file_command_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -438,7 +426,7 @@ func file_command_proto_rawDescGZIP() []byte { } var file_command_proto_msgTypes = make([]protoimpl.MessageInfo, 6) -var file_command_proto_goTypes = []interface{}{ +var file_command_proto_goTypes = []any{ (*CommandInfo)(nil), // 0: proto.CommandInfo (*CommandLookupRequest)(nil), // 1: proto.CommandLookupRequest (*AddCommandResponse)(nil), // 2: proto.AddCommandResponse @@ -467,82 +455,8 @@ func file_command_proto_init() { if File_command_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_command_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CommandInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_command_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CommandLookupRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_command_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AddCommandResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_command_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RemoveCommandResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_command_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CommandArgument); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_command_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CommandReturn); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_command_proto_msgTypes[4].OneofWrappers = []interface{}{} - file_command_proto_msgTypes[5].OneofWrappers = []interface{}{} + file_command_proto_msgTypes[4].OneofWrappers = []any{} + file_command_proto_msgTypes[5].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/pkg/proto/command_grpc.pb.go b/pkg/proto/command_grpc.pb.go index 18c3100..86aec35 100644 --- a/pkg/proto/command_grpc.pb.go +++ b/pkg/proto/command_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v5.28.2 +// - protoc-gen-go-grpc v1.5.1 +// - protoc v5.28.3 // source: command.proto package proto @@ -15,8 +15,15 @@ import ( // 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.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + CommandProvider_AddCommand_FullMethodName = "/proto.CommandProvider/AddCommand" + CommandProvider_RemoveCommand_FullMethodName = "/proto.CommandProvider/RemoveCommand" + CommandProvider_SendCommand_FullMethodName = "/proto.CommandProvider/SendCommand" + CommandProvider_SendStreamCommand_FullMethodName = "/proto.CommandProvider/SendStreamCommand" +) // CommandProviderClient is the client API for CommandProvider service. // @@ -25,7 +32,7 @@ type CommandProviderClient interface { AddCommand(ctx context.Context, in *CommandInfo, opts ...grpc.CallOption) (*AddCommandResponse, error) RemoveCommand(ctx context.Context, in *CommandLookupRequest, opts ...grpc.CallOption) (*RemoveCommandResponse, error) SendCommand(ctx context.Context, in *CommandArgument, opts ...grpc.CallOption) (*CommandReturn, error) - SendStreamCommand(ctx context.Context, opts ...grpc.CallOption) (CommandProvider_SendStreamCommandClient, error) + SendStreamCommand(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[CommandArgument, CommandReturn], error) } type commandProviderClient struct { @@ -37,8 +44,9 @@ func NewCommandProviderClient(cc grpc.ClientConnInterface) CommandProviderClient } func (c *commandProviderClient) AddCommand(ctx context.Context, in *CommandInfo, opts ...grpc.CallOption) (*AddCommandResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(AddCommandResponse) - err := c.cc.Invoke(ctx, "/proto.CommandProvider/AddCommand", in, out, opts...) + err := c.cc.Invoke(ctx, CommandProvider_AddCommand_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -46,8 +54,9 @@ func (c *commandProviderClient) AddCommand(ctx context.Context, in *CommandInfo, } func (c *commandProviderClient) RemoveCommand(ctx context.Context, in *CommandLookupRequest, opts ...grpc.CallOption) (*RemoveCommandResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(RemoveCommandResponse) - err := c.cc.Invoke(ctx, "/proto.CommandProvider/RemoveCommand", in, out, opts...) + err := c.cc.Invoke(ctx, CommandProvider_RemoveCommand_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -55,59 +64,45 @@ func (c *commandProviderClient) RemoveCommand(ctx context.Context, in *CommandLo } func (c *commandProviderClient) SendCommand(ctx context.Context, in *CommandArgument, opts ...grpc.CallOption) (*CommandReturn, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(CommandReturn) - err := c.cc.Invoke(ctx, "/proto.CommandProvider/SendCommand", in, out, opts...) + err := c.cc.Invoke(ctx, CommandProvider_SendCommand_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *commandProviderClient) SendStreamCommand(ctx context.Context, opts ...grpc.CallOption) (CommandProvider_SendStreamCommandClient, error) { - stream, err := c.cc.NewStream(ctx, &CommandProvider_ServiceDesc.Streams[0], "/proto.CommandProvider/SendStreamCommand", opts...) +func (c *commandProviderClient) SendStreamCommand(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[CommandArgument, CommandReturn], error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + stream, err := c.cc.NewStream(ctx, &CommandProvider_ServiceDesc.Streams[0], CommandProvider_SendStreamCommand_FullMethodName, cOpts...) if err != nil { return nil, err } - x := &commandProviderSendStreamCommandClient{stream} + x := &grpc.GenericClientStream[CommandArgument, CommandReturn]{ClientStream: stream} return x, nil } -type CommandProvider_SendStreamCommandClient interface { - Send(*CommandArgument) error - Recv() (*CommandReturn, error) - grpc.ClientStream -} - -type commandProviderSendStreamCommandClient struct { - grpc.ClientStream -} - -func (x *commandProviderSendStreamCommandClient) Send(m *CommandArgument) error { - return x.ClientStream.SendMsg(m) -} - -func (x *commandProviderSendStreamCommandClient) Recv() (*CommandReturn, error) { - m := new(CommandReturn) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type CommandProvider_SendStreamCommandClient = grpc.BidiStreamingClient[CommandArgument, CommandReturn] // CommandProviderServer is the server API for CommandProvider service. // All implementations must embed UnimplementedCommandProviderServer -// for forward compatibility +// for forward compatibility. type CommandProviderServer interface { AddCommand(context.Context, *CommandInfo) (*AddCommandResponse, error) RemoveCommand(context.Context, *CommandLookupRequest) (*RemoveCommandResponse, error) SendCommand(context.Context, *CommandArgument) (*CommandReturn, error) - SendStreamCommand(CommandProvider_SendStreamCommandServer) error + SendStreamCommand(grpc.BidiStreamingServer[CommandArgument, CommandReturn]) error mustEmbedUnimplementedCommandProviderServer() } -// UnimplementedCommandProviderServer must be embedded to have forward compatible implementations. -type UnimplementedCommandProviderServer struct { -} +// UnimplementedCommandProviderServer must 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 UnimplementedCommandProviderServer struct{} func (UnimplementedCommandProviderServer) AddCommand(context.Context, *CommandInfo) (*AddCommandResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AddCommand not implemented") @@ -118,10 +113,11 @@ func (UnimplementedCommandProviderServer) RemoveCommand(context.Context, *Comman func (UnimplementedCommandProviderServer) SendCommand(context.Context, *CommandArgument) (*CommandReturn, error) { return nil, status.Errorf(codes.Unimplemented, "method SendCommand not implemented") } -func (UnimplementedCommandProviderServer) SendStreamCommand(CommandProvider_SendStreamCommandServer) error { +func (UnimplementedCommandProviderServer) SendStreamCommand(grpc.BidiStreamingServer[CommandArgument, CommandReturn]) error { return status.Errorf(codes.Unimplemented, "method SendStreamCommand not implemented") } func (UnimplementedCommandProviderServer) mustEmbedUnimplementedCommandProviderServer() {} +func (UnimplementedCommandProviderServer) testEmbeddedByValue() {} // UnsafeCommandProviderServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to CommandProviderServer will @@ -131,6 +127,13 @@ type UnsafeCommandProviderServer interface { } func RegisterCommandProviderServer(s grpc.ServiceRegistrar, srv CommandProviderServer) { + // If the following call pancis, it indicates UnimplementedCommandProviderServer 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(&CommandProvider_ServiceDesc, srv) } @@ -144,7 +147,7 @@ func _CommandProvider_AddCommand_Handler(srv interface{}, ctx context.Context, d } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/proto.CommandProvider/AddCommand", + FullMethod: CommandProvider_AddCommand_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(CommandProviderServer).AddCommand(ctx, req.(*CommandInfo)) @@ -162,7 +165,7 @@ func _CommandProvider_RemoveCommand_Handler(srv interface{}, ctx context.Context } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/proto.CommandProvider/RemoveCommand", + FullMethod: CommandProvider_RemoveCommand_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(CommandProviderServer).RemoveCommand(ctx, req.(*CommandLookupRequest)) @@ -180,7 +183,7 @@ func _CommandProvider_SendCommand_Handler(srv interface{}, ctx context.Context, } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/proto.CommandProvider/SendCommand", + FullMethod: CommandProvider_SendCommand_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(CommandProviderServer).SendCommand(ctx, req.(*CommandArgument)) @@ -189,30 +192,11 @@ func _CommandProvider_SendCommand_Handler(srv interface{}, ctx context.Context, } func _CommandProvider_SendStreamCommand_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(CommandProviderServer).SendStreamCommand(&commandProviderSendStreamCommandServer{stream}) + return srv.(CommandProviderServer).SendStreamCommand(&grpc.GenericServerStream[CommandArgument, CommandReturn]{ServerStream: stream}) } -type CommandProvider_SendStreamCommandServer interface { - Send(*CommandReturn) error - Recv() (*CommandArgument, error) - grpc.ServerStream -} - -type commandProviderSendStreamCommandServer struct { - grpc.ServerStream -} - -func (x *commandProviderSendStreamCommandServer) Send(m *CommandReturn) error { - return x.ServerStream.SendMsg(m) -} - -func (x *commandProviderSendStreamCommandServer) Recv() (*CommandArgument, error) { - m := new(CommandArgument) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type CommandProvider_SendStreamCommandServer = grpc.BidiStreamingServer[CommandArgument, CommandReturn] // CommandProvider_ServiceDesc is the grpc.ServiceDesc for CommandProvider service. // It's only intended for direct use with grpc.RegisterService, diff --git a/pkg/proto/database.pb.go b/pkg/proto/database.pb.go index d4d2d88..11c0e06 100644 --- a/pkg/proto/database.pb.go +++ b/pkg/proto/database.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v5.28.2 +// protoc-gen-go v1.35.1 +// protoc v5.28.3 // source: database.proto package proto @@ -30,11 +30,9 @@ type AllocDatabaseRequest struct { func (x *AllocDatabaseRequest) Reset() { *x = AllocDatabaseRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_database_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_database_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AllocDatabaseRequest) String() string { @@ -45,7 +43,7 @@ func (*AllocDatabaseRequest) ProtoMessage() {} func (x *AllocDatabaseRequest) ProtoReflect() protoreflect.Message { mi := &file_database_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -78,11 +76,9 @@ type AllocDatabaseResponse struct { func (x *AllocDatabaseResponse) Reset() { *x = AllocDatabaseResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_database_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_database_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AllocDatabaseResponse) String() string { @@ -93,7 +89,7 @@ func (*AllocDatabaseResponse) ProtoMessage() {} func (x *AllocDatabaseResponse) ProtoReflect() protoreflect.Message { mi := &file_database_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -157,7 +153,7 @@ func file_database_proto_rawDescGZIP() []byte { } var file_database_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_database_proto_goTypes = []interface{}{ +var file_database_proto_goTypes = []any{ (*AllocDatabaseRequest)(nil), // 0: proto.AllocDatabaseRequest (*AllocDatabaseResponse)(nil), // 1: proto.AllocDatabaseResponse } @@ -176,32 +172,6 @@ func file_database_proto_init() { if File_database_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_database_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AllocDatabaseRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_database_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AllocDatabaseResponse); 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{ diff --git a/pkg/proto/database_grpc.pb.go b/pkg/proto/database_grpc.pb.go index ce01204..f7dd42a 100644 --- a/pkg/proto/database_grpc.pb.go +++ b/pkg/proto/database_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v5.28.2 +// - protoc-gen-go-grpc v1.5.1 +// - protoc v5.28.3 // source: database.proto package proto @@ -15,8 +15,12 @@ import ( // 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.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + DatabaseService_AllocDatabase_FullMethodName = "/proto.DatabaseService/AllocDatabase" +) // DatabaseServiceClient is the client API for DatabaseService service. // @@ -34,8 +38,9 @@ func NewDatabaseServiceClient(cc grpc.ClientConnInterface) DatabaseServiceClient } func (c *databaseServiceClient) AllocDatabase(ctx context.Context, in *AllocDatabaseRequest, opts ...grpc.CallOption) (*AllocDatabaseResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(AllocDatabaseResponse) - err := c.cc.Invoke(ctx, "/proto.DatabaseService/AllocDatabase", in, out, opts...) + err := c.cc.Invoke(ctx, DatabaseService_AllocDatabase_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -44,20 +49,24 @@ func (c *databaseServiceClient) AllocDatabase(ctx context.Context, in *AllocData // DatabaseServiceServer is the server API for DatabaseService service. // All implementations must embed UnimplementedDatabaseServiceServer -// for forward compatibility +// for forward compatibility. type DatabaseServiceServer interface { AllocDatabase(context.Context, *AllocDatabaseRequest) (*AllocDatabaseResponse, error) mustEmbedUnimplementedDatabaseServiceServer() } -// UnimplementedDatabaseServiceServer must be embedded to have forward compatible implementations. -type UnimplementedDatabaseServiceServer struct { -} +// UnimplementedDatabaseServiceServer must 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 UnimplementedDatabaseServiceServer struct{} func (UnimplementedDatabaseServiceServer) AllocDatabase(context.Context, *AllocDatabaseRequest) (*AllocDatabaseResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AllocDatabase not implemented") } func (UnimplementedDatabaseServiceServer) mustEmbedUnimplementedDatabaseServiceServer() {} +func (UnimplementedDatabaseServiceServer) testEmbeddedByValue() {} // UnsafeDatabaseServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to DatabaseServiceServer will @@ -67,6 +76,13 @@ type UnsafeDatabaseServiceServer interface { } func RegisterDatabaseServiceServer(s grpc.ServiceRegistrar, srv DatabaseServiceServer) { + // If the following call pancis, it indicates UnimplementedDatabaseServiceServer 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(&DatabaseService_ServiceDesc, srv) } @@ -80,7 +96,7 @@ func _DatabaseService_AllocDatabase_Handler(srv interface{}, ctx context.Context } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/proto.DatabaseService/AllocDatabase", + FullMethod: DatabaseService_AllocDatabase_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(DatabaseServiceServer).AllocDatabase(ctx, req.(*AllocDatabaseRequest)) diff --git a/pkg/proto/services.pb.go b/pkg/proto/services.pb.go index 27db564..e0e306e 100644 --- a/pkg/proto/services.pb.go +++ b/pkg/proto/services.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v5.28.2 +// protoc-gen-go v1.35.1 +// protoc v5.28.3 // source: services.proto package proto @@ -34,11 +34,9 @@ type ServiceInfo struct { func (x *ServiceInfo) Reset() { *x = ServiceInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_services_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_services_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ServiceInfo) String() string { @@ -49,7 +47,7 @@ func (*ServiceInfo) ProtoMessage() {} func (x *ServiceInfo) ProtoReflect() protoreflect.Message { mi := &file_services_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -110,11 +108,9 @@ type GetServiceRequest struct { func (x *GetServiceRequest) Reset() { *x = GetServiceRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_services_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_services_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetServiceRequest) String() string { @@ -125,7 +121,7 @@ func (*GetServiceRequest) ProtoMessage() {} func (x *GetServiceRequest) ProtoReflect() protoreflect.Message { mi := &file_services_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -164,11 +160,9 @@ type GetServiceResponse struct { func (x *GetServiceResponse) Reset() { *x = GetServiceResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_services_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_services_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetServiceResponse) String() string { @@ -179,7 +173,7 @@ func (*GetServiceResponse) ProtoMessage() {} func (x *GetServiceResponse) ProtoReflect() protoreflect.Message { mi := &file_services_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -211,11 +205,9 @@ type ListServiceRequest struct { func (x *ListServiceRequest) Reset() { *x = ListServiceRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_services_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_services_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ListServiceRequest) String() string { @@ -226,7 +218,7 @@ func (*ListServiceRequest) ProtoMessage() {} func (x *ListServiceRequest) ProtoReflect() protoreflect.Message { mi := &file_services_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -258,11 +250,9 @@ type ListServiceResponse struct { func (x *ListServiceResponse) Reset() { *x = ListServiceResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_services_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_services_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ListServiceResponse) String() string { @@ -273,7 +263,7 @@ func (*ListServiceResponse) ProtoMessage() {} func (x *ListServiceResponse) ProtoReflect() protoreflect.Message { mi := &file_services_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -305,11 +295,9 @@ type AddServiceResponse struct { func (x *AddServiceResponse) Reset() { *x = AddServiceResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_services_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_services_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AddServiceResponse) String() string { @@ -320,7 +308,7 @@ func (*AddServiceResponse) ProtoMessage() {} func (x *AddServiceResponse) ProtoReflect() protoreflect.Message { mi := &file_services_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -352,11 +340,9 @@ type RemoveServiceRequest struct { func (x *RemoveServiceRequest) Reset() { *x = RemoveServiceRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_services_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_services_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *RemoveServiceRequest) String() string { @@ -367,7 +353,7 @@ func (*RemoveServiceRequest) ProtoMessage() {} func (x *RemoveServiceRequest) ProtoReflect() protoreflect.Message { mi := &file_services_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -399,11 +385,9 @@ type RemoveServiceResponse struct { func (x *RemoveServiceResponse) Reset() { *x = RemoveServiceResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_services_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_services_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *RemoveServiceResponse) String() string { @@ -414,7 +398,7 @@ func (*RemoveServiceResponse) ProtoMessage() {} func (x *RemoveServiceResponse) ProtoReflect() protoreflect.Message { mi := &file_services_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -447,11 +431,9 @@ type EventInfo struct { func (x *EventInfo) Reset() { *x = EventInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_services_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_services_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *EventInfo) String() string { @@ -462,7 +444,7 @@ func (*EventInfo) ProtoMessage() {} func (x *EventInfo) ProtoReflect() protoreflect.Message { mi := &file_services_proto_msgTypes[8] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -499,11 +481,9 @@ type EventResponse struct { func (x *EventResponse) Reset() { *x = EventResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_services_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_services_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *EventResponse) String() string { @@ -514,7 +494,7 @@ func (*EventResponse) ProtoMessage() {} func (x *EventResponse) ProtoReflect() protoreflect.Message { mi := &file_services_proto_msgTypes[9] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -613,7 +593,7 @@ func file_services_proto_rawDescGZIP() []byte { } var file_services_proto_msgTypes = make([]protoimpl.MessageInfo, 10) -var file_services_proto_goTypes = []interface{}{ +var file_services_proto_goTypes = []any{ (*ServiceInfo)(nil), // 0: proto.ServiceInfo (*GetServiceRequest)(nil), // 1: proto.GetServiceRequest (*GetServiceResponse)(nil), // 2: proto.GetServiceResponse @@ -650,131 +630,9 @@ func file_services_proto_init() { if File_services_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_services_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ServiceInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_services_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetServiceRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_services_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetServiceResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_services_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListServiceRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_services_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListServiceResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_services_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AddServiceResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_services_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RemoveServiceRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_services_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RemoveServiceResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_services_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*EventInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_services_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*EventResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_services_proto_msgTypes[0].OneofWrappers = []interface{}{} - file_services_proto_msgTypes[1].OneofWrappers = []interface{}{} - file_services_proto_msgTypes[3].OneofWrappers = []interface{}{} + file_services_proto_msgTypes[0].OneofWrappers = []any{} + file_services_proto_msgTypes[1].OneofWrappers = []any{} + file_services_proto_msgTypes[3].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/pkg/proto/services_grpc.pb.go b/pkg/proto/services_grpc.pb.go index 126d119..0d2efbd 100644 --- a/pkg/proto/services_grpc.pb.go +++ b/pkg/proto/services_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v5.28.2 +// - protoc-gen-go-grpc v1.5.1 +// - protoc v5.28.3 // source: services.proto package proto @@ -15,8 +15,16 @@ import ( // 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.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + DirectoryService_GetService_FullMethodName = "/proto.DirectoryService/GetService" + DirectoryService_ListService_FullMethodName = "/proto.DirectoryService/ListService" + DirectoryService_AddService_FullMethodName = "/proto.DirectoryService/AddService" + DirectoryService_RemoveService_FullMethodName = "/proto.DirectoryService/RemoveService" + DirectoryService_BroadcastEvent_FullMethodName = "/proto.DirectoryService/BroadcastEvent" +) // DirectoryServiceClient is the client API for DirectoryService service. // @@ -38,8 +46,9 @@ func NewDirectoryServiceClient(cc grpc.ClientConnInterface) DirectoryServiceClie } func (c *directoryServiceClient) GetService(ctx context.Context, in *GetServiceRequest, opts ...grpc.CallOption) (*GetServiceResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(GetServiceResponse) - err := c.cc.Invoke(ctx, "/proto.DirectoryService/GetService", in, out, opts...) + err := c.cc.Invoke(ctx, DirectoryService_GetService_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -47,8 +56,9 @@ func (c *directoryServiceClient) GetService(ctx context.Context, in *GetServiceR } func (c *directoryServiceClient) ListService(ctx context.Context, in *ListServiceRequest, opts ...grpc.CallOption) (*ListServiceResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ListServiceResponse) - err := c.cc.Invoke(ctx, "/proto.DirectoryService/ListService", in, out, opts...) + err := c.cc.Invoke(ctx, DirectoryService_ListService_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -56,8 +66,9 @@ func (c *directoryServiceClient) ListService(ctx context.Context, in *ListServic } func (c *directoryServiceClient) AddService(ctx context.Context, in *ServiceInfo, opts ...grpc.CallOption) (*AddServiceResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(AddServiceResponse) - err := c.cc.Invoke(ctx, "/proto.DirectoryService/AddService", in, out, opts...) + err := c.cc.Invoke(ctx, DirectoryService_AddService_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -65,8 +76,9 @@ func (c *directoryServiceClient) AddService(ctx context.Context, in *ServiceInfo } func (c *directoryServiceClient) RemoveService(ctx context.Context, in *RemoveServiceRequest, opts ...grpc.CallOption) (*RemoveServiceResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(RemoveServiceResponse) - err := c.cc.Invoke(ctx, "/proto.DirectoryService/RemoveService", in, out, opts...) + err := c.cc.Invoke(ctx, DirectoryService_RemoveService_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -74,8 +86,9 @@ func (c *directoryServiceClient) RemoveService(ctx context.Context, in *RemoveSe } func (c *directoryServiceClient) BroadcastEvent(ctx context.Context, in *EventInfo, opts ...grpc.CallOption) (*EventResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(EventResponse) - err := c.cc.Invoke(ctx, "/proto.DirectoryService/BroadcastEvent", in, out, opts...) + err := c.cc.Invoke(ctx, DirectoryService_BroadcastEvent_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -84,7 +97,7 @@ func (c *directoryServiceClient) BroadcastEvent(ctx context.Context, in *EventIn // DirectoryServiceServer is the server API for DirectoryService service. // All implementations must embed UnimplementedDirectoryServiceServer -// for forward compatibility +// for forward compatibility. type DirectoryServiceServer interface { GetService(context.Context, *GetServiceRequest) (*GetServiceResponse, error) ListService(context.Context, *ListServiceRequest) (*ListServiceResponse, error) @@ -94,9 +107,12 @@ type DirectoryServiceServer interface { mustEmbedUnimplementedDirectoryServiceServer() } -// UnimplementedDirectoryServiceServer must be embedded to have forward compatible implementations. -type UnimplementedDirectoryServiceServer struct { -} +// UnimplementedDirectoryServiceServer must 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 UnimplementedDirectoryServiceServer struct{} func (UnimplementedDirectoryServiceServer) GetService(context.Context, *GetServiceRequest) (*GetServiceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetService not implemented") @@ -114,6 +130,7 @@ func (UnimplementedDirectoryServiceServer) BroadcastEvent(context.Context, *Even return nil, status.Errorf(codes.Unimplemented, "method BroadcastEvent not implemented") } func (UnimplementedDirectoryServiceServer) mustEmbedUnimplementedDirectoryServiceServer() {} +func (UnimplementedDirectoryServiceServer) testEmbeddedByValue() {} // UnsafeDirectoryServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to DirectoryServiceServer will @@ -123,6 +140,13 @@ type UnsafeDirectoryServiceServer interface { } func RegisterDirectoryServiceServer(s grpc.ServiceRegistrar, srv DirectoryServiceServer) { + // If the following call pancis, it indicates UnimplementedDirectoryServiceServer 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(&DirectoryService_ServiceDesc, srv) } @@ -136,7 +160,7 @@ func _DirectoryService_GetService_Handler(srv interface{}, ctx context.Context, } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/proto.DirectoryService/GetService", + FullMethod: DirectoryService_GetService_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(DirectoryServiceServer).GetService(ctx, req.(*GetServiceRequest)) @@ -154,7 +178,7 @@ func _DirectoryService_ListService_Handler(srv interface{}, ctx context.Context, } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/proto.DirectoryService/ListService", + FullMethod: DirectoryService_ListService_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(DirectoryServiceServer).ListService(ctx, req.(*ListServiceRequest)) @@ -172,7 +196,7 @@ func _DirectoryService_AddService_Handler(srv interface{}, ctx context.Context, } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/proto.DirectoryService/AddService", + FullMethod: DirectoryService_AddService_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(DirectoryServiceServer).AddService(ctx, req.(*ServiceInfo)) @@ -190,7 +214,7 @@ func _DirectoryService_RemoveService_Handler(srv interface{}, ctx context.Contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/proto.DirectoryService/RemoveService", + FullMethod: DirectoryService_RemoveService_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(DirectoryServiceServer).RemoveService(ctx, req.(*RemoveServiceRequest)) @@ -208,7 +232,7 @@ func _DirectoryService_BroadcastEvent_Handler(srv interface{}, ctx context.Conte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/proto.DirectoryService/BroadcastEvent", + FullMethod: DirectoryService_BroadcastEvent_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(DirectoryServiceServer).BroadcastEvent(ctx, req.(*EventInfo)) diff --git a/pkg/proto/stream.pb.go b/pkg/proto/stream.pb.go index 1f2b9bc..04205ad 100644 --- a/pkg/proto/stream.pb.go +++ b/pkg/proto/stream.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v5.28.2 +// protoc-gen-go v1.35.1 +// protoc v5.28.3 // source: stream.proto package proto @@ -30,11 +30,9 @@ type CountConnectionRequest struct { func (x *CountConnectionRequest) Reset() { *x = CountConnectionRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_stream_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_stream_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *CountConnectionRequest) String() string { @@ -45,7 +43,7 @@ func (*CountConnectionRequest) ProtoMessage() {} func (x *CountConnectionRequest) ProtoReflect() protoreflect.Message { mi := &file_stream_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -77,11 +75,9 @@ type CountConnectionResponse struct { func (x *CountConnectionResponse) Reset() { *x = CountConnectionResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_stream_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_stream_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *CountConnectionResponse) String() string { @@ -92,7 +88,7 @@ func (*CountConnectionResponse) ProtoMessage() {} func (x *CountConnectionResponse) ProtoReflect() protoreflect.Message { mi := &file_stream_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -126,11 +122,9 @@ type PushStreamRequest struct { func (x *PushStreamRequest) Reset() { *x = PushStreamRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_stream_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_stream_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *PushStreamRequest) String() string { @@ -141,7 +135,7 @@ func (*PushStreamRequest) ProtoMessage() {} func (x *PushStreamRequest) ProtoReflect() protoreflect.Message { mi := &file_stream_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -189,11 +183,9 @@ type PushStreamBatchRequest struct { func (x *PushStreamBatchRequest) Reset() { *x = PushStreamBatchRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_stream_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_stream_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *PushStreamBatchRequest) String() string { @@ -204,7 +196,7 @@ func (*PushStreamBatchRequest) ProtoMessage() {} func (x *PushStreamBatchRequest) ProtoReflect() protoreflect.Message { mi := &file_stream_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -245,18 +237,17 @@ type PushStreamResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - IsAllSuccess bool `protobuf:"varint,1,opt,name=is_all_success,json=isAllSuccess,proto3" json:"is_all_success,omitempty"` - AffectedCount int64 `protobuf:"varint,2,opt,name=affected_count,json=affectedCount,proto3" json:"affected_count,omitempty"` - FailedCount int64 `protobuf:"varint,3,opt,name=failed_count,json=failedCount,proto3" json:"failed_count,omitempty"` + IsAllSuccess bool `protobuf:"varint,1,opt,name=is_all_success,json=isAllSuccess,proto3" json:"is_all_success,omitempty"` + AffectedCount int64 `protobuf:"varint,2,opt,name=affected_count,json=affectedCount,proto3" json:"affected_count,omitempty"` + FailedCount int64 `protobuf:"varint,3,opt,name=failed_count,json=failedCount,proto3" json:"failed_count,omitempty"` + SuccessList []uint64 `protobuf:"varint,4,rep,packed,name=success_list,json=successList,proto3" json:"success_list,omitempty"` } func (x *PushStreamResponse) Reset() { *x = PushStreamResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_stream_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_stream_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *PushStreamResponse) String() string { @@ -267,7 +258,7 @@ func (*PushStreamResponse) ProtoMessage() {} func (x *PushStreamResponse) ProtoReflect() protoreflect.Message { mi := &file_stream_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -303,6 +294,13 @@ func (x *PushStreamResponse) GetFailedCount() int64 { return 0 } +func (x *PushStreamResponse) GetSuccessList() []uint64 { + if x != nil { + return x.SuccessList + } + return nil +} + type StreamEventRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -316,11 +314,9 @@ type StreamEventRequest struct { func (x *StreamEventRequest) Reset() { *x = StreamEventRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_stream_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_stream_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *StreamEventRequest) String() string { @@ -331,7 +327,7 @@ func (*StreamEventRequest) ProtoMessage() {} func (x *StreamEventRequest) ProtoReflect() protoreflect.Message { mi := &file_stream_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -382,11 +378,9 @@ type StreamEventResponse struct { func (x *StreamEventResponse) Reset() { *x = StreamEventResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_stream_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_stream_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *StreamEventResponse) String() string { @@ -397,7 +391,7 @@ func (*StreamEventResponse) ProtoMessage() {} func (x *StreamEventResponse) ProtoReflect() protoreflect.Message { mi := &file_stream_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -437,7 +431,7 @@ var file_stream_proto_rawDesc = []byte{ 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x04, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, - 0x79, 0x22, 0x84, 0x01, 0x0a, 0x12, 0x50, 0x75, 0x73, 0x68, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, + 0x79, 0x22, 0xa7, 0x01, 0x0a, 0x12, 0x50, 0x75, 0x73, 0x68, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x24, 0x0a, 0x0e, 0x69, 0x73, 0x5f, 0x61, 0x6c, 0x6c, 0x5f, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x69, 0x73, 0x41, 0x6c, 0x6c, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x25, @@ -445,33 +439,36 @@ var file_stream_proto_rawDesc = []byte{ 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x61, 0x66, 0x66, 0x65, 0x63, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x66, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x66, 0x61, 0x69, - 0x6c, 0x65, 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x7a, 0x0a, 0x12, 0x53, 0x74, 0x72, 0x65, - 0x61, 0x6d, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, - 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, - 0x76, 0x65, 0x6e, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1b, 0x0a, - 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, - 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, 0x79, - 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x15, 0x0a, 0x13, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x45, 0x76, - 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xfd, 0x01, 0x0a, 0x0d, - 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x58, 0x0a, - 0x15, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, 0x6f, 0x6e, 0x6e, - 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, - 0x6f, 0x75, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x6f, - 0x75, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x0a, 0x50, 0x75, 0x73, 0x68, 0x53, - 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x75, - 0x73, 0x68, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x53, 0x74, 0x72, 0x65, - 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4d, 0x0a, 0x0f, - 0x50, 0x75, 0x73, 0x68, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x42, 0x61, 0x74, 0x63, 0x68, 0x12, - 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x53, 0x74, 0x72, 0x65, - 0x61, 0x6d, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x53, 0x74, 0x72, 0x65, 0x61, - 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x09, 0x5a, 0x07, 0x2e, - 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6c, 0x65, 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x75, 0x63, 0x63, + 0x65, 0x73, 0x73, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x04, 0x20, 0x03, 0x28, 0x04, 0x52, 0x0b, + 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x7a, 0x0a, 0x12, 0x53, + 0x74, 0x72, 0x65, 0x61, 0x6d, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, + 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, + 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x18, 0x0a, + 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, + 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x15, 0x0a, 0x13, 0x53, 0x74, 0x72, 0x65, 0x61, + 0x6d, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xfd, + 0x01, 0x0a, 0x0d, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x12, 0x58, 0x0a, 0x15, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, + 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x0a, 0x50, 0x75, + 0x73, 0x68, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x2e, 0x50, 0x75, 0x73, 0x68, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x53, + 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x4d, 0x0a, 0x0f, 0x50, 0x75, 0x73, 0x68, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x42, 0x61, 0x74, + 0x63, 0x68, 0x12, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x53, + 0x74, 0x72, 0x65, 0x61, 0x6d, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x53, 0x74, + 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x09, + 0x5a, 0x07, 0x2e, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -487,7 +484,7 @@ func file_stream_proto_rawDescGZIP() []byte { } var file_stream_proto_msgTypes = make([]protoimpl.MessageInfo, 7) -var file_stream_proto_goTypes = []interface{}{ +var file_stream_proto_goTypes = []any{ (*CountConnectionRequest)(nil), // 0: proto.CountConnectionRequest (*CountConnectionResponse)(nil), // 1: proto.CountConnectionResponse (*PushStreamRequest)(nil), // 2: proto.PushStreamRequest @@ -515,93 +512,7 @@ func file_stream_proto_init() { if File_stream_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_stream_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CountConnectionRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_stream_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CountConnectionResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_stream_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PushStreamRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_stream_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PushStreamBatchRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_stream_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PushStreamResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_stream_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*StreamEventRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_stream_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*StreamEventResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_stream_proto_msgTypes[2].OneofWrappers = []interface{}{} + file_stream_proto_msgTypes[2].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/pkg/proto/stream.proto b/pkg/proto/stream.proto index 5648097..b576035 100644 --- a/pkg/proto/stream.proto +++ b/pkg/proto/stream.proto @@ -34,6 +34,7 @@ message PushStreamResponse { bool is_all_success = 1; int64 affected_count = 2; int64 failed_count = 3; + repeated uint64 success_list = 4; } message StreamEventRequest { diff --git a/pkg/proto/stream_grpc.pb.go b/pkg/proto/stream_grpc.pb.go index d13ad02..cbbed4b 100644 --- a/pkg/proto/stream_grpc.pb.go +++ b/pkg/proto/stream_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v5.28.2 +// - protoc-gen-go-grpc v1.5.1 +// - protoc v5.28.3 // source: stream.proto package proto @@ -15,8 +15,14 @@ import ( // 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.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + StreamService_CountStreamConnection_FullMethodName = "/proto.StreamService/CountStreamConnection" + StreamService_PushStream_FullMethodName = "/proto.StreamService/PushStream" + StreamService_PushStreamBatch_FullMethodName = "/proto.StreamService/PushStreamBatch" +) // StreamServiceClient is the client API for StreamService service. // @@ -36,8 +42,9 @@ func NewStreamServiceClient(cc grpc.ClientConnInterface) StreamServiceClient { } func (c *streamServiceClient) CountStreamConnection(ctx context.Context, in *CountConnectionRequest, opts ...grpc.CallOption) (*CountConnectionResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(CountConnectionResponse) - err := c.cc.Invoke(ctx, "/proto.StreamService/CountStreamConnection", in, out, opts...) + err := c.cc.Invoke(ctx, StreamService_CountStreamConnection_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -45,8 +52,9 @@ func (c *streamServiceClient) CountStreamConnection(ctx context.Context, in *Cou } func (c *streamServiceClient) PushStream(ctx context.Context, in *PushStreamRequest, opts ...grpc.CallOption) (*PushStreamResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(PushStreamResponse) - err := c.cc.Invoke(ctx, "/proto.StreamService/PushStream", in, out, opts...) + err := c.cc.Invoke(ctx, StreamService_PushStream_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -54,8 +62,9 @@ func (c *streamServiceClient) PushStream(ctx context.Context, in *PushStreamRequ } func (c *streamServiceClient) PushStreamBatch(ctx context.Context, in *PushStreamBatchRequest, opts ...grpc.CallOption) (*PushStreamResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(PushStreamResponse) - err := c.cc.Invoke(ctx, "/proto.StreamService/PushStreamBatch", in, out, opts...) + err := c.cc.Invoke(ctx, StreamService_PushStreamBatch_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -64,7 +73,7 @@ func (c *streamServiceClient) PushStreamBatch(ctx context.Context, in *PushStrea // StreamServiceServer is the server API for StreamService service. // All implementations must embed UnimplementedStreamServiceServer -// for forward compatibility +// for forward compatibility. type StreamServiceServer interface { CountStreamConnection(context.Context, *CountConnectionRequest) (*CountConnectionResponse, error) PushStream(context.Context, *PushStreamRequest) (*PushStreamResponse, error) @@ -72,9 +81,12 @@ type StreamServiceServer interface { mustEmbedUnimplementedStreamServiceServer() } -// UnimplementedStreamServiceServer must be embedded to have forward compatible implementations. -type UnimplementedStreamServiceServer struct { -} +// UnimplementedStreamServiceServer must 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 UnimplementedStreamServiceServer struct{} func (UnimplementedStreamServiceServer) CountStreamConnection(context.Context, *CountConnectionRequest) (*CountConnectionResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CountStreamConnection not implemented") @@ -86,6 +98,7 @@ func (UnimplementedStreamServiceServer) PushStreamBatch(context.Context, *PushSt return nil, status.Errorf(codes.Unimplemented, "method PushStreamBatch not implemented") } func (UnimplementedStreamServiceServer) mustEmbedUnimplementedStreamServiceServer() {} +func (UnimplementedStreamServiceServer) testEmbeddedByValue() {} // UnsafeStreamServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to StreamServiceServer will @@ -95,6 +108,13 @@ type UnsafeStreamServiceServer interface { } func RegisterStreamServiceServer(s grpc.ServiceRegistrar, srv StreamServiceServer) { + // If the following call pancis, it indicates UnimplementedStreamServiceServer 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(&StreamService_ServiceDesc, srv) } @@ -108,7 +128,7 @@ func _StreamService_CountStreamConnection_Handler(srv interface{}, ctx context.C } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/proto.StreamService/CountStreamConnection", + FullMethod: StreamService_CountStreamConnection_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(StreamServiceServer).CountStreamConnection(ctx, req.(*CountConnectionRequest)) @@ -126,7 +146,7 @@ func _StreamService_PushStream_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/proto.StreamService/PushStream", + FullMethod: StreamService_PushStream_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(StreamServiceServer).PushStream(ctx, req.(*PushStreamRequest)) @@ -144,7 +164,7 @@ func _StreamService_PushStreamBatch_Handler(srv interface{}, ctx context.Context } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/proto.StreamService/PushStreamBatch", + FullMethod: StreamService_PushStreamBatch_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(StreamServiceServer).PushStreamBatch(ctx, req.(*PushStreamBatchRequest)) diff --git a/pkg/proto/user.pb.go b/pkg/proto/user.pb.go index da707aa..363823e 100644 --- a/pkg/proto/user.pb.go +++ b/pkg/proto/user.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v5.28.2 +// protoc-gen-go v1.35.1 +// protoc v5.28.3 // source: user.proto package proto @@ -33,11 +33,9 @@ type UserInfo struct { func (x *UserInfo) Reset() { *x = UserInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_user_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_user_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *UserInfo) String() string { @@ -48,7 +46,7 @@ func (*UserInfo) ProtoMessage() {} func (x *UserInfo) ProtoReflect() protoreflect.Message { mi := &file_user_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -101,11 +99,9 @@ type MultipleUserInfo struct { func (x *MultipleUserInfo) Reset() { *x = MultipleUserInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_user_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_user_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *MultipleUserInfo) String() string { @@ -116,7 +112,7 @@ func (*MultipleUserInfo) ProtoMessage() {} func (x *MultipleUserInfo) ProtoReflect() protoreflect.Message { mi := &file_user_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -149,11 +145,9 @@ type GetUserRequest struct { func (x *GetUserRequest) Reset() { *x = GetUserRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_user_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_user_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetUserRequest) String() string { @@ -164,7 +158,7 @@ func (*GetUserRequest) ProtoMessage() {} func (x *GetUserRequest) ProtoReflect() protoreflect.Message { mi := &file_user_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -203,11 +197,9 @@ type ListUserRequest struct { func (x *ListUserRequest) Reset() { *x = ListUserRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_user_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_user_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ListUserRequest) String() string { @@ -218,7 +210,7 @@ func (*ListUserRequest) ProtoMessage() {} func (x *ListUserRequest) ProtoReflect() protoreflect.Message { mi := &file_user_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -252,11 +244,9 @@ type ListUserRelativeRequest struct { func (x *ListUserRelativeRequest) Reset() { *x = ListUserRelativeRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_user_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_user_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ListUserRelativeRequest) String() string { @@ -267,7 +257,7 @@ func (*ListUserRelativeRequest) ProtoMessage() {} func (x *ListUserRelativeRequest) ProtoReflect() protoreflect.Message { mi := &file_user_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -313,11 +303,9 @@ type ListUserRelativeResponse struct { func (x *ListUserRelativeResponse) Reset() { *x = ListUserRelativeResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_user_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_user_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ListUserRelativeResponse) String() string { @@ -328,7 +316,7 @@ func (*ListUserRelativeResponse) ProtoMessage() {} func (x *ListUserRelativeResponse) ProtoReflect() protoreflect.Message { mi := &file_user_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -417,7 +405,7 @@ func file_user_proto_rawDescGZIP() []byte { } var file_user_proto_msgTypes = make([]protoimpl.MessageInfo, 6) -var file_user_proto_goTypes = []interface{}{ +var file_user_proto_goTypes = []any{ (*UserInfo)(nil), // 0: proto.UserInfo (*MultipleUserInfo)(nil), // 1: proto.MultipleUserInfo (*GetUserRequest)(nil), // 2: proto.GetUserRequest @@ -446,82 +434,8 @@ func file_user_proto_init() { if File_user_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_user_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UserInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_user_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MultipleUserInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_user_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetUserRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_user_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListUserRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_user_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListUserRelativeRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_user_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListUserRelativeResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_user_proto_msgTypes[0].OneofWrappers = []interface{}{} - file_user_proto_msgTypes[2].OneofWrappers = []interface{}{} + file_user_proto_msgTypes[0].OneofWrappers = []any{} + file_user_proto_msgTypes[2].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/pkg/proto/user_grpc.pb.go b/pkg/proto/user_grpc.pb.go index 8d24f31..8d991ce 100644 --- a/pkg/proto/user_grpc.pb.go +++ b/pkg/proto/user_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v5.28.2 +// - protoc-gen-go-grpc v1.5.1 +// - protoc v5.28.3 // source: user.proto package proto @@ -15,8 +15,14 @@ import ( // 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.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + UserService_GetUser_FullMethodName = "/proto.UserService/GetUser" + UserService_ListUser_FullMethodName = "/proto.UserService/ListUser" + UserService_ListUserRelative_FullMethodName = "/proto.UserService/ListUserRelative" +) // UserServiceClient is the client API for UserService service. // @@ -36,8 +42,9 @@ func NewUserServiceClient(cc grpc.ClientConnInterface) UserServiceClient { } func (c *userServiceClient) GetUser(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*UserInfo, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(UserInfo) - err := c.cc.Invoke(ctx, "/proto.UserService/GetUser", in, out, opts...) + err := c.cc.Invoke(ctx, UserService_GetUser_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -45,8 +52,9 @@ func (c *userServiceClient) GetUser(ctx context.Context, in *GetUserRequest, opt } func (c *userServiceClient) ListUser(ctx context.Context, in *ListUserRequest, opts ...grpc.CallOption) (*MultipleUserInfo, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(MultipleUserInfo) - err := c.cc.Invoke(ctx, "/proto.UserService/ListUser", in, out, opts...) + err := c.cc.Invoke(ctx, UserService_ListUser_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -54,8 +62,9 @@ func (c *userServiceClient) ListUser(ctx context.Context, in *ListUserRequest, o } func (c *userServiceClient) ListUserRelative(ctx context.Context, in *ListUserRelativeRequest, opts ...grpc.CallOption) (*ListUserRelativeResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ListUserRelativeResponse) - err := c.cc.Invoke(ctx, "/proto.UserService/ListUserRelative", in, out, opts...) + err := c.cc.Invoke(ctx, UserService_ListUserRelative_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -64,7 +73,7 @@ func (c *userServiceClient) ListUserRelative(ctx context.Context, in *ListUserRe // UserServiceServer is the server API for UserService service. // All implementations must embed UnimplementedUserServiceServer -// for forward compatibility +// for forward compatibility. type UserServiceServer interface { GetUser(context.Context, *GetUserRequest) (*UserInfo, error) ListUser(context.Context, *ListUserRequest) (*MultipleUserInfo, error) @@ -72,9 +81,12 @@ type UserServiceServer interface { mustEmbedUnimplementedUserServiceServer() } -// UnimplementedUserServiceServer must be embedded to have forward compatible implementations. -type UnimplementedUserServiceServer struct { -} +// UnimplementedUserServiceServer must 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 UnimplementedUserServiceServer struct{} func (UnimplementedUserServiceServer) GetUser(context.Context, *GetUserRequest) (*UserInfo, error) { return nil, status.Errorf(codes.Unimplemented, "method GetUser not implemented") @@ -86,6 +98,7 @@ func (UnimplementedUserServiceServer) ListUserRelative(context.Context, *ListUse return nil, status.Errorf(codes.Unimplemented, "method ListUserRelative not implemented") } func (UnimplementedUserServiceServer) mustEmbedUnimplementedUserServiceServer() {} +func (UnimplementedUserServiceServer) testEmbeddedByValue() {} // UnsafeUserServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to UserServiceServer will @@ -95,6 +108,13 @@ type UnsafeUserServiceServer interface { } func RegisterUserServiceServer(s grpc.ServiceRegistrar, srv UserServiceServer) { + // If the following call pancis, it indicates UnimplementedUserServiceServer 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(&UserService_ServiceDesc, srv) } @@ -108,7 +128,7 @@ func _UserService_GetUser_Handler(srv interface{}, ctx context.Context, dec func } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/proto.UserService/GetUser", + FullMethod: UserService_GetUser_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(UserServiceServer).GetUser(ctx, req.(*GetUserRequest)) @@ -126,7 +146,7 @@ func _UserService_ListUser_Handler(srv interface{}, ctx context.Context, dec fun } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/proto.UserService/ListUser", + FullMethod: UserService_ListUser_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(UserServiceServer).ListUser(ctx, req.(*ListUserRequest)) @@ -144,7 +164,7 @@ func _UserService_ListUserRelative_Handler(srv interface{}, ctx context.Context, } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/proto.UserService/ListUserRelative", + FullMethod: UserService_ListUserRelative_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(UserServiceServer).ListUserRelative(ctx, req.(*ListUserRelativeRequest))