diff --git a/skills/protobuf/README.md b/skills/protobuf/README.md index 69282b4..4efc0ce 100644 --- a/skills/protobuf/README.md +++ b/skills/protobuf/README.md @@ -34,3 +34,8 @@ go install google.golang.org/protobuf/cmd/protoc-gen-go@latest # 项目的根目录 作为命令执行目录 -I=. $ protoc -I=. --go_out=. --go_opt=module="gitlab.com/go-course-project/go17" skills/protobuf/hello.proto ``` + +4. 一次编译多个文件 +```sh +protoc -I=. --go_out=. --go_opt=module="gitlab.com/go-course-project/go17" skills/protobuf/*.proto +``` \ No newline at end of file diff --git a/skills/protobuf/event.pb.go b/skills/protobuf/event.pb.go new file mode 100644 index 0000000..4941740 --- /dev/null +++ b/skills/protobuf/event.pb.go @@ -0,0 +1,303 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.5 +// protoc v5.29.3 +// source: skills/protobuf/event.proto + +package protobuf + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +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 EVENT_TYPE int32 + +const ( + EVENT_TYPE_ECS EVENT_TYPE = 0 + EVENT_TYPE_RDS EVENT_TYPE = 1 +) + +// Enum value maps for EVENT_TYPE. +var ( + EVENT_TYPE_name = map[int32]string{ + 0: "ECS", + 1: "RDS", + } + EVENT_TYPE_value = map[string]int32{ + "ECS": 0, + "RDS": 1, + } +) + +func (x EVENT_TYPE) Enum() *EVENT_TYPE { + p := new(EVENT_TYPE) + *p = x + return p +} + +func (x EVENT_TYPE) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (EVENT_TYPE) Descriptor() protoreflect.EnumDescriptor { + return file_skills_protobuf_event_proto_enumTypes[0].Descriptor() +} + +func (EVENT_TYPE) Type() protoreflect.EnumType { + return &file_skills_protobuf_event_proto_enumTypes[0] +} + +func (x EVENT_TYPE) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use EVENT_TYPE.Descriptor instead. +func (EVENT_TYPE) EnumDescriptor() ([]byte, []int) { + return file_skills_protobuf_event_proto_rawDescGZIP(), []int{0} +} + +type EVENT_ECS struct { + state protoimpl.MessageState `protogen:"open.v1"` + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *EVENT_ECS) Reset() { + *x = EVENT_ECS{} + mi := &file_skills_protobuf_event_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *EVENT_ECS) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EVENT_ECS) ProtoMessage() {} + +func (x *EVENT_ECS) ProtoReflect() protoreflect.Message { + mi := &file_skills_protobuf_event_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EVENT_ECS.ProtoReflect.Descriptor instead. +func (*EVENT_ECS) Descriptor() ([]byte, []int) { + return file_skills_protobuf_event_proto_rawDescGZIP(), []int{0} +} + +func (x *EVENT_ECS) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +type EVENT_RDS struct { + state protoimpl.MessageState `protogen:"open.v1"` + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *EVENT_RDS) Reset() { + *x = EVENT_RDS{} + mi := &file_skills_protobuf_event_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *EVENT_RDS) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EVENT_RDS) ProtoMessage() {} + +func (x *EVENT_RDS) ProtoReflect() protoreflect.Message { + mi := &file_skills_protobuf_event_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use EVENT_RDS.ProtoReflect.Descriptor instead. +func (*EVENT_RDS) Descriptor() ([]byte, []int) { + return file_skills_protobuf_event_proto_rawDescGZIP(), []int{1} +} + +func (x *EVENT_RDS) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +type Event struct { + state protoimpl.MessageState `protogen:"open.v1"` + // 事件类型(ECS/RDS/...) + // ECS + Type EVENT_TYPE `protobuf:"varint,1,opt,name=type,proto3,enum=hello.EVENT_TYPE" json:"type,omitempty"` + Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` + Detail []*anypb.Any `protobuf:"bytes,3,rep,name=detail,proto3" json:"detail,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Event) Reset() { + *x = Event{} + mi := &file_skills_protobuf_event_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Event) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Event) ProtoMessage() {} + +func (x *Event) ProtoReflect() protoreflect.Message { + mi := &file_skills_protobuf_event_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Event.ProtoReflect.Descriptor instead. +func (*Event) Descriptor() ([]byte, []int) { + return file_skills_protobuf_event_proto_rawDescGZIP(), []int{2} +} + +func (x *Event) GetType() EVENT_TYPE { + if x != nil { + return x.Type + } + return EVENT_TYPE_ECS +} + +func (x *Event) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +func (x *Event) GetDetail() []*anypb.Any { + if x != nil { + return x.Detail + } + return nil +} + +var File_skills_protobuf_event_proto protoreflect.FileDescriptor + +var file_skills_protobuf_event_proto_rawDesc = string([]byte{ + 0x0a, 0x1b, 0x73, 0x6b, 0x69, 0x6c, 0x6c, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x68, + 0x65, 0x6c, 0x6c, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0x25, 0x0a, 0x09, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x45, 0x43, 0x53, 0x12, 0x18, 0x0a, 0x07, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x25, 0x0a, 0x09, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, + 0x52, 0x44, 0x53, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x76, 0x0a, + 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x11, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x2e, 0x45, 0x56, 0x45, + 0x4e, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, + 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x2c, 0x0a, 0x06, 0x64, 0x65, 0x74, 0x61, 0x69, + 0x6c, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x06, 0x64, + 0x65, 0x74, 0x61, 0x69, 0x6c, 0x2a, 0x1e, 0x0a, 0x0a, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x54, + 0x59, 0x50, 0x45, 0x12, 0x07, 0x0a, 0x03, 0x45, 0x43, 0x53, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, + 0x52, 0x44, 0x53, 0x10, 0x01, 0x42, 0x33, 0x5a, 0x31, 0x67, 0x69, 0x74, 0x6c, 0x61, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x2d, 0x63, 0x6f, 0x75, 0x72, 0x73, 0x65, 0x2d, 0x70, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x67, 0x6f, 0x31, 0x37, 0x2f, 0x73, 0x6b, 0x69, 0x6c, 0x6c, + 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, +}) + +var ( + file_skills_protobuf_event_proto_rawDescOnce sync.Once + file_skills_protobuf_event_proto_rawDescData []byte +) + +func file_skills_protobuf_event_proto_rawDescGZIP() []byte { + file_skills_protobuf_event_proto_rawDescOnce.Do(func() { + file_skills_protobuf_event_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_skills_protobuf_event_proto_rawDesc), len(file_skills_protobuf_event_proto_rawDesc))) + }) + return file_skills_protobuf_event_proto_rawDescData +} + +var file_skills_protobuf_event_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_skills_protobuf_event_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_skills_protobuf_event_proto_goTypes = []any{ + (EVENT_TYPE)(0), // 0: hello.EVENT_TYPE + (*EVENT_ECS)(nil), // 1: hello.EVENT_ECS + (*EVENT_RDS)(nil), // 2: hello.EVENT_RDS + (*Event)(nil), // 3: hello.Event + (*anypb.Any)(nil), // 4: google.protobuf.Any +} +var file_skills_protobuf_event_proto_depIdxs = []int32{ + 0, // 0: hello.Event.type:type_name -> hello.EVENT_TYPE + 4, // 1: hello.Event.detail:type_name -> google.protobuf.Any + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_skills_protobuf_event_proto_init() } +func file_skills_protobuf_event_proto_init() { + if File_skills_protobuf_event_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_skills_protobuf_event_proto_rawDesc), len(file_skills_protobuf_event_proto_rawDesc)), + NumEnums: 1, + NumMessages: 3, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_skills_protobuf_event_proto_goTypes, + DependencyIndexes: file_skills_protobuf_event_proto_depIdxs, + EnumInfos: file_skills_protobuf_event_proto_enumTypes, + MessageInfos: file_skills_protobuf_event_proto_msgTypes, + }.Build() + File_skills_protobuf_event_proto = out.File + file_skills_protobuf_event_proto_goTypes = nil + file_skills_protobuf_event_proto_depIdxs = nil +} diff --git a/skills/protobuf/event.proto b/skills/protobuf/event.proto new file mode 100644 index 0000000..f4f656a --- /dev/null +++ b/skills/protobuf/event.proto @@ -0,0 +1,32 @@ +syntax = "proto3"; + +package hello; +option go_package="gitlab.com/go-course-project/go17/skills/protobuf"; + +import "google/protobuf/any.proto"; + +enum EVENT_TYPE { + ECS = 0; + RDS = 1; +} + +message EVENT_ECS { + string message = 1; +} + +message EVENT_RDS { + string message = 1; +} + +message Event { + // 事件类型(ECS/RDS/...) + // ECS + EVENT_TYPE type = 1; + string message = 2; + repeated google.protobuf.Any detail = 3; +} + + + + + diff --git a/skills/protobuf/hello.pb.go b/skills/protobuf/hello.pb.go index b3bb62c..e596828 100644 --- a/skills/protobuf/hello.pb.go +++ b/skills/protobuf/hello.pb.go @@ -9,7 +9,6 @@ package protobuf import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - anypb "google.golang.org/protobuf/types/known/anypb" reflect "reflect" sync "sync" unsafe "unsafe" @@ -68,52 +67,6 @@ func (DESCRIBE_BY) EnumDescriptor() ([]byte, []int) { return file_skills_protobuf_hello_proto_rawDescGZIP(), []int{0} } -type EVENT_TYPE int32 - -const ( - EVENT_TYPE_ECS EVENT_TYPE = 0 - EVENT_TYPE_RDS EVENT_TYPE = 1 -) - -// Enum value maps for EVENT_TYPE. -var ( - EVENT_TYPE_name = map[int32]string{ - 0: "ECS", - 1: "RDS", - } - EVENT_TYPE_value = map[string]int32{ - "ECS": 0, - "RDS": 1, - } -) - -func (x EVENT_TYPE) Enum() *EVENT_TYPE { - p := new(EVENT_TYPE) - *p = x - return p -} - -func (x EVENT_TYPE) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (EVENT_TYPE) Descriptor() protoreflect.EnumDescriptor { - return file_skills_protobuf_hello_proto_enumTypes[1].Descriptor() -} - -func (EVENT_TYPE) Type() protoreflect.EnumType { - return &file_skills_protobuf_hello_proto_enumTypes[1] -} - -func (x EVENT_TYPE) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use EVENT_TYPE.Descriptor instead. -func (EVENT_TYPE) EnumDescriptor() ([]byte, []int) { - return file_skills_protobuf_hello_proto_rawDescGZIP(), []int{1} -} - type HelloRequest struct { state protoimpl.MessageState `protogen:"open.v1"` MyName string `protobuf:"bytes,1,opt,name=my_name,json=myName,proto3" json:"my_name,omitempty"` @@ -226,27 +179,27 @@ func (x *HelloResponse) GetMessage() string { return "" } -type EVENT_ECS struct { +type EventSet struct { state protoimpl.MessageState `protogen:"open.v1"` - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + Items []*Event `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *EVENT_ECS) Reset() { - *x = EVENT_ECS{} +func (x *EventSet) Reset() { + *x = EventSet{} mi := &file_skills_protobuf_hello_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *EVENT_ECS) String() string { +func (x *EventSet) String() string { return protoimpl.X.MessageStringOf(x) } -func (*EVENT_ECS) ProtoMessage() {} +func (*EventSet) ProtoMessage() {} -func (x *EVENT_ECS) ProtoReflect() protoreflect.Message { +func (x *EventSet) ProtoReflect() protoreflect.Message { mi := &file_skills_protobuf_hello_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -258,120 +211,14 @@ func (x *EVENT_ECS) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use EVENT_ECS.ProtoReflect.Descriptor instead. -func (*EVENT_ECS) Descriptor() ([]byte, []int) { +// Deprecated: Use EventSet.ProtoReflect.Descriptor instead. +func (*EventSet) Descriptor() ([]byte, []int) { return file_skills_protobuf_hello_proto_rawDescGZIP(), []int{2} } -func (x *EVENT_ECS) GetMessage() string { +func (x *EventSet) GetItems() []*Event { if x != nil { - return x.Message - } - return "" -} - -type EVENT_RDS struct { - state protoimpl.MessageState `protogen:"open.v1"` - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *EVENT_RDS) Reset() { - *x = EVENT_RDS{} - mi := &file_skills_protobuf_hello_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *EVENT_RDS) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*EVENT_RDS) ProtoMessage() {} - -func (x *EVENT_RDS) ProtoReflect() protoreflect.Message { - mi := &file_skills_protobuf_hello_proto_msgTypes[3] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use EVENT_RDS.ProtoReflect.Descriptor instead. -func (*EVENT_RDS) Descriptor() ([]byte, []int) { - return file_skills_protobuf_hello_proto_rawDescGZIP(), []int{3} -} - -func (x *EVENT_RDS) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -type Event struct { - state protoimpl.MessageState `protogen:"open.v1"` - // 事件类型(ECS/RDS/...) - // ECS - Type EVENT_TYPE `protobuf:"varint,1,opt,name=type,proto3,enum=hello.EVENT_TYPE" json:"type,omitempty"` - Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` - Detail []*anypb.Any `protobuf:"bytes,3,rep,name=detail,proto3" json:"detail,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Event) Reset() { - *x = Event{} - mi := &file_skills_protobuf_hello_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Event) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Event) ProtoMessage() {} - -func (x *Event) ProtoReflect() protoreflect.Message { - mi := &file_skills_protobuf_hello_proto_msgTypes[4] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Event.ProtoReflect.Descriptor instead. -func (*Event) Descriptor() ([]byte, []int) { - return file_skills_protobuf_hello_proto_rawDescGZIP(), []int{4} -} - -func (x *Event) GetType() EVENT_TYPE { - if x != nil { - return x.Type - } - return EVENT_TYPE_ECS -} - -func (x *Event) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -func (x *Event) GetDetail() []*anypb.Any { - if x != nil { - return x.Detail + return x.Items } return nil } @@ -381,45 +228,33 @@ var File_skills_protobuf_hello_proto protoreflect.FileDescriptor var file_skills_protobuf_hello_proto_rawDesc = string([]byte{ 0x0a, 0x1b, 0x73, 0x6b, 0x69, 0x6c, 0x6c, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x68, - 0x65, 0x6c, 0x6c, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, - 0xd0, 0x01, 0x0a, 0x0c, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x17, 0x0a, 0x07, 0x6d, 0x79, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x06, 0x6d, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x67, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x61, 0x67, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x6d, - 0x61, 0x67, 0x69, 0x63, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x03, 0x20, 0x03, 0x28, - 0x03, 0x52, 0x0b, 0x6d, 0x61, 0x67, 0x69, 0x63, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x37, - 0x0a, 0x06, 0x65, 0x78, 0x74, 0x72, 0x61, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, - 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x2e, 0x45, 0x78, 0x74, 0x72, 0x61, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, - 0x06, 0x65, 0x78, 0x74, 0x72, 0x61, 0x73, 0x1a, 0x39, 0x0a, 0x0b, 0x45, 0x78, 0x74, 0x72, 0x61, - 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, - 0x38, 0x01, 0x22, 0x29, 0x0a, 0x0d, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x25, 0x0a, - 0x09, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x45, 0x43, 0x53, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, - 0x73, 0x61, 0x67, 0x65, 0x22, 0x25, 0x0a, 0x09, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x52, 0x44, - 0x53, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x76, 0x0a, 0x05, 0x45, - 0x76, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x11, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x2e, 0x45, 0x56, 0x45, 0x4e, 0x54, - 0x5f, 0x54, 0x59, 0x50, 0x45, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x2c, 0x0a, 0x06, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x18, - 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x06, 0x64, 0x65, 0x74, - 0x61, 0x69, 0x6c, 0x2a, 0x1f, 0x0a, 0x0b, 0x44, 0x45, 0x53, 0x43, 0x52, 0x49, 0x42, 0x45, 0x5f, - 0x42, 0x59, 0x12, 0x06, 0x0a, 0x02, 0x49, 0x44, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x41, - 0x4d, 0x45, 0x10, 0x01, 0x2a, 0x1e, 0x0a, 0x0a, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x59, - 0x50, 0x45, 0x12, 0x07, 0x0a, 0x03, 0x45, 0x43, 0x53, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x52, - 0x44, 0x53, 0x10, 0x01, 0x42, 0x33, 0x5a, 0x31, 0x67, 0x69, 0x74, 0x6c, 0x61, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x2d, 0x63, 0x6f, 0x75, 0x72, 0x73, 0x65, 0x2d, 0x70, 0x72, 0x6f, - 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x67, 0x6f, 0x31, 0x37, 0x2f, 0x73, 0x6b, 0x69, 0x6c, 0x6c, 0x73, - 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x65, 0x6c, 0x6c, 0x6f, 0x1a, 0x1b, 0x73, 0x6b, 0x69, 0x6c, 0x6c, 0x73, 0x2f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x22, 0xd0, 0x01, 0x0a, 0x0c, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x6d, 0x79, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x61, + 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x61, 0x67, 0x65, 0x12, 0x21, 0x0a, + 0x0c, 0x6d, 0x61, 0x67, 0x69, 0x63, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x03, 0x20, + 0x03, 0x28, 0x03, 0x52, 0x0b, 0x6d, 0x61, 0x67, 0x69, 0x63, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, + 0x12, 0x37, 0x0a, 0x06, 0x65, 0x78, 0x74, 0x72, 0x61, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x1f, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x45, 0x78, 0x74, 0x72, 0x61, 0x73, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x52, 0x06, 0x65, 0x78, 0x74, 0x72, 0x61, 0x73, 0x1a, 0x39, 0x0a, 0x0b, 0x45, 0x78, 0x74, + 0x72, 0x61, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x3a, 0x02, 0x38, 0x01, 0x22, 0x29, 0x0a, 0x0d, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, + 0x2e, 0x0a, 0x08, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x74, 0x12, 0x22, 0x0a, 0x05, 0x69, + 0x74, 0x65, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x68, 0x65, 0x6c, + 0x6c, 0x6f, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x2a, + 0x1f, 0x0a, 0x0b, 0x44, 0x45, 0x53, 0x43, 0x52, 0x49, 0x42, 0x45, 0x5f, 0x42, 0x59, 0x12, 0x06, + 0x0a, 0x02, 0x49, 0x44, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x41, 0x4d, 0x45, 0x10, 0x01, + 0x42, 0x33, 0x5a, 0x31, 0x67, 0x69, 0x74, 0x6c, 0x61, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, + 0x6f, 0x2d, 0x63, 0x6f, 0x75, 0x72, 0x73, 0x65, 0x2d, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, + 0x2f, 0x67, 0x6f, 0x31, 0x37, 0x2f, 0x73, 0x6b, 0x69, 0x6c, 0x6c, 0x73, 0x2f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, }) var ( @@ -434,28 +269,24 @@ func file_skills_protobuf_hello_proto_rawDescGZIP() []byte { return file_skills_protobuf_hello_proto_rawDescData } -var file_skills_protobuf_hello_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_skills_protobuf_hello_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_skills_protobuf_hello_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_skills_protobuf_hello_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_skills_protobuf_hello_proto_goTypes = []any{ (DESCRIBE_BY)(0), // 0: hello.DESCRIBE_BY - (EVENT_TYPE)(0), // 1: hello.EVENT_TYPE - (*HelloRequest)(nil), // 2: hello.HelloRequest - (*HelloResponse)(nil), // 3: hello.HelloResponse - (*EVENT_ECS)(nil), // 4: hello.EVENT_ECS - (*EVENT_RDS)(nil), // 5: hello.EVENT_RDS - (*Event)(nil), // 6: hello.Event - nil, // 7: hello.HelloRequest.ExtrasEntry - (*anypb.Any)(nil), // 8: google.protobuf.Any + (*HelloRequest)(nil), // 1: hello.HelloRequest + (*HelloResponse)(nil), // 2: hello.HelloResponse + (*EventSet)(nil), // 3: hello.EventSet + nil, // 4: hello.HelloRequest.ExtrasEntry + (*Event)(nil), // 5: hello.Event } var file_skills_protobuf_hello_proto_depIdxs = []int32{ - 7, // 0: hello.HelloRequest.extras:type_name -> hello.HelloRequest.ExtrasEntry - 1, // 1: hello.Event.type:type_name -> hello.EVENT_TYPE - 8, // 2: hello.Event.detail:type_name -> google.protobuf.Any - 3, // [3:3] is the sub-list for method output_type - 3, // [3:3] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 4, // 0: hello.HelloRequest.extras:type_name -> hello.HelloRequest.ExtrasEntry + 5, // 1: hello.EventSet.items:type_name -> hello.Event + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_skills_protobuf_hello_proto_init() } @@ -463,13 +294,14 @@ func file_skills_protobuf_hello_proto_init() { if File_skills_protobuf_hello_proto != nil { return } + file_skills_protobuf_event_proto_init() type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_skills_protobuf_hello_proto_rawDesc), len(file_skills_protobuf_hello_proto_rawDesc)), - NumEnums: 2, - NumMessages: 6, + NumEnums: 1, + NumMessages: 4, NumExtensions: 0, NumServices: 0, }, diff --git a/skills/protobuf/hello.proto b/skills/protobuf/hello.proto index 1b0bc33..95b5c5c 100644 --- a/skills/protobuf/hello.proto +++ b/skills/protobuf/hello.proto @@ -3,7 +3,7 @@ syntax = "proto3"; package hello; option go_package="gitlab.com/go-course-project/go17/skills/protobuf"; -import "google/protobuf/any.proto"; +import "skills/protobuf/event.proto"; message HelloRequest { string my_name = 1; @@ -21,25 +21,8 @@ enum DESCRIBE_BY { NAME = 1; } -enum EVENT_TYPE { - ECS = 0; - RDS = 1; -} - -message EVENT_ECS { - string message = 1; -} - -message EVENT_RDS { - string message = 1; -} - -message Event { - // 事件类型(ECS/RDS/...) - // ECS - EVENT_TYPE type = 1; - string message = 2; - repeated google.protobuf.Any detail = 3; +message EventSet { + repeated Event items = 1; }