From da433c88615a9dc75de7d4e5b81c6b73ea0049c0 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 17 Jul 2024 13:45:12 +0800 Subject: [PATCH] :sparkles: Batch notify user api --- pkg/proto/notify.pb.go | 188 ++++++++++++++++++++++++++---------- pkg/proto/notify.proto | 6 ++ pkg/proto/notify_grpc.pb.go | 42 +++++++- 3 files changed, 181 insertions(+), 55 deletions(-) diff --git a/pkg/proto/notify.pb.go b/pkg/proto/notify.pb.go index 3739f8e..7ae5300 100644 --- a/pkg/proto/notify.pb.go +++ b/pkg/proto/notify.pb.go @@ -75,6 +75,61 @@ func (x *NotifyUserRequest) GetNotify() *NotifyRequest { return nil } +type NotifyUserBatchRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserId []uint64 `protobuf:"varint,1,rep,packed,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + Notify *NotifyRequest `protobuf:"bytes,2,opt,name=notify,proto3" json:"notify,omitempty"` +} + +func (x *NotifyUserBatchRequest) Reset() { + *x = NotifyUserBatchRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_notify_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NotifyUserBatchRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NotifyUserBatchRequest) ProtoMessage() {} + +func (x *NotifyUserBatchRequest) ProtoReflect() protoreflect.Message { + mi := &file_notify_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 NotifyUserBatchRequest.ProtoReflect.Descriptor instead. +func (*NotifyUserBatchRequest) Descriptor() ([]byte, []int) { + return file_notify_proto_rawDescGZIP(), []int{1} +} + +func (x *NotifyUserBatchRequest) GetUserId() []uint64 { + if x != nil { + return x.UserId + } + return nil +} + +func (x *NotifyUserBatchRequest) GetNotify() *NotifyRequest { + if x != nil { + return x.Notify + } + return nil +} + type NotifyRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -92,7 +147,7 @@ type NotifyRequest struct { func (x *NotifyRequest) Reset() { *x = NotifyRequest{} if protoimpl.UnsafeEnabled { - mi := &file_notify_proto_msgTypes[1] + mi := &file_notify_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -105,7 +160,7 @@ func (x *NotifyRequest) String() string { func (*NotifyRequest) ProtoMessage() {} func (x *NotifyRequest) ProtoReflect() protoreflect.Message { - mi := &file_notify_proto_msgTypes[1] + mi := &file_notify_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -118,7 +173,7 @@ func (x *NotifyRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use NotifyRequest.ProtoReflect.Descriptor instead. func (*NotifyRequest) Descriptor() ([]byte, []int) { - return file_notify_proto_rawDescGZIP(), []int{1} + return file_notify_proto_rawDescGZIP(), []int{2} } func (x *NotifyRequest) GetTopic() string { @@ -182,7 +237,7 @@ type NotifyResponse struct { func (x *NotifyResponse) Reset() { *x = NotifyResponse{} if protoimpl.UnsafeEnabled { - mi := &file_notify_proto_msgTypes[2] + mi := &file_notify_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -195,7 +250,7 @@ func (x *NotifyResponse) String() string { func (*NotifyResponse) ProtoMessage() {} func (x *NotifyResponse) ProtoReflect() protoreflect.Message { - mi := &file_notify_proto_msgTypes[2] + mi := &file_notify_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -208,7 +263,7 @@ func (x *NotifyResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use NotifyResponse.ProtoReflect.Descriptor instead. func (*NotifyResponse) Descriptor() ([]byte, []int) { - return file_notify_proto_rawDescGZIP(), []int{2} + return file_notify_proto_rawDescGZIP(), []int{3} } func (x *NotifyResponse) GetIsSuccess() bool { @@ -235,36 +290,47 @@ var file_notify_proto_rawDesc = []byte{ 0x72, 0x49, 0x64, 0x12, 0x2c, 0x0a, 0x06, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x06, 0x6e, 0x6f, 0x74, 0x69, 0x66, - 0x79, 0x22, 0xde, 0x01, 0x0a, 0x0d, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, - 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, - 0x1f, 0x0a, 0x08, 0x73, 0x75, 0x62, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x48, 0x00, 0x52, 0x08, 0x73, 0x75, 0x62, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x88, 0x01, 0x01, - 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x62, 0x6f, 0x64, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x73, 0x5f, 0x72, 0x65, 0x61, 0x6c, 0x74, 0x69, 0x6d, 0x65, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x69, 0x73, 0x52, 0x65, 0x61, 0x6c, 0x74, 0x69, 0x6d, - 0x65, 0x12, 0x22, 0x0a, 0x0d, 0x69, 0x73, 0x5f, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x5f, 0x70, 0x75, - 0x73, 0x68, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x73, 0x46, 0x6f, 0x72, 0x63, - 0x65, 0x50, 0x75, 0x73, 0x68, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x73, 0x75, 0x62, 0x74, 0x69, 0x74, - 0x6c, 0x65, 0x22, 0x56, 0x0a, 0x0e, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x73, 0x5f, 0x73, 0x75, 0x63, 0x63, 0x65, - 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x53, 0x75, 0x63, 0x63, - 0x65, 0x73, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x66, 0x66, 0x65, 0x63, 0x74, 0x65, 0x64, 0x5f, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x61, 0x66, 0x66, - 0x65, 0x63, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x32, 0x8b, 0x01, 0x0a, 0x08, 0x4e, - 0x6f, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x3f, 0x0a, 0x0a, 0x4e, 0x6f, 0x74, 0x69, 0x66, - 0x79, 0x55, 0x73, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x6f, - 0x74, 0x69, 0x66, 0x79, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x0d, 0x4e, 0x6f, 0x74, 0x69, - 0x66, 0x79, 0x41, 0x6c, 0x6c, 0x55, 0x73, 0x65, 0x72, 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2e, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x09, 0x5a, 0x07, 0x2e, 0x3b, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x79, 0x22, 0x5f, 0x0a, 0x16, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x55, 0x73, 0x65, 0x72, 0x42, + 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, + 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, 0x04, 0x52, 0x06, 0x75, 0x73, + 0x65, 0x72, 0x49, 0x64, 0x12, 0x2c, 0x0a, 0x06, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x6f, 0x74, + 0x69, 0x66, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x06, 0x6e, 0x6f, 0x74, 0x69, + 0x66, 0x79, 0x22, 0xde, 0x01, 0x0a, 0x0d, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, + 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, + 0x12, 0x1f, 0x0a, 0x08, 0x73, 0x75, 0x62, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x48, 0x00, 0x52, 0x08, 0x73, 0x75, 0x62, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x88, 0x01, + 0x01, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x62, 0x6f, 0x64, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x73, 0x5f, 0x72, 0x65, 0x61, 0x6c, 0x74, 0x69, 0x6d, 0x65, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x69, 0x73, 0x52, 0x65, 0x61, 0x6c, 0x74, 0x69, + 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0d, 0x69, 0x73, 0x5f, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x5f, 0x70, + 0x75, 0x73, 0x68, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x73, 0x46, 0x6f, 0x72, + 0x63, 0x65, 0x50, 0x75, 0x73, 0x68, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x73, 0x75, 0x62, 0x74, 0x69, + 0x74, 0x6c, 0x65, 0x22, 0x56, 0x0a, 0x0e, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x73, 0x5f, 0x73, 0x75, 0x63, 0x63, + 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x53, 0x75, 0x63, + 0x63, 0x65, 0x73, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x66, 0x66, 0x65, 0x63, 0x74, 0x65, 0x64, + 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x61, 0x66, + 0x66, 0x65, 0x63, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x32, 0xd6, 0x01, 0x0a, 0x08, + 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x3f, 0x0a, 0x0a, 0x4e, 0x6f, 0x74, 0x69, + 0x66, 0x79, 0x55, 0x73, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, + 0x6f, 0x74, 0x69, 0x66, 0x79, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x49, 0x0a, 0x0f, 0x4e, 0x6f, 0x74, + 0x69, 0x66, 0x79, 0x55, 0x73, 0x65, 0x72, 0x42, 0x61, 0x74, 0x63, 0x68, 0x12, 0x1d, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x55, 0x73, 0x65, 0x72, 0x42, + 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x0d, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x41, 0x6c, + 0x6c, 0x55, 0x73, 0x65, 0x72, 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x6f, + 0x74, 0x69, 0x66, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x42, 0x09, 0x5a, 0x07, 0x2e, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -279,23 +345,27 @@ func file_notify_proto_rawDescGZIP() []byte { return file_notify_proto_rawDescData } -var file_notify_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_notify_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_notify_proto_goTypes = []any{ - (*NotifyUserRequest)(nil), // 0: proto.NotifyUserRequest - (*NotifyRequest)(nil), // 1: proto.NotifyRequest - (*NotifyResponse)(nil), // 2: proto.NotifyResponse + (*NotifyUserRequest)(nil), // 0: proto.NotifyUserRequest + (*NotifyUserBatchRequest)(nil), // 1: proto.NotifyUserBatchRequest + (*NotifyRequest)(nil), // 2: proto.NotifyRequest + (*NotifyResponse)(nil), // 3: proto.NotifyResponse } var file_notify_proto_depIdxs = []int32{ - 1, // 0: proto.NotifyUserRequest.notify:type_name -> proto.NotifyRequest - 0, // 1: proto.Notifier.NotifyUser:input_type -> proto.NotifyUserRequest - 1, // 2: proto.Notifier.NotifyAllUser:input_type -> proto.NotifyRequest - 2, // 3: proto.Notifier.NotifyUser:output_type -> proto.NotifyResponse - 2, // 4: proto.Notifier.NotifyAllUser:output_type -> proto.NotifyResponse - 3, // [3:5] is the sub-list for method output_type - 1, // [1:3] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 2, // 0: proto.NotifyUserRequest.notify:type_name -> proto.NotifyRequest + 2, // 1: proto.NotifyUserBatchRequest.notify:type_name -> proto.NotifyRequest + 0, // 2: proto.Notifier.NotifyUser:input_type -> proto.NotifyUserRequest + 1, // 3: proto.Notifier.NotifyUserBatch:input_type -> proto.NotifyUserBatchRequest + 2, // 4: proto.Notifier.NotifyAllUser:input_type -> proto.NotifyRequest + 3, // 5: proto.Notifier.NotifyUser:output_type -> proto.NotifyResponse + 3, // 6: proto.Notifier.NotifyUserBatch:output_type -> proto.NotifyResponse + 3, // 7: proto.Notifier.NotifyAllUser:output_type -> proto.NotifyResponse + 5, // [5:8] is the sub-list for method output_type + 2, // [2:5] 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_notify_proto_init() } @@ -317,7 +387,7 @@ func file_notify_proto_init() { } } file_notify_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*NotifyRequest); i { + switch v := v.(*NotifyUserBatchRequest); i { case 0: return &v.state case 1: @@ -329,6 +399,18 @@ func file_notify_proto_init() { } } file_notify_proto_msgTypes[2].Exporter = func(v any, i int) any { + switch v := v.(*NotifyRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_notify_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*NotifyResponse); i { case 0: return &v.state @@ -341,14 +423,14 @@ func file_notify_proto_init() { } } } - file_notify_proto_msgTypes[1].OneofWrappers = []any{} + file_notify_proto_msgTypes[2].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_notify_proto_rawDesc, NumEnums: 0, - NumMessages: 3, + NumMessages: 4, NumExtensions: 0, NumServices: 1, }, diff --git a/pkg/proto/notify.proto b/pkg/proto/notify.proto index cb66988..f70b666 100644 --- a/pkg/proto/notify.proto +++ b/pkg/proto/notify.proto @@ -6,6 +6,7 @@ package proto; service Notifier { rpc NotifyUser(NotifyUserRequest) returns (NotifyResponse) {} + rpc NotifyUserBatch(NotifyUserBatchRequest) returns (NotifyResponse) {} rpc NotifyAllUser(NotifyRequest) returns(NotifyResponse) {} } @@ -14,6 +15,11 @@ message NotifyUserRequest { NotifyRequest notify = 2; } +message NotifyUserBatchRequest { + repeated uint64 user_id = 1; + NotifyRequest notify = 2; +} + message NotifyRequest { string topic = 1; string title = 2; diff --git a/pkg/proto/notify_grpc.pb.go b/pkg/proto/notify_grpc.pb.go index 91b78ef..5434787 100644 --- a/pkg/proto/notify_grpc.pb.go +++ b/pkg/proto/notify_grpc.pb.go @@ -19,8 +19,9 @@ import ( const _ = grpc.SupportPackageIsVersion8 const ( - Notifier_NotifyUser_FullMethodName = "/proto.Notifier/NotifyUser" - Notifier_NotifyAllUser_FullMethodName = "/proto.Notifier/NotifyAllUser" + Notifier_NotifyUser_FullMethodName = "/proto.Notifier/NotifyUser" + Notifier_NotifyUserBatch_FullMethodName = "/proto.Notifier/NotifyUserBatch" + Notifier_NotifyAllUser_FullMethodName = "/proto.Notifier/NotifyAllUser" ) // NotifierClient is the client API for Notifier service. @@ -28,6 +29,7 @@ const ( // 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 NotifierClient interface { NotifyUser(ctx context.Context, in *NotifyUserRequest, opts ...grpc.CallOption) (*NotifyResponse, error) + NotifyUserBatch(ctx context.Context, in *NotifyUserBatchRequest, opts ...grpc.CallOption) (*NotifyResponse, error) NotifyAllUser(ctx context.Context, in *NotifyRequest, opts ...grpc.CallOption) (*NotifyResponse, error) } @@ -49,6 +51,16 @@ func (c *notifierClient) NotifyUser(ctx context.Context, in *NotifyUserRequest, return out, nil } +func (c *notifierClient) NotifyUserBatch(ctx context.Context, in *NotifyUserBatchRequest, opts ...grpc.CallOption) (*NotifyResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(NotifyResponse) + err := c.cc.Invoke(ctx, Notifier_NotifyUserBatch_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *notifierClient) NotifyAllUser(ctx context.Context, in *NotifyRequest, opts ...grpc.CallOption) (*NotifyResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(NotifyResponse) @@ -64,6 +76,7 @@ func (c *notifierClient) NotifyAllUser(ctx context.Context, in *NotifyRequest, o // for forward compatibility type NotifierServer interface { NotifyUser(context.Context, *NotifyUserRequest) (*NotifyResponse, error) + NotifyUserBatch(context.Context, *NotifyUserBatchRequest) (*NotifyResponse, error) NotifyAllUser(context.Context, *NotifyRequest) (*NotifyResponse, error) mustEmbedUnimplementedNotifierServer() } @@ -75,6 +88,9 @@ type UnimplementedNotifierServer struct { func (UnimplementedNotifierServer) NotifyUser(context.Context, *NotifyUserRequest) (*NotifyResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method NotifyUser not implemented") } +func (UnimplementedNotifierServer) NotifyUserBatch(context.Context, *NotifyUserBatchRequest) (*NotifyResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method NotifyUserBatch not implemented") +} func (UnimplementedNotifierServer) NotifyAllUser(context.Context, *NotifyRequest) (*NotifyResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method NotifyAllUser not implemented") } @@ -109,6 +125,24 @@ func _Notifier_NotifyUser_Handler(srv interface{}, ctx context.Context, dec func return interceptor(ctx, in, info, handler) } +func _Notifier_NotifyUserBatch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(NotifyUserBatchRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(NotifierServer).NotifyUserBatch(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Notifier_NotifyUserBatch_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(NotifierServer).NotifyUserBatch(ctx, req.(*NotifyUserBatchRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Notifier_NotifyAllUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(NotifyRequest) if err := dec(in); err != nil { @@ -138,6 +172,10 @@ var Notifier_ServiceDesc = grpc.ServiceDesc{ MethodName: "NotifyUser", Handler: _Notifier_NotifyUser_Handler, }, + { + MethodName: "NotifyUserBatch", + Handler: _Notifier_NotifyUserBatch_Handler, + }, { MethodName: "NotifyAllUser", Handler: _Notifier_NotifyAllUser_Handler,