diff --git a/common/idl/domain/msg/msg_dto.pb.go b/common/idl/domain/msg/msg_dto.pb.go new file mode 100644 index 0000000..e6503aa --- /dev/null +++ b/common/idl/domain/msg/msg_dto.pb.go @@ -0,0 +1,302 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.21.1 +// source: msg_dto.proto + +//protoc --go-grpc_out=. --go_out=. ./common/idl/domain/msg/msg_dto.proto + +package msg + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type MsgDTO struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SendID string `protobuf:"bytes,1,opt,name=sendID,proto3" json:"sendID,omitempty"` + RecvID string `protobuf:"bytes,2,opt,name=recvID,proto3" json:"recvID,omitempty"` + GroupID string `protobuf:"bytes,3,opt,name=groupID,proto3" json:"groupID,omitempty"` + ClientMsgID string `protobuf:"bytes,4,opt,name=clientMsgID,proto3" json:"clientMsgID,omitempty"` + ServerMsgID string `protobuf:"bytes,5,opt,name=ServerMsgID,proto3" json:"ServerMsgID,omitempty"` + SenderPlatformID int32 `protobuf:"varint,6,opt,name=senderPlatformID,proto3" json:"senderPlatformID,omitempty"` + SenderNickname string `protobuf:"bytes,7,opt,name=senderNickname,proto3" json:"senderNickname,omitempty"` + SenderFaceURL string `protobuf:"bytes,8,opt,name=senderFaceURL,proto3" json:"senderFaceURL,omitempty"` + SessionType int32 `protobuf:"varint,9,opt,name=sessionType,proto3" json:"sessionType,omitempty"` + MsgFrom int32 `protobuf:"varint,10,opt,name=msgFrom,proto3" json:"msgFrom,omitempty"` + ContentType int32 `protobuf:"varint,11,opt,name=ContentType,proto3" json:"ContentType,omitempty"` + Content []byte `protobuf:"bytes,12,opt,name=Content,proto3" json:"Content,omitempty"` + Seq int64 `protobuf:"varint,13,opt,name=Seq,proto3" json:"Seq,omitempty"` + SendTime int64 `protobuf:"varint,14,opt,name=SendTime,proto3" json:"SendTime,omitempty"` + CreateTime int64 `protobuf:"varint,15,opt,name=CreateTime,proto3" json:"CreateTime,omitempty"` + Status int32 `protobuf:"varint,16,opt,name=Status,proto3" json:"Status,omitempty"` + IsRead bool `protobuf:"varint,17,opt,name=IsRead,proto3" json:"IsRead,omitempty"` +} + +func (x *MsgDTO) Reset() { + *x = MsgDTO{} + if protoimpl.UnsafeEnabled { + mi := &file_msg_dto_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MsgDTO) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MsgDTO) ProtoMessage() {} + +func (x *MsgDTO) ProtoReflect() protoreflect.Message { + mi := &file_msg_dto_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MsgDTO.ProtoReflect.Descriptor instead. +func (*MsgDTO) Descriptor() ([]byte, []int) { + return file_msg_dto_proto_rawDescGZIP(), []int{0} +} + +func (x *MsgDTO) GetSendID() string { + if x != nil { + return x.SendID + } + return "" +} + +func (x *MsgDTO) GetRecvID() string { + if x != nil { + return x.RecvID + } + return "" +} + +func (x *MsgDTO) GetGroupID() string { + if x != nil { + return x.GroupID + } + return "" +} + +func (x *MsgDTO) GetClientMsgID() string { + if x != nil { + return x.ClientMsgID + } + return "" +} + +func (x *MsgDTO) GetServerMsgID() string { + if x != nil { + return x.ServerMsgID + } + return "" +} + +func (x *MsgDTO) GetSenderPlatformID() int32 { + if x != nil { + return x.SenderPlatformID + } + return 0 +} + +func (x *MsgDTO) GetSenderNickname() string { + if x != nil { + return x.SenderNickname + } + return "" +} + +func (x *MsgDTO) GetSenderFaceURL() string { + if x != nil { + return x.SenderFaceURL + } + return "" +} + +func (x *MsgDTO) GetSessionType() int32 { + if x != nil { + return x.SessionType + } + return 0 +} + +func (x *MsgDTO) GetMsgFrom() int32 { + if x != nil { + return x.MsgFrom + } + return 0 +} + +func (x *MsgDTO) GetContentType() int32 { + if x != nil { + return x.ContentType + } + return 0 +} + +func (x *MsgDTO) GetContent() []byte { + if x != nil { + return x.Content + } + return nil +} + +func (x *MsgDTO) GetSeq() int64 { + if x != nil { + return x.Seq + } + return 0 +} + +func (x *MsgDTO) GetSendTime() int64 { + if x != nil { + return x.SendTime + } + return 0 +} + +func (x *MsgDTO) GetCreateTime() int64 { + if x != nil { + return x.CreateTime + } + return 0 +} + +func (x *MsgDTO) GetStatus() int32 { + if x != nil { + return x.Status + } + return 0 +} + +func (x *MsgDTO) GetIsRead() bool { + if x != nil { + return x.IsRead + } + return false +} + +var File_msg_dto_proto protoreflect.FileDescriptor + +var file_msg_dto_proto_rawDesc = []byte{ + 0x0a, 0x0d, 0x6d, 0x73, 0x67, 0x5f, 0x64, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 0x03, 0x6d, 0x73, 0x67, 0x22, 0x86, 0x04, 0x0a, 0x06, 0x6d, 0x73, 0x67, 0x44, 0x54, 0x4f, 0x12, + 0x16, 0x0a, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x73, 0x65, 0x6e, 0x64, 0x49, 0x44, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x63, 0x76, 0x49, + 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x63, 0x76, 0x49, 0x44, 0x12, + 0x18, 0x0a, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x44, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x44, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6c, 0x69, + 0x65, 0x6e, 0x74, 0x4d, 0x73, 0x67, 0x49, 0x44, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, + 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4d, 0x73, 0x67, 0x49, 0x44, 0x12, 0x20, 0x0a, 0x0b, 0x53, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x4d, 0x73, 0x67, 0x49, 0x44, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0b, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4d, 0x73, 0x67, 0x49, 0x44, 0x12, 0x2a, 0x0a, + 0x10, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x49, + 0x44, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x50, + 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x49, 0x44, 0x12, 0x26, 0x0a, 0x0e, 0x73, 0x65, 0x6e, + 0x64, 0x65, 0x72, 0x4e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0e, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x4e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x46, 0x61, 0x63, 0x65, 0x55, + 0x52, 0x4c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, + 0x46, 0x61, 0x63, 0x65, 0x55, 0x52, 0x4c, 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x65, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x73, 0x65, + 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x73, 0x67, + 0x46, 0x72, 0x6f, 0x6d, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x6d, 0x73, 0x67, 0x46, + 0x72, 0x6f, 0x6d, 0x12, 0x20, 0x0a, 0x0b, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, + 0x70, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, + 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, + 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, + 0x10, 0x0a, 0x03, 0x53, 0x65, 0x71, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x53, 0x65, + 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x53, 0x65, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x0e, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x08, 0x53, 0x65, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1e, 0x0a, + 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x0f, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x16, 0x0a, + 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x10, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x73, 0x52, 0x65, 0x61, 0x64, 0x18, + 0x11, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x49, 0x73, 0x52, 0x65, 0x61, 0x64, 0x42, 0x17, 0x5a, + 0x15, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x69, 0x64, 0x6c, 0x2f, 0x64, 0x6f, 0x6d, 0x61, + 0x69, 0x6e, 0x2f, 0x6d, 0x73, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_msg_dto_proto_rawDescOnce sync.Once + file_msg_dto_proto_rawDescData = file_msg_dto_proto_rawDesc +) + +func file_msg_dto_proto_rawDescGZIP() []byte { + file_msg_dto_proto_rawDescOnce.Do(func() { + file_msg_dto_proto_rawDescData = protoimpl.X.CompressGZIP(file_msg_dto_proto_rawDescData) + }) + return file_msg_dto_proto_rawDescData +} + +var file_msg_dto_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_msg_dto_proto_goTypes = []interface{}{ + (*MsgDTO)(nil), // 0: msg.msgDTO +} +var file_msg_dto_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_msg_dto_proto_init() } +func file_msg_dto_proto_init() { + if File_msg_dto_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_msg_dto_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MsgDTO); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_msg_dto_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_msg_dto_proto_goTypes, + DependencyIndexes: file_msg_dto_proto_depIdxs, + MessageInfos: file_msg_dto_proto_msgTypes, + }.Build() + File_msg_dto_proto = out.File + file_msg_dto_proto_rawDesc = nil + file_msg_dto_proto_goTypes = nil + file_msg_dto_proto_depIdxs = nil +} diff --git a/common/idl/domain/msg/msg_dto.proto b/common/idl/domain/msg/msg_dto.proto new file mode 100644 index 0000000..30e1135 --- /dev/null +++ b/common/idl/domain/msg/msg_dto.proto @@ -0,0 +1,25 @@ +syntax = "proto3"; + +option go_package = "common/idl/domain/msg"; +//protoc --go-grpc_out=. --go_out=. ./common/idl/domain/msg/msg_dto.proto +package msg; + +message msgDTO { + string sendID = 1; + string recvID = 2; + string groupID = 3; + string clientMsgID = 4; + string ServerMsgID = 5; + int32 senderPlatformID = 6; + string senderNickname = 7; + string senderFaceURL = 8; + int32 sessionType = 9; + int32 msgFrom = 10; + int32 ContentType = 11; + bytes Content = 12; + int64 Seq = 13; + int64 SendTime = 14; + int64 CreateTime = 15; + int32 Status = 16; + bool IsRead = 17; +} \ No newline at end of file diff --git a/common/idl/message/message.pb.go b/common/idl/message/message.pb.go index c7b777a..cb99968 100644 --- a/common/idl/message/message.pb.go +++ b/common/idl/message/message.pb.go @@ -2,7 +2,7 @@ // versions: // protoc-gen-go v1.31.0 // protoc v3.6.1 -// source: message/message.proto +// source: msg/msg.proto package message @@ -20,7 +20,7 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// cd common/idl; protoc -I message --go_out=plugins=grpc:message message/message.proto +// cd common/idl; protoc -I msg --go_out=plugins=grpc:msg msg/msg.proto type CmdType int32 const ( @@ -85,7 +85,7 @@ type MsgCmd struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Type CmdType `protobuf:"varint,1,opt,name=Type,proto3,enum=message.CmdType" json:"Type,omitempty"` + Type CmdType `protobuf:"varint,1,opt,name=Type,proto3,enum=msg.CmdType" json:"Type,omitempty"` Payload []byte `protobuf:"bytes,2,opt,name=Payload,proto3" json:"Payload,omitempty"` } @@ -326,7 +326,7 @@ type ACKMsg struct { Code uint32 `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"` Msg string `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"` - Type CmdType `protobuf:"varint,3,opt,name=Type,proto3,enum=message.CmdType" json:"Type,omitempty"` + Type CmdType `protobuf:"varint,3,opt,name=Type,proto3,enum=msg.CmdType" json:"Type,omitempty"` ConnID uint64 `protobuf:"varint,4,opt,name=ConnID,proto3" json:"ConnID,omitempty"` ClientID uint64 `protobuf:"varint,5,opt,name=ClientID,proto3" json:"ClientID,omitempty"` SessionID uint64 `protobuf:"varint,6,opt,name=SessionID,proto3" json:"SessionID,omitempty"` @@ -800,26 +800,26 @@ func file_message_message_proto_rawDescGZIP() []byte { var file_message_message_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_message_message_proto_msgTypes = make([]protoimpl.MessageInfo, 11) var file_message_message_proto_goTypes = []interface{}{ - (CmdType)(0), // 0: message.CmdType - (*MsgCmd)(nil), // 1: message.MsgCmd - (*UPMsg)(nil), // 2: message.UPMsg - (*UPMsgHead)(nil), // 3: message.UPMsgHead - (*PushMsg)(nil), // 4: message.PushMsg - (*ACKMsg)(nil), // 5: message.ACKMsg - (*LoginMsgHead)(nil), // 6: message.LoginMsgHead - (*LoginMsg)(nil), // 7: message.LoginMsg - (*HeartbeatMsgHead)(nil), // 8: message.HeartbeatMsgHead - (*HeartbeatMsg)(nil), // 9: message.HeartbeatMsg - (*ReConnMsgHead)(nil), // 10: message.ReConnMsgHead - (*ReConnMsg)(nil), // 11: message.ReConnMsg + (CmdType)(0), // 0: msg.CmdType + (*MsgCmd)(nil), // 1: msg.MsgCmd + (*UPMsg)(nil), // 2: msg.UPMsg + (*UPMsgHead)(nil), // 3: msg.UPMsgHead + (*PushMsg)(nil), // 4: msg.PushMsg + (*ACKMsg)(nil), // 5: msg.ACKMsg + (*LoginMsgHead)(nil), // 6: msg.LoginMsgHead + (*LoginMsg)(nil), // 7: msg.LoginMsg + (*HeartbeatMsgHead)(nil), // 8: msg.HeartbeatMsgHead + (*HeartbeatMsg)(nil), // 9: msg.HeartbeatMsg + (*ReConnMsgHead)(nil), // 10: msg.ReConnMsgHead + (*ReConnMsg)(nil), // 11: msg.ReConnMsg } var file_message_message_proto_depIdxs = []int32{ - 0, // 0: message.MsgCmd.Type:type_name -> message.CmdType - 3, // 1: message.UPMsg.Head:type_name -> message.UPMsgHead - 0, // 2: message.ACKMsg.Type:type_name -> message.CmdType - 6, // 3: message.LoginMsg.Head:type_name -> message.LoginMsgHead - 8, // 4: message.HeartbeatMsg.Head:type_name -> message.HeartbeatMsgHead - 10, // 5: message.ReConnMsg.Head:type_name -> message.ReConnMsgHead + 0, // 0: msg.MsgCmd.Type:type_name -> msg.CmdType + 3, // 1: msg.UPMsg.Head:type_name -> msg.UPMsgHead + 0, // 2: msg.ACKMsg.Type:type_name -> msg.CmdType + 6, // 3: msg.LoginMsg.Head:type_name -> msg.LoginMsgHead + 8, // 4: msg.HeartbeatMsg.Head:type_name -> msg.HeartbeatMsgHead + 10, // 5: msg.ReConnMsg.Head:type_name -> msg.ReConnMsgHead 6, // [6:6] is the sub-list for method output_type 6, // [6:6] is the sub-list for method input_type 6, // [6:6] is the sub-list for extension type_name diff --git a/common/idl/message/message.proto b/common/idl/message/message.proto index e0b53f0..0a085d2 100644 --- a/common/idl/message/message.proto +++ b/common/idl/message/message.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -option go_package = "./;message"; +option go_package = "./;msg"; package message; // cd common/idl; protoc -I message --go_out=plugins=grpc:message message/message.proto diff --git a/common/prpc/example/helloservice/helloworld.pb.go b/common/prpc/example/helloservice/helloworld.pb.go index 2a9cd5c..7284f63 100644 --- a/common/prpc/example/helloservice/helloworld.pb.go +++ b/common/prpc/example/helloservice/helloworld.pb.go @@ -23,7 +23,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package -// The request message containing the user's name. +// The request msg containing the user's name. type HelloRequest struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -63,9 +63,9 @@ func (m *HelloRequest) GetName() string { return "" } -// The response message containing the greetings +// The response msg containing the greetings type HelloReply struct { - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + Message string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` diff --git a/common/prpc/trace/attr.go b/common/prpc/trace/attr.go index 73c6c4f..ec68ad4 100644 --- a/common/prpc/trace/attr.go +++ b/common/prpc/trace/attr.go @@ -9,17 +9,17 @@ import ( const ( // GRPCStatusCodeKey is convention for numeric status code of a gRPC request. GRPCStatusCodeKey = attribute.Key("rpc.grpc.status_code") - // RPCNameKey is the name of message transmitted or received. + // RPCNameKey is the name of msg transmitted or received. RPCNameKey = attribute.Key("name") - // RPCMessageTypeKey is the type of message transmitted or received. - RPCMessageTypeKey = attribute.Key("message.type") - // RPCMessageIDKey is the identifier of message transmitted or received. - RPCMessageIDKey = attribute.Key("message.id") - // RPCMessageCompressedSizeKey is the compressed size of the message transmitted or received in bytes. - RPCMessageCompressedSizeKey = attribute.Key("message.compressed_size") - // RPCMessageUncompressedSizeKey is the uncompressed size of the message + // RPCMessageTypeKey is the type of msg transmitted or received. + RPCMessageTypeKey = attribute.Key("msg.type") + // RPCMessageIDKey is the identifier of msg transmitted or received. + RPCMessageIDKey = attribute.Key("msg.id") + // RPCMessageCompressedSizeKey is the compressed size of the msg transmitted or received in bytes. + RPCMessageCompressedSizeKey = attribute.Key("msg.compressed_size") + // RPCMessageUncompressedSizeKey is the uncompressed size of the msg // transmitted or received in bytes. - RPCMessageUncompressedSizeKey = attribute.Key("message.uncompressed_size") + RPCMessageUncompressedSizeKey = attribute.Key("msg.uncompressed_size") // ServerEnvironment ... ServerEnvironment = attribute.Key("environment") ) @@ -28,11 +28,11 @@ const ( var ( // RPCSystemGRPC is the semantic convention for gRPC as the remoting system. RPCSystemGRPC = semconv.RPCSystemKey.String("grpc") - // RPCNameMessage is the semantic convention for a message named message. - RPCNameMessage = RPCNameKey.String("message") - // RPCMessageTypeSent is the semantic conventions for sent RPC message types. + // RPCNameMessage is the semantic convention for a msg named msg. + RPCNameMessage = RPCNameKey.String("msg") + // RPCMessageTypeSent is the semantic conventions for sent RPC msg types. RPCMessageTypeSent = RPCMessageTypeKey.String("SENT") - // RPCMessageTypeReceived is the semantic conventions for the received RPC message types. + // RPCMessageTypeReceived is the semantic conventions for the received RPC msg types. RPCMessageTypeReceived = RPCMessageTypeKey.String("RECEIVED") ) diff --git a/common/sdk/api.go b/common/sdk/api.go index 01a648a..2aa8d58 100644 --- a/common/sdk/api.go +++ b/common/sdk/api.go @@ -74,7 +74,7 @@ func (chat *Chat) GetCurClientID() uint64 { return 0 } -//Close close chat +// Close close chat func (chat *Chat) Close() { chat.conn.close() close(chat.closeChan) @@ -91,7 +91,7 @@ func (chat *Chat) ReConn() { chat.reConn() } -//Recv receive message +// Recv receive msg func (chat *Chat) Recv() <-chan *Message { return chat.conn.recv() } diff --git a/domain/msg/rpc/service/msg.pb.go b/domain/msg/rpc/service/msg.pb.go new file mode 100644 index 0000000..31c51c4 --- /dev/null +++ b/domain/msg/rpc/service/msg.pb.go @@ -0,0 +1,241 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.21.1 +// source: domain/msg/rpc/service/msg.proto + +package service + +import ( + _ "common/idl/base" + msg "common/idl/domain/msg" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type SendMsgReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + MsgData *msg.MsgDTO `protobuf:"bytes,1,opt,name=msgData,proto3" json:"msgData,omitempty"` +} + +func (x *SendMsgReq) Reset() { + *x = SendMsgReq{} + if protoimpl.UnsafeEnabled { + mi := &file_domain_msg_rpc_service_msg_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SendMsgReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SendMsgReq) ProtoMessage() {} + +func (x *SendMsgReq) ProtoReflect() protoreflect.Message { + mi := &file_domain_msg_rpc_service_msg_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SendMsgReq.ProtoReflect.Descriptor instead. +func (*SendMsgReq) Descriptor() ([]byte, []int) { + return file_domain_msg_rpc_service_msg_proto_rawDescGZIP(), []int{0} +} + +func (x *SendMsgReq) GetMsgData() *msg.MsgDTO { + if x != nil { + return x.MsgData + } + return nil +} + +type SendMsgResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ServerMsgID string `protobuf:"bytes,1,opt,name=serverMsgID,proto3" json:"serverMsgID,omitempty"` + ClientMsgID string `protobuf:"bytes,2,opt,name=clientMsgID,proto3" json:"clientMsgID,omitempty"` + SendTime int64 `protobuf:"varint,3,opt,name=sendTime,proto3" json:"sendTime,omitempty"` +} + +func (x *SendMsgResp) Reset() { + *x = SendMsgResp{} + if protoimpl.UnsafeEnabled { + mi := &file_domain_msg_rpc_service_msg_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SendMsgResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SendMsgResp) ProtoMessage() {} + +func (x *SendMsgResp) ProtoReflect() protoreflect.Message { + mi := &file_domain_msg_rpc_service_msg_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SendMsgResp.ProtoReflect.Descriptor instead. +func (*SendMsgResp) Descriptor() ([]byte, []int) { + return file_domain_msg_rpc_service_msg_proto_rawDescGZIP(), []int{1} +} + +func (x *SendMsgResp) GetServerMsgID() string { + if x != nil { + return x.ServerMsgID + } + return "" +} + +func (x *SendMsgResp) GetClientMsgID() string { + if x != nil { + return x.ClientMsgID + } + return "" +} + +func (x *SendMsgResp) GetSendTime() int64 { + if x != nil { + return x.SendTime + } + return 0 +} + +var File_domain_msg_rpc_service_msg_proto protoreflect.FileDescriptor + +var file_domain_msg_rpc_service_msg_proto_rawDesc = []byte{ + 0x0a, 0x20, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2f, 0x6d, 0x73, 0x67, 0x2f, 0x72, 0x70, 0x63, + 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x1a, 0x1a, 0x63, 0x6f, 0x6d, + 0x6d, 0x6f, 0x6e, 0x2f, 0x69, 0x64, 0x6c, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x62, 0x61, 0x73, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x23, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, + 0x69, 0x64, 0x6c, 0x2f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2f, 0x6d, 0x73, 0x67, 0x2f, 0x6d, + 0x73, 0x67, 0x5f, 0x64, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x33, 0x0a, 0x0a, + 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x71, 0x12, 0x25, 0x0a, 0x07, 0x6d, 0x73, + 0x67, 0x44, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x6d, 0x73, + 0x67, 0x2e, 0x6d, 0x73, 0x67, 0x44, 0x54, 0x4f, 0x52, 0x07, 0x6d, 0x73, 0x67, 0x44, 0x61, 0x74, + 0x61, 0x22, 0x6d, 0x0a, 0x0b, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x73, 0x70, + 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4d, 0x73, 0x67, 0x49, 0x44, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4d, 0x73, 0x67, + 0x49, 0x44, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4d, 0x73, 0x67, 0x49, + 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4d, + 0x73, 0x67, 0x49, 0x44, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x73, 0x65, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, + 0x32, 0x3b, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x12, 0x34, 0x0a, 0x07, 0x53, 0x65, 0x6e, 0x64, 0x4d, + 0x73, 0x67, 0x12, 0x13, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x65, 0x6e, + 0x64, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x14, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x73, 0x70, 0x42, 0x18, 0x5a, + 0x16, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2f, 0x6d, 0x73, 0x67, 0x2f, 0x72, 0x70, 0x63, 0x2f, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_domain_msg_rpc_service_msg_proto_rawDescOnce sync.Once + file_domain_msg_rpc_service_msg_proto_rawDescData = file_domain_msg_rpc_service_msg_proto_rawDesc +) + +func file_domain_msg_rpc_service_msg_proto_rawDescGZIP() []byte { + file_domain_msg_rpc_service_msg_proto_rawDescOnce.Do(func() { + file_domain_msg_rpc_service_msg_proto_rawDescData = protoimpl.X.CompressGZIP(file_domain_msg_rpc_service_msg_proto_rawDescData) + }) + return file_domain_msg_rpc_service_msg_proto_rawDescData +} + +var file_domain_msg_rpc_service_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_domain_msg_rpc_service_msg_proto_goTypes = []interface{}{ + (*SendMsgReq)(nil), // 0: service.SendMsgReq + (*SendMsgResp)(nil), // 1: service.SendMsgResp + (*msg.MsgDTO)(nil), // 2: msg.msgDTO +} +var file_domain_msg_rpc_service_msg_proto_depIdxs = []int32{ + 2, // 0: service.SendMsgReq.msgData:type_name -> msg.msgDTO + 0, // 1: service.msg.SendMsg:input_type -> service.SendMsgReq + 1, // 2: service.msg.SendMsg:output_type -> service.SendMsgResp + 2, // [2:3] is the sub-list for method output_type + 1, // [1:2] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_domain_msg_rpc_service_msg_proto_init() } +func file_domain_msg_rpc_service_msg_proto_init() { + if File_domain_msg_rpc_service_msg_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_domain_msg_rpc_service_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SendMsgReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_domain_msg_rpc_service_msg_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SendMsgResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_domain_msg_rpc_service_msg_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_domain_msg_rpc_service_msg_proto_goTypes, + DependencyIndexes: file_domain_msg_rpc_service_msg_proto_depIdxs, + MessageInfos: file_domain_msg_rpc_service_msg_proto_msgTypes, + }.Build() + File_domain_msg_rpc_service_msg_proto = out.File + file_domain_msg_rpc_service_msg_proto_rawDesc = nil + file_domain_msg_rpc_service_msg_proto_goTypes = nil + file_domain_msg_rpc_service_msg_proto_depIdxs = nil +} diff --git a/domain/msg/rpc/service/msg.proto b/domain/msg/rpc/service/msg.proto new file mode 100644 index 0000000..a15a4d7 --- /dev/null +++ b/domain/msg/rpc/service/msg.proto @@ -0,0 +1,24 @@ +syntax = "proto3"; + +import "common/idl/base/base.proto"; +import "common/idl/domain/msg/msg_dto.proto"; +package service; +option go_package = "domain/msg/rpc/service"; + + +// user domain rpc server定义 +// 在项目根目录下执行 执行protoc --go-grpc_out=. --go_out=. ./domain/message/rpc/service/message.proto + +service msg { + rpc SendMsg(SendMsgReq) returns (SendMsgResp); +} + +message SendMsgReq{ + .msg.msgDTO msgData = 1; +} + +message SendMsgResp { + string serverMsgID = 1; + string clientMsgID = 2; + int64 sendTime = 3; +} \ No newline at end of file diff --git a/domain/msg/rpc/service/msg_grpc.pb.go b/domain/msg/rpc/service/msg_grpc.pb.go new file mode 100644 index 0000000..468ba6d --- /dev/null +++ b/domain/msg/rpc/service/msg_grpc.pb.go @@ -0,0 +1,105 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v3.21.1 +// source: domain/msg/rpc/service/msg.proto + +package service + +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 + +// MsgClient is the client API for Msg 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 MsgClient interface { + SendMsg(ctx context.Context, in *SendMsgReq, opts ...grpc.CallOption) (*SendMsgResp, error) +} + +type msgClient struct { + cc grpc.ClientConnInterface +} + +func NewMsgClient(cc grpc.ClientConnInterface) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) SendMsg(ctx context.Context, in *SendMsgReq, opts ...grpc.CallOption) (*SendMsgResp, error) { + out := new(SendMsgResp) + err := c.cc.Invoke(ctx, "/service.msg/SendMsg", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +// All implementations must embed UnimplementedMsgServer +// for forward compatibility +type MsgServer interface { + SendMsg(context.Context, *SendMsgReq) (*SendMsgResp, error) + mustEmbedUnimplementedMsgServer() +} + +// UnimplementedMsgServer must be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (UnimplementedMsgServer) SendMsg(context.Context, *SendMsgReq) (*SendMsgResp, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendMsg not implemented") +} +func (UnimplementedMsgServer) mustEmbedUnimplementedMsgServer() {} + +// UnsafeMsgServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to MsgServer will +// result in compilation errors. +type UnsafeMsgServer interface { + mustEmbedUnimplementedMsgServer() +} + +func RegisterMsgServer(s grpc.ServiceRegistrar, srv MsgServer) { + s.RegisterService(&Msg_ServiceDesc, srv) +} + +func _Msg_SendMsg_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SendMsgReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SendMsg(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/service.msg/SendMsg", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SendMsg(ctx, req.(*SendMsgReq)) + } + return interceptor(ctx, in, info, handler) +} + +// Msg_ServiceDesc is the grpc.ServiceDesc for Msg service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Msg_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "service.msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "SendMsg", + Handler: _Msg_SendMsg_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "domain/msg/rpc/service/msg.proto", +} diff --git a/domain/msg/rpc/service/service.go b/domain/msg/rpc/service/service.go new file mode 100644 index 0000000..047621a --- /dev/null +++ b/domain/msg/rpc/service/service.go @@ -0,0 +1,21 @@ +package service + +import ( + "context" + "github.com/hardcore-os/plato/domain/msg/storage" +) + +type sm *storage.StorageManager + +func Init() { + sm = storage.NewStorageManager() +} + +type Service struct { +} + +func (s *Service) mustEmbedUnimplementedMsgServer() {} + +func (s *Service) SendMsg(context.Context, *SendMsgReq) (*SendMsgResp, error) { + return nil, nil +} diff --git a/domain/msg/server.go b/domain/msg/server.go new file mode 100644 index 0000000..6cb5870 --- /dev/null +++ b/domain/msg/server.go @@ -0,0 +1 @@ +package msg diff --git a/domain/msg/storage/storage.go b/domain/msg/storage/storage.go new file mode 100644 index 0000000..13c024c --- /dev/null +++ b/domain/msg/storage/storage.go @@ -0,0 +1,14 @@ +package storage + +const ( + userDomainCacheKey = "userDomainCacheKey:%d" +) + +// 保持聚合的一致性 +type StorageManager struct { +} + +func NewStorageManager() *StorageManager { + sm := &StorageManager{} + return sm +} diff --git a/ipconf/api.go b/ipconf/api.go index c728599..b3683b3 100644 --- a/ipconf/api.go +++ b/ipconf/api.go @@ -10,7 +10,7 @@ import ( ) type Response struct { - Message string `json:"message"` + Message string `json:"msg"` Code int `json:"code"` Data interface{} `json:"data"` }