From 6d899a83844f9b3db9196be2d7f03ba82c398a2f Mon Sep 17 00:00:00 2001 From: h0n9 Date: Thu, 16 Nov 2023 12:40:20 +0900 Subject: [PATCH 1/5] Simplify msgCapsule Data format for general use --- cli/client/client.go | 37 +++++++++++-------------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/cli/client/client.go b/cli/client/client.go index 07651a9..98b1a8b 100644 --- a/cli/client/client.go +++ b/cli/client/client.go @@ -149,18 +149,10 @@ var Cmd = &cobra.Command{ if bytes.Equal(signature.GetPubKey(), pubKeyBytes) { continue } - data := msgCapsule.GetData() - if len(data) == 0 { + if len(msgCapsule.GetData()) == 0 { continue } - timestamp := msgCapsule.GetTimestamp() - msg := Msg{} - err = json.Unmarshal(data, &msg) - if err != nil { - fmt.Println(err) - continue - } - printOutput(true, &msg, timestamp) + printOutput(true, msgCapsule) printInput(true) } }() @@ -189,13 +181,7 @@ var Cmd = &cobra.Command{ continue } go func() { - msg := Msg{ - Data: []byte(input), - Metadata: map[string][]byte{ - "nickname": []byte(nickname), - }, - } - data, err := json.Marshal(msg) + data, err := json.Marshal(input) if err != nil { fmt.Println(err) return @@ -242,21 +228,20 @@ func printInput(newline bool) { if newline { s = "\r\n" + s } - fmt.Printf(s, nickname) + fmt.Printf(s, "me") } -func printOutput(newline bool, msg *Msg, timestamp int64) { +func printOutput(newline bool, msgCapsule *pb.MsgCapsule) { s := "📩 <%s> [%d] %s" if newline { s = "\r\n" + s } - nickname := "unknown" - metadata := msg.Metadata - value, exist := metadata["nickname"] - if exist { - nickname = string(value) - } - fmt.Printf(s, nickname, timestamp, msg.Data) + fmt.Printf( + s, + string(msgCapsule.GetSignature().GetPubKey()), + msgCapsule.GetTimestamp(), + msgCapsule.GetData(), + ) } type Msg struct { From 37fa277ec067f7bc0a7b5a7fd7d320b9299d5b09 Mon Sep 17 00:00:00 2001 From: h0n9 Date: Sat, 13 Jan 2024 23:28:23 +0900 Subject: [PATCH 2/5] Fix format to print pubkey --- cli/client/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/client/client.go b/cli/client/client.go index 98b1a8b..82881fc 100644 --- a/cli/client/client.go +++ b/cli/client/client.go @@ -238,7 +238,7 @@ func printOutput(newline bool, msgCapsule *pb.MsgCapsule) { } fmt.Printf( s, - string(msgCapsule.GetSignature().GetPubKey()), + fmt.Sprintf("%x", msgCapsule.GetSignature().GetPubKey()[:4]), msgCapsule.GetTimestamp(), msgCapsule.GetData(), ) From 98352c45d40081dd1b7f552548fc64b088b29e6d Mon Sep 17 00:00:00 2001 From: h0n9 Date: Thu, 8 Feb 2024 22:12:44 +0900 Subject: [PATCH 3/5] Rename lake.proto to msg-lake.proto --- proto/{lake.proto => msg-lake.proto} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename proto/{lake.proto => msg-lake.proto} (97%) diff --git a/proto/lake.proto b/proto/msg-lake.proto similarity index 97% rename from proto/lake.proto rename to proto/msg-lake.proto index aee923c..1f85057 100644 --- a/proto/lake.proto +++ b/proto/msg-lake.proto @@ -2,7 +2,7 @@ syntax = "proto3"; option go_package = "github.com/h0n9/msg-lake/proto"; -service Lake { +service MsgLake { rpc Publish(PublishReq) returns (PublishRes); rpc Subscribe(SubscribeReq) returns (stream SubscribeRes); } @@ -47,4 +47,4 @@ message MsgCapsule { message Signature { bytes pub_key = 1; bytes data = 2; -} \ No newline at end of file +} From 66b7e90b53327bb3dc8aec4fa5735ad2afcf5754 Mon Sep 17 00:00:00 2001 From: h0n9 Date: Thu, 8 Feb 2024 22:16:07 +0900 Subject: [PATCH 4/5] Rename lake*pb.go to msg-lake*pb.go --- proto/lake_grpc.pb.go | 174 --------------------- proto/{lake.pb.go => msg-lake.pb.go} | 218 +++++++++++++-------------- proto/msg-lake_grpc.pb.go | 174 +++++++++++++++++++++ 3 files changed, 283 insertions(+), 283 deletions(-) delete mode 100644 proto/lake_grpc.pb.go rename proto/{lake.pb.go => msg-lake.pb.go} (63%) create mode 100644 proto/msg-lake_grpc.pb.go diff --git a/proto/lake_grpc.pb.go b/proto/lake_grpc.pb.go deleted file mode 100644 index 7d05c42..0000000 --- a/proto/lake_grpc.pb.go +++ /dev/null @@ -1,174 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.3.0 -// - protoc v3.21.12 -// source: proto/lake.proto - -package proto - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 - -const ( - Lake_Publish_FullMethodName = "/Lake/Publish" - Lake_Subscribe_FullMethodName = "/Lake/Subscribe" -) - -// LakeClient is the client API for Lake service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type LakeClient interface { - Publish(ctx context.Context, in *PublishReq, opts ...grpc.CallOption) (*PublishRes, error) - Subscribe(ctx context.Context, in *SubscribeReq, opts ...grpc.CallOption) (Lake_SubscribeClient, error) -} - -type lakeClient struct { - cc grpc.ClientConnInterface -} - -func NewLakeClient(cc grpc.ClientConnInterface) LakeClient { - return &lakeClient{cc} -} - -func (c *lakeClient) Publish(ctx context.Context, in *PublishReq, opts ...grpc.CallOption) (*PublishRes, error) { - out := new(PublishRes) - err := c.cc.Invoke(ctx, Lake_Publish_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *lakeClient) Subscribe(ctx context.Context, in *SubscribeReq, opts ...grpc.CallOption) (Lake_SubscribeClient, error) { - stream, err := c.cc.NewStream(ctx, &Lake_ServiceDesc.Streams[0], Lake_Subscribe_FullMethodName, opts...) - if err != nil { - return nil, err - } - x := &lakeSubscribeClient{stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - return x, nil -} - -type Lake_SubscribeClient interface { - Recv() (*SubscribeRes, error) - grpc.ClientStream -} - -type lakeSubscribeClient struct { - grpc.ClientStream -} - -func (x *lakeSubscribeClient) Recv() (*SubscribeRes, error) { - m := new(SubscribeRes) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -// LakeServer is the server API for Lake service. -// All implementations must embed UnimplementedLakeServer -// for forward compatibility -type LakeServer interface { - Publish(context.Context, *PublishReq) (*PublishRes, error) - Subscribe(*SubscribeReq, Lake_SubscribeServer) error - mustEmbedUnimplementedLakeServer() -} - -// UnimplementedLakeServer must be embedded to have forward compatible implementations. -type UnimplementedLakeServer struct { -} - -func (UnimplementedLakeServer) Publish(context.Context, *PublishReq) (*PublishRes, error) { - return nil, status.Errorf(codes.Unimplemented, "method Publish not implemented") -} -func (UnimplementedLakeServer) Subscribe(*SubscribeReq, Lake_SubscribeServer) error { - return status.Errorf(codes.Unimplemented, "method Subscribe not implemented") -} -func (UnimplementedLakeServer) mustEmbedUnimplementedLakeServer() {} - -// UnsafeLakeServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to LakeServer will -// result in compilation errors. -type UnsafeLakeServer interface { - mustEmbedUnimplementedLakeServer() -} - -func RegisterLakeServer(s grpc.ServiceRegistrar, srv LakeServer) { - s.RegisterService(&Lake_ServiceDesc, srv) -} - -func _Lake_Publish_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(PublishReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(LakeServer).Publish(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Lake_Publish_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(LakeServer).Publish(ctx, req.(*PublishReq)) - } - return interceptor(ctx, in, info, handler) -} - -func _Lake_Subscribe_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(SubscribeReq) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(LakeServer).Subscribe(m, &lakeSubscribeServer{stream}) -} - -type Lake_SubscribeServer interface { - Send(*SubscribeRes) error - grpc.ServerStream -} - -type lakeSubscribeServer struct { - grpc.ServerStream -} - -func (x *lakeSubscribeServer) Send(m *SubscribeRes) error { - return x.ServerStream.SendMsg(m) -} - -// Lake_ServiceDesc is the grpc.ServiceDesc for Lake service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Lake_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "Lake", - HandlerType: (*LakeServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Publish", - Handler: _Lake_Publish_Handler, - }, - }, - Streams: []grpc.StreamDesc{ - { - StreamName: "Subscribe", - Handler: _Lake_Subscribe_Handler, - ServerStreams: true, - }, - }, - Metadata: "proto/lake.proto", -} diff --git a/proto/lake.pb.go b/proto/msg-lake.pb.go similarity index 63% rename from proto/lake.pb.go rename to proto/msg-lake.pb.go index 32d7363..1285144 100644 --- a/proto/lake.pb.go +++ b/proto/msg-lake.pb.go @@ -1,8 +1,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.30.0 -// protoc v3.21.12 -// source: proto/lake.proto +// protoc v4.25.0 +// source: msg-lake.proto package proto @@ -53,11 +53,11 @@ func (x SubscribeResType) String() string { } func (SubscribeResType) Descriptor() protoreflect.EnumDescriptor { - return file_proto_lake_proto_enumTypes[0].Descriptor() + return file_msg_lake_proto_enumTypes[0].Descriptor() } func (SubscribeResType) Type() protoreflect.EnumType { - return &file_proto_lake_proto_enumTypes[0] + return &file_msg_lake_proto_enumTypes[0] } func (x SubscribeResType) Number() protoreflect.EnumNumber { @@ -66,7 +66,7 @@ func (x SubscribeResType) Number() protoreflect.EnumNumber { // Deprecated: Use SubscribeResType.Descriptor instead. func (SubscribeResType) EnumDescriptor() ([]byte, []int) { - return file_proto_lake_proto_rawDescGZIP(), []int{0} + return file_msg_lake_proto_rawDescGZIP(), []int{0} } type PublishReq struct { @@ -81,7 +81,7 @@ type PublishReq struct { func (x *PublishReq) Reset() { *x = PublishReq{} if protoimpl.UnsafeEnabled { - mi := &file_proto_lake_proto_msgTypes[0] + mi := &file_msg_lake_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -94,7 +94,7 @@ func (x *PublishReq) String() string { func (*PublishReq) ProtoMessage() {} func (x *PublishReq) ProtoReflect() protoreflect.Message { - mi := &file_proto_lake_proto_msgTypes[0] + mi := &file_msg_lake_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -107,7 +107,7 @@ func (x *PublishReq) ProtoReflect() protoreflect.Message { // Deprecated: Use PublishReq.ProtoReflect.Descriptor instead. func (*PublishReq) Descriptor() ([]byte, []int) { - return file_proto_lake_proto_rawDescGZIP(), []int{0} + return file_msg_lake_proto_rawDescGZIP(), []int{0} } func (x *PublishReq) GetTopicId() string { @@ -136,7 +136,7 @@ type PublishRes struct { func (x *PublishRes) Reset() { *x = PublishRes{} if protoimpl.UnsafeEnabled { - mi := &file_proto_lake_proto_msgTypes[1] + mi := &file_msg_lake_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -149,7 +149,7 @@ func (x *PublishRes) String() string { func (*PublishRes) ProtoMessage() {} func (x *PublishRes) ProtoReflect() protoreflect.Message { - mi := &file_proto_lake_proto_msgTypes[1] + mi := &file_msg_lake_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -162,7 +162,7 @@ func (x *PublishRes) ProtoReflect() protoreflect.Message { // Deprecated: Use PublishRes.ProtoReflect.Descriptor instead. func (*PublishRes) Descriptor() ([]byte, []int) { - return file_proto_lake_proto_rawDescGZIP(), []int{1} + return file_msg_lake_proto_rawDescGZIP(), []int{1} } func (x *PublishRes) GetTopicId() string { @@ -191,7 +191,7 @@ type SubscribeReq struct { func (x *SubscribeReq) Reset() { *x = SubscribeReq{} if protoimpl.UnsafeEnabled { - mi := &file_proto_lake_proto_msgTypes[2] + mi := &file_msg_lake_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -204,7 +204,7 @@ func (x *SubscribeReq) String() string { func (*SubscribeReq) ProtoMessage() {} func (x *SubscribeReq) ProtoReflect() protoreflect.Message { - mi := &file_proto_lake_proto_msgTypes[2] + mi := &file_msg_lake_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -217,7 +217,7 @@ func (x *SubscribeReq) ProtoReflect() protoreflect.Message { // Deprecated: Use SubscribeReq.ProtoReflect.Descriptor instead. func (*SubscribeReq) Descriptor() ([]byte, []int) { - return file_proto_lake_proto_rawDescGZIP(), []int{2} + return file_msg_lake_proto_rawDescGZIP(), []int{2} } func (x *SubscribeReq) GetTopicId() string { @@ -252,7 +252,7 @@ type SubscribeRes struct { func (x *SubscribeRes) Reset() { *x = SubscribeRes{} if protoimpl.UnsafeEnabled { - mi := &file_proto_lake_proto_msgTypes[3] + mi := &file_msg_lake_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -265,7 +265,7 @@ func (x *SubscribeRes) String() string { func (*SubscribeRes) ProtoMessage() {} func (x *SubscribeRes) ProtoReflect() protoreflect.Message { - mi := &file_proto_lake_proto_msgTypes[3] + mi := &file_msg_lake_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -278,7 +278,7 @@ func (x *SubscribeRes) ProtoReflect() protoreflect.Message { // Deprecated: Use SubscribeRes.ProtoReflect.Descriptor instead. func (*SubscribeRes) Descriptor() ([]byte, []int) { - return file_proto_lake_proto_rawDescGZIP(), []int{3} + return file_msg_lake_proto_rawDescGZIP(), []int{3} } func (x *SubscribeRes) GetType() SubscribeResType { @@ -352,7 +352,7 @@ type MsgCapsule struct { func (x *MsgCapsule) Reset() { *x = MsgCapsule{} if protoimpl.UnsafeEnabled { - mi := &file_proto_lake_proto_msgTypes[4] + mi := &file_msg_lake_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -365,7 +365,7 @@ func (x *MsgCapsule) String() string { func (*MsgCapsule) ProtoMessage() {} func (x *MsgCapsule) ProtoReflect() protoreflect.Message { - mi := &file_proto_lake_proto_msgTypes[4] + mi := &file_msg_lake_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -378,7 +378,7 @@ func (x *MsgCapsule) ProtoReflect() protoreflect.Message { // Deprecated: Use MsgCapsule.ProtoReflect.Descriptor instead. func (*MsgCapsule) Descriptor() ([]byte, []int) { - return file_proto_lake_proto_rawDescGZIP(), []int{4} + return file_msg_lake_proto_rawDescGZIP(), []int{4} } func (x *MsgCapsule) GetData() []byte { @@ -414,7 +414,7 @@ type Signature struct { func (x *Signature) Reset() { *x = Signature{} if protoimpl.UnsafeEnabled { - mi := &file_proto_lake_proto_msgTypes[5] + mi := &file_msg_lake_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -427,7 +427,7 @@ func (x *Signature) String() string { func (*Signature) ProtoMessage() {} func (x *Signature) ProtoReflect() protoreflect.Message { - mi := &file_proto_lake_proto_msgTypes[5] + mi := &file_msg_lake_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -440,7 +440,7 @@ func (x *Signature) ProtoReflect() protoreflect.Message { // Deprecated: Use Signature.ProtoReflect.Descriptor instead. func (*Signature) Descriptor() ([]byte, []int) { - return file_proto_lake_proto_rawDescGZIP(), []int{5} + return file_msg_lake_proto_rawDescGZIP(), []int{5} } func (x *Signature) GetPubKey() []byte { @@ -457,80 +457,80 @@ func (x *Signature) GetData() []byte { return nil } -var File_proto_lake_proto protoreflect.FileDescriptor - -var file_proto_lake_proto_rawDesc = []byte{ - 0x0a, 0x10, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6c, 0x61, 0x6b, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x22, 0x55, 0x0a, 0x0a, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x52, 0x65, 0x71, +var File_msg_lake_proto protoreflect.FileDescriptor + +var file_msg_lake_proto_rawDesc = []byte{ + 0x0a, 0x0e, 0x6d, 0x73, 0x67, 0x2d, 0x6c, 0x61, 0x6b, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x22, 0x55, 0x0a, 0x0a, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x52, 0x65, 0x71, 0x12, 0x19, + 0x0a, 0x08, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x07, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x49, 0x64, 0x12, 0x2c, 0x0a, 0x0b, 0x6d, 0x73, 0x67, + 0x5f, 0x63, 0x61, 0x70, 0x73, 0x75, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, + 0x2e, 0x4d, 0x73, 0x67, 0x43, 0x61, 0x70, 0x73, 0x75, 0x6c, 0x65, 0x52, 0x0a, 0x6d, 0x73, 0x67, + 0x43, 0x61, 0x70, 0x73, 0x75, 0x6c, 0x65, 0x22, 0x37, 0x0a, 0x0a, 0x50, 0x75, 0x62, 0x6c, 0x69, + 0x73, 0x68, 0x52, 0x65, 0x73, 0x12, 0x19, 0x0a, 0x08, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x5f, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x49, 0x64, + 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02, 0x6f, 0x6b, + 0x22, 0x57, 0x0a, 0x0c, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x71, 0x12, 0x19, 0x0a, 0x08, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x49, 0x64, 0x12, 0x2c, 0x0a, 0x0b, 0x6d, 0x73, 0x67, 0x5f, 0x63, 0x61, 0x70, 0x73, 0x75, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x4d, 0x73, 0x67, 0x43, 0x61, 0x70, 0x73, 0x75, 0x6c, 0x65, 0x52, 0x0a, 0x6d, - 0x73, 0x67, 0x43, 0x61, 0x70, 0x73, 0x75, 0x6c, 0x65, 0x22, 0x37, 0x0a, 0x0a, 0x50, 0x75, 0x62, - 0x6c, 0x69, 0x73, 0x68, 0x52, 0x65, 0x73, 0x12, 0x19, 0x0a, 0x08, 0x74, 0x6f, 0x70, 0x69, 0x63, - 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x74, 0x6f, 0x70, 0x69, 0x63, - 0x49, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02, - 0x6f, 0x6b, 0x22, 0x57, 0x0a, 0x0c, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, - 0x65, 0x71, 0x12, 0x19, 0x0a, 0x08, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x49, 0x64, 0x12, 0x2c, 0x0a, - 0x0b, 0x6d, 0x73, 0x67, 0x5f, 0x63, 0x61, 0x70, 0x73, 0x75, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x4d, 0x73, 0x67, 0x43, 0x61, 0x70, 0x73, 0x75, 0x6c, 0x65, 0x52, - 0x0a, 0x6d, 0x73, 0x67, 0x43, 0x61, 0x70, 0x73, 0x75, 0x6c, 0x65, 0x22, 0xbe, 0x01, 0x0a, 0x0c, - 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x73, 0x12, 0x25, 0x0a, 0x04, - 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x11, 0x2e, 0x53, 0x75, 0x62, - 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x73, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, - 0x79, 0x70, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x5f, 0x69, 0x64, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x49, 0x64, 0x12, 0x23, - 0x0a, 0x0d, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, - 0x72, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x48, - 0x00, 0x52, 0x02, 0x6f, 0x6b, 0x12, 0x2e, 0x0a, 0x0b, 0x6d, 0x73, 0x67, 0x5f, 0x63, 0x61, 0x70, - 0x73, 0x75, 0x6c, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x4d, 0x73, 0x67, - 0x43, 0x61, 0x70, 0x73, 0x75, 0x6c, 0x65, 0x48, 0x00, 0x52, 0x0a, 0x6d, 0x73, 0x67, 0x43, 0x61, - 0x70, 0x73, 0x75, 0x6c, 0x65, 0x42, 0x05, 0x0a, 0x03, 0x72, 0x65, 0x73, 0x22, 0x68, 0x0a, 0x0a, - 0x4d, 0x73, 0x67, 0x43, 0x61, 0x70, 0x73, 0x75, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, - 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x28, - 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x0a, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x09, 0x73, - 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, - 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0x38, 0x0a, 0x09, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, - 0x75, 0x72, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x75, 0x62, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x70, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, - 0x2a, 0x70, 0x0a, 0x10, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x73, - 0x54, 0x79, 0x70, 0x65, 0x12, 0x22, 0x0a, 0x1e, 0x53, 0x55, 0x42, 0x53, 0x43, 0x52, 0x49, 0x42, - 0x45, 0x5f, 0x52, 0x45, 0x53, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, - 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x1a, 0x0a, 0x16, 0x53, 0x55, 0x42, 0x53, - 0x43, 0x52, 0x49, 0x42, 0x45, 0x5f, 0x52, 0x45, 0x53, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x41, - 0x43, 0x4b, 0x10, 0x01, 0x12, 0x1c, 0x0a, 0x18, 0x53, 0x55, 0x42, 0x53, 0x43, 0x52, 0x49, 0x42, - 0x45, 0x5f, 0x52, 0x45, 0x53, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x52, 0x45, 0x4c, 0x41, 0x59, - 0x10, 0x02, 0x32, 0x58, 0x0a, 0x04, 0x4c, 0x61, 0x6b, 0x65, 0x12, 0x23, 0x0a, 0x07, 0x50, 0x75, - 0x62, 0x6c, 0x69, 0x73, 0x68, 0x12, 0x0b, 0x2e, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x52, - 0x65, 0x71, 0x1a, 0x0b, 0x2e, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x52, 0x65, 0x73, 0x12, - 0x2b, 0x0a, 0x09, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x12, 0x0d, 0x2e, 0x53, - 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x0d, 0x2e, 0x53, 0x75, - 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x73, 0x30, 0x01, 0x42, 0x20, 0x5a, 0x1e, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x30, 0x6e, 0x39, 0x2f, - 0x6d, 0x73, 0x67, 0x2d, 0x6c, 0x61, 0x6b, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x67, 0x43, 0x61, 0x70, 0x73, 0x75, 0x6c, 0x65, 0x22, 0xbe, 0x01, 0x0a, 0x0c, 0x53, 0x75, + 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x73, 0x12, 0x25, 0x0a, 0x04, 0x74, 0x79, + 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x11, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, + 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x73, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, + 0x65, 0x12, 0x19, 0x0a, 0x08, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, + 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 0x49, + 0x64, 0x12, 0x10, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, + 0x02, 0x6f, 0x6b, 0x12, 0x2e, 0x0a, 0x0b, 0x6d, 0x73, 0x67, 0x5f, 0x63, 0x61, 0x70, 0x73, 0x75, + 0x6c, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x4d, 0x73, 0x67, 0x43, 0x61, + 0x70, 0x73, 0x75, 0x6c, 0x65, 0x48, 0x00, 0x52, 0x0a, 0x6d, 0x73, 0x67, 0x43, 0x61, 0x70, 0x73, + 0x75, 0x6c, 0x65, 0x42, 0x05, 0x0a, 0x03, 0x72, 0x65, 0x73, 0x22, 0x68, 0x0a, 0x0a, 0x4d, 0x73, + 0x67, 0x43, 0x61, 0x70, 0x73, 0x75, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x28, 0x0a, 0x09, + 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0a, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x09, 0x73, 0x69, 0x67, + 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x22, 0x38, 0x0a, 0x09, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, + 0x65, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x75, 0x62, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x06, 0x70, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, + 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x2a, 0x70, + 0x0a, 0x10, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x73, 0x54, 0x79, + 0x70, 0x65, 0x12, 0x22, 0x0a, 0x1e, 0x53, 0x55, 0x42, 0x53, 0x43, 0x52, 0x49, 0x42, 0x45, 0x5f, + 0x52, 0x45, 0x53, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, + 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x1a, 0x0a, 0x16, 0x53, 0x55, 0x42, 0x53, 0x43, 0x52, + 0x49, 0x42, 0x45, 0x5f, 0x52, 0x45, 0x53, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x41, 0x43, 0x4b, + 0x10, 0x01, 0x12, 0x1c, 0x0a, 0x18, 0x53, 0x55, 0x42, 0x53, 0x43, 0x52, 0x49, 0x42, 0x45, 0x5f, + 0x52, 0x45, 0x53, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x52, 0x45, 0x4c, 0x41, 0x59, 0x10, 0x02, + 0x32, 0x5b, 0x0a, 0x07, 0x4d, 0x73, 0x67, 0x4c, 0x61, 0x6b, 0x65, 0x12, 0x23, 0x0a, 0x07, 0x50, + 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x12, 0x0b, 0x2e, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, + 0x52, 0x65, 0x71, 0x1a, 0x0b, 0x2e, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x52, 0x65, 0x73, + 0x12, 0x2b, 0x0a, 0x09, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x12, 0x0d, 0x2e, + 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x0d, 0x2e, 0x53, + 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x73, 0x30, 0x01, 0x42, 0x20, 0x5a, + 0x1e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x30, 0x6e, 0x39, + 0x2f, 0x6d, 0x73, 0x67, 0x2d, 0x6c, 0x61, 0x6b, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_proto_lake_proto_rawDescOnce sync.Once - file_proto_lake_proto_rawDescData = file_proto_lake_proto_rawDesc + file_msg_lake_proto_rawDescOnce sync.Once + file_msg_lake_proto_rawDescData = file_msg_lake_proto_rawDesc ) -func file_proto_lake_proto_rawDescGZIP() []byte { - file_proto_lake_proto_rawDescOnce.Do(func() { - file_proto_lake_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_lake_proto_rawDescData) +func file_msg_lake_proto_rawDescGZIP() []byte { + file_msg_lake_proto_rawDescOnce.Do(func() { + file_msg_lake_proto_rawDescData = protoimpl.X.CompressGZIP(file_msg_lake_proto_rawDescData) }) - return file_proto_lake_proto_rawDescData + return file_msg_lake_proto_rawDescData } -var file_proto_lake_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_proto_lake_proto_msgTypes = make([]protoimpl.MessageInfo, 6) -var file_proto_lake_proto_goTypes = []interface{}{ +var file_msg_lake_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_msg_lake_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_msg_lake_proto_goTypes = []interface{}{ (SubscribeResType)(0), // 0: SubscribeResType (*PublishReq)(nil), // 1: PublishReq (*PublishRes)(nil), // 2: PublishRes @@ -539,16 +539,16 @@ var file_proto_lake_proto_goTypes = []interface{}{ (*MsgCapsule)(nil), // 5: MsgCapsule (*Signature)(nil), // 6: Signature } -var file_proto_lake_proto_depIdxs = []int32{ +var file_msg_lake_proto_depIdxs = []int32{ 5, // 0: PublishReq.msg_capsule:type_name -> MsgCapsule 5, // 1: SubscribeReq.msg_capsule:type_name -> MsgCapsule 0, // 2: SubscribeRes.type:type_name -> SubscribeResType 5, // 3: SubscribeRes.msg_capsule:type_name -> MsgCapsule 6, // 4: MsgCapsule.signature:type_name -> Signature - 1, // 5: Lake.Publish:input_type -> PublishReq - 3, // 6: Lake.Subscribe:input_type -> SubscribeReq - 2, // 7: Lake.Publish:output_type -> PublishRes - 4, // 8: Lake.Subscribe:output_type -> SubscribeRes + 1, // 5: MsgLake.Publish:input_type -> PublishReq + 3, // 6: MsgLake.Subscribe:input_type -> SubscribeReq + 2, // 7: MsgLake.Publish:output_type -> PublishRes + 4, // 8: MsgLake.Subscribe:output_type -> SubscribeRes 7, // [7:9] is the sub-list for method output_type 5, // [5:7] is the sub-list for method input_type 5, // [5:5] is the sub-list for extension type_name @@ -556,13 +556,13 @@ var file_proto_lake_proto_depIdxs = []int32{ 0, // [0:5] is the sub-list for field type_name } -func init() { file_proto_lake_proto_init() } -func file_proto_lake_proto_init() { - if File_proto_lake_proto != nil { +func init() { file_msg_lake_proto_init() } +func file_msg_lake_proto_init() { + if File_msg_lake_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_proto_lake_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_msg_lake_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*PublishReq); i { case 0: return &v.state @@ -574,7 +574,7 @@ func file_proto_lake_proto_init() { return nil } } - file_proto_lake_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_msg_lake_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*PublishRes); i { case 0: return &v.state @@ -586,7 +586,7 @@ func file_proto_lake_proto_init() { return nil } } - file_proto_lake_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_msg_lake_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*SubscribeReq); i { case 0: return &v.state @@ -598,7 +598,7 @@ func file_proto_lake_proto_init() { return nil } } - file_proto_lake_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_msg_lake_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*SubscribeRes); i { case 0: return &v.state @@ -610,7 +610,7 @@ func file_proto_lake_proto_init() { return nil } } - file_proto_lake_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_msg_lake_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*MsgCapsule); i { case 0: return &v.state @@ -622,7 +622,7 @@ func file_proto_lake_proto_init() { return nil } } - file_proto_lake_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_msg_lake_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Signature); i { case 0: return &v.state @@ -635,7 +635,7 @@ func file_proto_lake_proto_init() { } } } - file_proto_lake_proto_msgTypes[3].OneofWrappers = []interface{}{ + file_msg_lake_proto_msgTypes[3].OneofWrappers = []interface{}{ (*SubscribeRes_Ok)(nil), (*SubscribeRes_MsgCapsule)(nil), } @@ -643,19 +643,19 @@ func file_proto_lake_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_proto_lake_proto_rawDesc, + RawDescriptor: file_msg_lake_proto_rawDesc, NumEnums: 1, NumMessages: 6, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_proto_lake_proto_goTypes, - DependencyIndexes: file_proto_lake_proto_depIdxs, - EnumInfos: file_proto_lake_proto_enumTypes, - MessageInfos: file_proto_lake_proto_msgTypes, + GoTypes: file_msg_lake_proto_goTypes, + DependencyIndexes: file_msg_lake_proto_depIdxs, + EnumInfos: file_msg_lake_proto_enumTypes, + MessageInfos: file_msg_lake_proto_msgTypes, }.Build() - File_proto_lake_proto = out.File - file_proto_lake_proto_rawDesc = nil - file_proto_lake_proto_goTypes = nil - file_proto_lake_proto_depIdxs = nil + File_msg_lake_proto = out.File + file_msg_lake_proto_rawDesc = nil + file_msg_lake_proto_goTypes = nil + file_msg_lake_proto_depIdxs = nil } diff --git a/proto/msg-lake_grpc.pb.go b/proto/msg-lake_grpc.pb.go new file mode 100644 index 0000000..b0acd44 --- /dev/null +++ b/proto/msg-lake_grpc.pb.go @@ -0,0 +1,174 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc v4.25.0 +// source: msg-lake.proto + +package proto + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + MsgLake_Publish_FullMethodName = "/MsgLake/Publish" + MsgLake_Subscribe_FullMethodName = "/MsgLake/Subscribe" +) + +// MsgLakeClient is the client API for MsgLake service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type MsgLakeClient interface { + Publish(ctx context.Context, in *PublishReq, opts ...grpc.CallOption) (*PublishRes, error) + Subscribe(ctx context.Context, in *SubscribeReq, opts ...grpc.CallOption) (MsgLake_SubscribeClient, error) +} + +type msgLakeClient struct { + cc grpc.ClientConnInterface +} + +func NewMsgLakeClient(cc grpc.ClientConnInterface) MsgLakeClient { + return &msgLakeClient{cc} +} + +func (c *msgLakeClient) Publish(ctx context.Context, in *PublishReq, opts ...grpc.CallOption) (*PublishRes, error) { + out := new(PublishRes) + err := c.cc.Invoke(ctx, MsgLake_Publish_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgLakeClient) Subscribe(ctx context.Context, in *SubscribeReq, opts ...grpc.CallOption) (MsgLake_SubscribeClient, error) { + stream, err := c.cc.NewStream(ctx, &MsgLake_ServiceDesc.Streams[0], MsgLake_Subscribe_FullMethodName, opts...) + if err != nil { + return nil, err + } + x := &msgLakeSubscribeClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type MsgLake_SubscribeClient interface { + Recv() (*SubscribeRes, error) + grpc.ClientStream +} + +type msgLakeSubscribeClient struct { + grpc.ClientStream +} + +func (x *msgLakeSubscribeClient) Recv() (*SubscribeRes, error) { + m := new(SubscribeRes) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// MsgLakeServer is the server API for MsgLake service. +// All implementations must embed UnimplementedMsgLakeServer +// for forward compatibility +type MsgLakeServer interface { + Publish(context.Context, *PublishReq) (*PublishRes, error) + Subscribe(*SubscribeReq, MsgLake_SubscribeServer) error + mustEmbedUnimplementedMsgLakeServer() +} + +// UnimplementedMsgLakeServer must be embedded to have forward compatible implementations. +type UnimplementedMsgLakeServer struct { +} + +func (UnimplementedMsgLakeServer) Publish(context.Context, *PublishReq) (*PublishRes, error) { + return nil, status.Errorf(codes.Unimplemented, "method Publish not implemented") +} +func (UnimplementedMsgLakeServer) Subscribe(*SubscribeReq, MsgLake_SubscribeServer) error { + return status.Errorf(codes.Unimplemented, "method Subscribe not implemented") +} +func (UnimplementedMsgLakeServer) mustEmbedUnimplementedMsgLakeServer() {} + +// UnsafeMsgLakeServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to MsgLakeServer will +// result in compilation errors. +type UnsafeMsgLakeServer interface { + mustEmbedUnimplementedMsgLakeServer() +} + +func RegisterMsgLakeServer(s grpc.ServiceRegistrar, srv MsgLakeServer) { + s.RegisterService(&MsgLake_ServiceDesc, srv) +} + +func _MsgLake_Publish_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PublishReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgLakeServer).Publish(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: MsgLake_Publish_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgLakeServer).Publish(ctx, req.(*PublishReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _MsgLake_Subscribe_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(SubscribeReq) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(MsgLakeServer).Subscribe(m, &msgLakeSubscribeServer{stream}) +} + +type MsgLake_SubscribeServer interface { + Send(*SubscribeRes) error + grpc.ServerStream +} + +type msgLakeSubscribeServer struct { + grpc.ServerStream +} + +func (x *msgLakeSubscribeServer) Send(m *SubscribeRes) error { + return x.ServerStream.SendMsg(m) +} + +// MsgLake_ServiceDesc is the grpc.ServiceDesc for MsgLake service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var MsgLake_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "MsgLake", + HandlerType: (*MsgLakeServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Publish", + Handler: _MsgLake_Publish_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "Subscribe", + Handler: _MsgLake_Subscribe_Handler, + ServerStreams: true, + }, + }, + Metadata: "msg-lake.proto", +} From 5ff69d1c257286dd8a94d19c73d8117f09f47bd8 Mon Sep 17 00:00:00 2001 From: h0n9 Date: Thu, 8 Feb 2024 22:17:11 +0900 Subject: [PATCH 5/5] Update gRPC service registration and client instantiation --- cli/agent/agent.go | 2 +- cli/client/client.go | 2 +- lake/lake.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cli/agent/agent.go b/cli/agent/agent.go index 93700a1..8867e40 100644 --- a/cli/agent/agent.go +++ b/cli/agent/agent.go @@ -95,7 +95,7 @@ var Cmd = &cobra.Command{ } logger.Info().Msg("initalized lake service") - pb.RegisterLakeServer(grpcServer, lakeService) + pb.RegisterMsgLakeServer(grpcServer, lakeService) logger.Info().Msg("registered lake service to gRPC server") listener, err := net.Listen("tcp", grpcListenAddr) diff --git a/cli/client/client.go b/cli/client/client.go index 82881fc..5680b81 100644 --- a/cli/client/client.go +++ b/cli/client/client.go @@ -88,7 +88,7 @@ var Cmd = &cobra.Command{ if err != nil { return err } - cli := pb.NewLakeClient(conn) + cli := pb.NewMsgLakeClient(conn) msg := Msg{ Data: []byte(topicID), diff --git a/lake/lake.go b/lake/lake.go index e1ad30a..899717c 100644 --- a/lake/lake.go +++ b/lake/lake.go @@ -22,7 +22,7 @@ const ( ) type Service struct { - pb.UnimplementedLakeServer + pb.UnimplementedMsgLakeServer ctx context.Context logger *zerolog.Logger @@ -96,7 +96,7 @@ func (service *Service) Publish(ctx context.Context, req *pb.PublishReq) (*pb.Pu return &publishRes, nil } -func (service *Service) Subscribe(req *pb.SubscribeReq, stream pb.Lake_SubscribeServer) error { +func (service *Service) Subscribe(req *pb.SubscribeReq, stream pb.MsgLake_SubscribeServer) error { service.logger.Debug(). Str("topic-id", req.GetTopicId()). Msg("begin of subscribe stream")