🎉 Initial Commit

This commit is contained in:
2024-10-25 00:56:22 +08:00
commit 7597bff972
26 changed files with 2052 additions and 0 deletions

589
pkg/proto/pusher.pb.go Normal file
View File

@@ -0,0 +1,589 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.35.1
// protoc v5.28.2
// source: pusher.proto
package proto
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 NotifyInfo struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Topic string `protobuf:"bytes,1,opt,name=topic,proto3" json:"topic,omitempty"`
Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"`
Subtitle *string `protobuf:"bytes,3,opt,name=subtitle,proto3,oneof" json:"subtitle,omitempty"`
Body string `protobuf:"bytes,4,opt,name=body,proto3" json:"body,omitempty"`
Metadata []byte `protobuf:"bytes,5,opt,name=metadata,proto3" json:"metadata,omitempty"`
Priority int32 `protobuf:"varint,6,opt,name=priority,proto3" json:"priority,omitempty"`
}
func (x *NotifyInfo) Reset() {
*x = NotifyInfo{}
mi := &file_pusher_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *NotifyInfo) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*NotifyInfo) ProtoMessage() {}
func (x *NotifyInfo) ProtoReflect() protoreflect.Message {
mi := &file_pusher_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 NotifyInfo.ProtoReflect.Descriptor instead.
func (*NotifyInfo) Descriptor() ([]byte, []int) {
return file_pusher_proto_rawDescGZIP(), []int{0}
}
func (x *NotifyInfo) GetTopic() string {
if x != nil {
return x.Topic
}
return ""
}
func (x *NotifyInfo) GetTitle() string {
if x != nil {
return x.Title
}
return ""
}
func (x *NotifyInfo) GetSubtitle() string {
if x != nil && x.Subtitle != nil {
return *x.Subtitle
}
return ""
}
func (x *NotifyInfo) GetBody() string {
if x != nil {
return x.Body
}
return ""
}
func (x *NotifyInfo) GetMetadata() []byte {
if x != nil {
return x.Metadata
}
return nil
}
func (x *NotifyInfo) GetPriority() int32 {
if x != nil {
return x.Priority
}
return 0
}
type PushNotificationRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Provider string `protobuf:"bytes,1,opt,name=provider,proto3" json:"provider,omitempty"`
DeviceToken string `protobuf:"bytes,2,opt,name=device_token,json=deviceToken,proto3" json:"device_token,omitempty"`
Notify *NotifyInfo `protobuf:"bytes,3,opt,name=notify,proto3" json:"notify,omitempty"`
}
func (x *PushNotificationRequest) Reset() {
*x = PushNotificationRequest{}
mi := &file_pusher_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *PushNotificationRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PushNotificationRequest) ProtoMessage() {}
func (x *PushNotificationRequest) ProtoReflect() protoreflect.Message {
mi := &file_pusher_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 PushNotificationRequest.ProtoReflect.Descriptor instead.
func (*PushNotificationRequest) Descriptor() ([]byte, []int) {
return file_pusher_proto_rawDescGZIP(), []int{1}
}
func (x *PushNotificationRequest) GetProvider() string {
if x != nil {
return x.Provider
}
return ""
}
func (x *PushNotificationRequest) GetDeviceToken() string {
if x != nil {
return x.DeviceToken
}
return ""
}
func (x *PushNotificationRequest) GetNotify() *NotifyInfo {
if x != nil {
return x.Notify
}
return nil
}
type PushNotificationBatchRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Providers []string `protobuf:"bytes,1,rep,name=provider,proto3" json:"provider,omitempty"`
DeviceTokens []string `protobuf:"bytes,2,rep,name=device_tokens,json=deviceTokens,proto3" json:"device_tokens,omitempty"`
Notify *NotifyInfo `protobuf:"bytes,3,opt,name=notify,proto3" json:"notify,omitempty"`
}
func (x *PushNotificationBatchRequest) Reset() {
*x = PushNotificationBatchRequest{}
mi := &file_pusher_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *PushNotificationBatchRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PushNotificationBatchRequest) ProtoMessage() {}
func (x *PushNotificationBatchRequest) ProtoReflect() protoreflect.Message {
mi := &file_pusher_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 PushNotificationBatchRequest.ProtoReflect.Descriptor instead.
func (*PushNotificationBatchRequest) Descriptor() ([]byte, []int) {
return file_pusher_proto_rawDescGZIP(), []int{2}
}
func (x *PushNotificationBatchRequest) GetProviders() []string {
if x != nil {
return x.Providers
}
return nil
}
func (x *PushNotificationBatchRequest) GetDeviceTokens() []string {
if x != nil {
return x.DeviceTokens
}
return nil
}
func (x *PushNotificationBatchRequest) GetNotify() *NotifyInfo {
if x != nil {
return x.Notify
}
return nil
}
type EmailInfo struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Subject string `protobuf:"bytes,1,opt,name=subject,proto3" json:"subject,omitempty"`
TextBody *string `protobuf:"bytes,2,opt,name=text_body,json=textBody,proto3,oneof" json:"text_body,omitempty"`
HtmlBody *string `protobuf:"bytes,3,opt,name=html_body,json=htmlBody,proto3,oneof" json:"html_body,omitempty"`
}
func (x *EmailInfo) Reset() {
*x = EmailInfo{}
mi := &file_pusher_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *EmailInfo) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*EmailInfo) ProtoMessage() {}
func (x *EmailInfo) ProtoReflect() protoreflect.Message {
mi := &file_pusher_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 EmailInfo.ProtoReflect.Descriptor instead.
func (*EmailInfo) Descriptor() ([]byte, []int) {
return file_pusher_proto_rawDescGZIP(), []int{3}
}
func (x *EmailInfo) GetSubject() string {
if x != nil {
return x.Subject
}
return ""
}
func (x *EmailInfo) GetTextBody() string {
if x != nil && x.TextBody != nil {
return *x.TextBody
}
return ""
}
func (x *EmailInfo) GetHtmlBody() string {
if x != nil && x.HtmlBody != nil {
return *x.HtmlBody
}
return ""
}
type DeliverEmailRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
To string `protobuf:"bytes,1,opt,name=to,proto3" json:"to,omitempty"`
Email *EmailInfo `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"`
}
func (x *DeliverEmailRequest) Reset() {
*x = DeliverEmailRequest{}
mi := &file_pusher_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *DeliverEmailRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DeliverEmailRequest) ProtoMessage() {}
func (x *DeliverEmailRequest) ProtoReflect() protoreflect.Message {
mi := &file_pusher_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 DeliverEmailRequest.ProtoReflect.Descriptor instead.
func (*DeliverEmailRequest) Descriptor() ([]byte, []int) {
return file_pusher_proto_rawDescGZIP(), []int{4}
}
func (x *DeliverEmailRequest) GetTo() string {
if x != nil {
return x.To
}
return ""
}
func (x *DeliverEmailRequest) GetEmail() *EmailInfo {
if x != nil {
return x.Email
}
return nil
}
type DeliverEmailBatchRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
To []string `protobuf:"bytes,1,rep,name=to,proto3" json:"to,omitempty"`
Email *EmailInfo `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"`
}
func (x *DeliverEmailBatchRequest) Reset() {
*x = DeliverEmailBatchRequest{}
mi := &file_pusher_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *DeliverEmailBatchRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DeliverEmailBatchRequest) ProtoMessage() {}
func (x *DeliverEmailBatchRequest) ProtoReflect() protoreflect.Message {
mi := &file_pusher_proto_msgTypes[5]
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 DeliverEmailBatchRequest.ProtoReflect.Descriptor instead.
func (*DeliverEmailBatchRequest) Descriptor() ([]byte, []int) {
return file_pusher_proto_rawDescGZIP(), []int{5}
}
func (x *DeliverEmailBatchRequest) GetTo() []string {
if x != nil {
return x.To
}
return nil
}
func (x *DeliverEmailBatchRequest) GetEmail() *EmailInfo {
if x != nil {
return x.Email
}
return nil
}
type DeliveryResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
IsSuccess bool `protobuf:"varint,1,opt,name=is_success,json=isSuccess,proto3" json:"is_success,omitempty"`
}
func (x *DeliveryResponse) Reset() {
*x = DeliveryResponse{}
mi := &file_pusher_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *DeliveryResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DeliveryResponse) ProtoMessage() {}
func (x *DeliveryResponse) ProtoReflect() protoreflect.Message {
mi := &file_pusher_proto_msgTypes[6]
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 DeliveryResponse.ProtoReflect.Descriptor instead.
func (*DeliveryResponse) Descriptor() ([]byte, []int) {
return file_pusher_proto_rawDescGZIP(), []int{6}
}
func (x *DeliveryResponse) GetIsSuccess() bool {
if x != nil {
return x.IsSuccess
}
return false
}
var File_pusher_proto protoreflect.FileDescriptor
var file_pusher_proto_rawDesc = []byte{
0x0a, 0x0c, 0x70, 0x75, 0x73, 0x68, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb2, 0x01, 0x0a, 0x0a, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79,
0x49, 0x6e, 0x66, 0x6f, 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, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20,
0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x42, 0x0b, 0x0a,
0x09, 0x5f, 0x73, 0x75, 0x62, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x22, 0x83, 0x01, 0x0a, 0x17, 0x50,
0x75, 0x73, 0x68, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64,
0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64,
0x65, 0x72, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x74, 0x6f, 0x6b,
0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65,
0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x29, 0x0a, 0x06, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x18,
0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x6f,
0x74, 0x69, 0x66, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x06, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79,
0x22, 0x8c, 0x01, 0x0a, 0x1c, 0x50, 0x75, 0x73, 0x68, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x18, 0x01,
0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x12,
0x23, 0x0a, 0x0d, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x73,
0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x54, 0x6f,
0x6b, 0x65, 0x6e, 0x73, 0x12, 0x29, 0x0a, 0x06, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x18, 0x03,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x6f, 0x74,
0x69, 0x66, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x06, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x22,
0x85, 0x01, 0x0a, 0x09, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x18, 0x0a,
0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07,
0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x20, 0x0a, 0x09, 0x74, 0x65, 0x78, 0x74, 0x5f,
0x62, 0x6f, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x08, 0x74, 0x65,
0x78, 0x74, 0x42, 0x6f, 0x64, 0x79, 0x88, 0x01, 0x01, 0x12, 0x20, 0x0a, 0x09, 0x68, 0x74, 0x6d,
0x6c, 0x5f, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x08,
0x68, 0x74, 0x6d, 0x6c, 0x42, 0x6f, 0x64, 0x79, 0x88, 0x01, 0x01, 0x42, 0x0c, 0x0a, 0x0a, 0x5f,
0x74, 0x65, 0x78, 0x74, 0x5f, 0x62, 0x6f, 0x64, 0x79, 0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x68, 0x74,
0x6d, 0x6c, 0x5f, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x4d, 0x0a, 0x13, 0x44, 0x65, 0x6c, 0x69, 0x76,
0x65, 0x72, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e,
0x0a, 0x02, 0x74, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x74, 0x6f, 0x12, 0x26,
0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x49, 0x6e, 0x66, 0x6f, 0x52,
0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x22, 0x52, 0x0a, 0x18, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65,
0x72, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x02,
0x74, 0x6f, 0x12, 0x26, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28,
0x0b, 0x32, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x49,
0x6e, 0x66, 0x6f, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x22, 0x31, 0x0a, 0x10, 0x44, 0x65,
0x6c, 0x69, 0x76, 0x65, 0x72, 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, 0x32, 0xcf, 0x02,
0x0a, 0x0d, 0x50, 0x75, 0x73, 0x68, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12,
0x4d, 0x0a, 0x10, 0x50, 0x75, 0x73, 0x68, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x75, 0x73, 0x68,
0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x6c, 0x69,
0x76, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x57,
0x0a, 0x15, 0x50, 0x75, 0x73, 0x68, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x12, 0x23, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
0x50, 0x75, 0x73, 0x68, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x45, 0x0a, 0x0c, 0x44, 0x65, 0x6c, 0x69, 0x76,
0x65, 0x72, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x6c, 0x69,
0x76, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4f,
0x0a, 0x11, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x42, 0x61,
0x74, 0x63, 0x68, 0x12, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x6c, 0x69,
0x76, 0x65, 0x72, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x6c,
0x69, 0x76, 0x65, 0x72, 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 (
file_pusher_proto_rawDescOnce sync.Once
file_pusher_proto_rawDescData = file_pusher_proto_rawDesc
)
func file_pusher_proto_rawDescGZIP() []byte {
file_pusher_proto_rawDescOnce.Do(func() {
file_pusher_proto_rawDescData = protoimpl.X.CompressGZIP(file_pusher_proto_rawDescData)
})
return file_pusher_proto_rawDescData
}
var file_pusher_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_pusher_proto_goTypes = []any{
(*NotifyInfo)(nil), // 0: proto.NotifyInfo
(*PushNotificationRequest)(nil), // 1: proto.PushNotificationRequest
(*PushNotificationBatchRequest)(nil), // 2: proto.PushNotificationBatchRequest
(*EmailInfo)(nil), // 3: proto.EmailInfo
(*DeliverEmailRequest)(nil), // 4: proto.DeliverEmailRequest
(*DeliverEmailBatchRequest)(nil), // 5: proto.DeliverEmailBatchRequest
(*DeliveryResponse)(nil), // 6: proto.DeliveryResponse
}
var file_pusher_proto_depIdxs = []int32{
0, // 0: proto.PushNotificationRequest.notify:type_name -> proto.NotifyInfo
0, // 1: proto.PushNotificationBatchRequest.notify:type_name -> proto.NotifyInfo
3, // 2: proto.DeliverEmailRequest.email:type_name -> proto.EmailInfo
3, // 3: proto.DeliverEmailBatchRequest.email:type_name -> proto.EmailInfo
1, // 4: proto.PusherService.PushNotification:input_type -> proto.PushNotificationRequest
2, // 5: proto.PusherService.PushNotificationBatch:input_type -> proto.PushNotificationBatchRequest
4, // 6: proto.PusherService.DeliverEmail:input_type -> proto.DeliverEmailRequest
5, // 7: proto.PusherService.DeliverEmailBatch:input_type -> proto.DeliverEmailBatchRequest
6, // 8: proto.PusherService.PushNotification:output_type -> proto.DeliveryResponse
6, // 9: proto.PusherService.PushNotificationBatch:output_type -> proto.DeliveryResponse
6, // 10: proto.PusherService.DeliverEmail:output_type -> proto.DeliveryResponse
6, // 11: proto.PusherService.DeliverEmailBatch:output_type -> proto.DeliveryResponse
8, // [8:12] is the sub-list for method output_type
4, // [4:8] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
}
func init() { file_pusher_proto_init() }
func file_pusher_proto_init() {
if File_pusher_proto != nil {
return
}
file_pusher_proto_msgTypes[0].OneofWrappers = []any{}
file_pusher_proto_msgTypes[3].OneofWrappers = []any{}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_pusher_proto_rawDesc,
NumEnums: 0,
NumMessages: 7,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_pusher_proto_goTypes,
DependencyIndexes: file_pusher_proto_depIdxs,
MessageInfos: file_pusher_proto_msgTypes,
}.Build()
File_pusher_proto = out.File
file_pusher_proto_rawDesc = nil
file_pusher_proto_goTypes = nil
file_pusher_proto_depIdxs = nil
}

57
pkg/proto/pusher.proto Normal file
View File

@@ -0,0 +1,57 @@
syntax = "proto3";
option go_package = ".;proto";
package proto;
service PusherService {
rpc PushNotification(PushNotificationRequest) returns (DeliveryResponse) {}
rpc PushNotificationBatch(PushNotificationBatchRequest) returns (DeliveryResponse) {}
rpc DeliverEmail(DeliverEmailRequest) returns (DeliveryResponse) {}
rpc DeliverEmailBatch(DeliverEmailBatchRequest) returns (DeliveryResponse) {}
}
// Notifications parts
message NotifyInfo {
string topic = 1;
string title = 2;
optional string subtitle = 3;
string body = 4;
bytes metadata = 5;
int32 priority = 6;
}
message PushNotificationRequest {
string provider = 1;
string device_token = 2;
NotifyInfo notify = 3;
}
message PushNotificationBatchRequest {
repeated string providers = 1;
repeated string device_tokens = 2;
NotifyInfo notify = 3;
}
// Email parts
message EmailInfo {
string subject = 1;
optional string text_body = 2;
optional string html_body = 3;
}
message DeliverEmailRequest {
string to = 1;
EmailInfo email = 2;
}
message DeliverEmailBatchRequest {
repeated string to = 1;
EmailInfo email = 2;
}
message DeliveryResponse {
bool is_success = 1;
}

235
pkg/proto/pusher_grpc.pb.go Normal file
View File

@@ -0,0 +1,235 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v5.28.2
// source: pusher.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.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
PusherService_PushNotification_FullMethodName = "/proto.PusherService/PushNotification"
PusherService_PushNotificationBatch_FullMethodName = "/proto.PusherService/PushNotificationBatch"
PusherService_DeliverEmail_FullMethodName = "/proto.PusherService/DeliverEmail"
PusherService_DeliverEmailBatch_FullMethodName = "/proto.PusherService/DeliverEmailBatch"
)
// PusherServiceClient is the client API for PusherService 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 PusherServiceClient interface {
PushNotification(ctx context.Context, in *PushNotificationRequest, opts ...grpc.CallOption) (*DeliveryResponse, error)
PushNotificationBatch(ctx context.Context, in *PushNotificationBatchRequest, opts ...grpc.CallOption) (*DeliveryResponse, error)
DeliverEmail(ctx context.Context, in *DeliverEmailRequest, opts ...grpc.CallOption) (*DeliveryResponse, error)
DeliverEmailBatch(ctx context.Context, in *DeliverEmailBatchRequest, opts ...grpc.CallOption) (*DeliveryResponse, error)
}
type pusherServiceClient struct {
cc grpc.ClientConnInterface
}
func NewPusherServiceClient(cc grpc.ClientConnInterface) PusherServiceClient {
return &pusherServiceClient{cc}
}
func (c *pusherServiceClient) PushNotification(ctx context.Context, in *PushNotificationRequest, opts ...grpc.CallOption) (*DeliveryResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(DeliveryResponse)
err := c.cc.Invoke(ctx, PusherService_PushNotification_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *pusherServiceClient) PushNotificationBatch(ctx context.Context, in *PushNotificationBatchRequest, opts ...grpc.CallOption) (*DeliveryResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(DeliveryResponse)
err := c.cc.Invoke(ctx, PusherService_PushNotificationBatch_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *pusherServiceClient) DeliverEmail(ctx context.Context, in *DeliverEmailRequest, opts ...grpc.CallOption) (*DeliveryResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(DeliveryResponse)
err := c.cc.Invoke(ctx, PusherService_DeliverEmail_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *pusherServiceClient) DeliverEmailBatch(ctx context.Context, in *DeliverEmailBatchRequest, opts ...grpc.CallOption) (*DeliveryResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(DeliveryResponse)
err := c.cc.Invoke(ctx, PusherService_DeliverEmailBatch_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// PusherServiceServer is the server API for PusherService service.
// All implementations must embed UnimplementedPusherServiceServer
// for forward compatibility.
type PusherServiceServer interface {
PushNotification(context.Context, *PushNotificationRequest) (*DeliveryResponse, error)
PushNotificationBatch(context.Context, *PushNotificationBatchRequest) (*DeliveryResponse, error)
DeliverEmail(context.Context, *DeliverEmailRequest) (*DeliveryResponse, error)
DeliverEmailBatch(context.Context, *DeliverEmailBatchRequest) (*DeliveryResponse, error)
mustEmbedUnimplementedPusherServiceServer()
}
// UnimplementedPusherServiceServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedPusherServiceServer struct{}
func (UnimplementedPusherServiceServer) PushNotification(context.Context, *PushNotificationRequest) (*DeliveryResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method PushNotification not implemented")
}
func (UnimplementedPusherServiceServer) PushNotificationBatch(context.Context, *PushNotificationBatchRequest) (*DeliveryResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method PushNotificationBatch not implemented")
}
func (UnimplementedPusherServiceServer) DeliverEmail(context.Context, *DeliverEmailRequest) (*DeliveryResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method DeliverEmail not implemented")
}
func (UnimplementedPusherServiceServer) DeliverEmailBatch(context.Context, *DeliverEmailBatchRequest) (*DeliveryResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method DeliverEmailBatch not implemented")
}
func (UnimplementedPusherServiceServer) mustEmbedUnimplementedPusherServiceServer() {}
func (UnimplementedPusherServiceServer) testEmbeddedByValue() {}
// UnsafePusherServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to PusherServiceServer will
// result in compilation errors.
type UnsafePusherServiceServer interface {
mustEmbedUnimplementedPusherServiceServer()
}
func RegisterPusherServiceServer(s grpc.ServiceRegistrar, srv PusherServiceServer) {
// If the following call pancis, it indicates UnimplementedPusherServiceServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&PusherService_ServiceDesc, srv)
}
func _PusherService_PushNotification_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(PushNotificationRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PusherServiceServer).PushNotification(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: PusherService_PushNotification_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PusherServiceServer).PushNotification(ctx, req.(*PushNotificationRequest))
}
return interceptor(ctx, in, info, handler)
}
func _PusherService_PushNotificationBatch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(PushNotificationBatchRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PusherServiceServer).PushNotificationBatch(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: PusherService_PushNotificationBatch_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PusherServiceServer).PushNotificationBatch(ctx, req.(*PushNotificationBatchRequest))
}
return interceptor(ctx, in, info, handler)
}
func _PusherService_DeliverEmail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DeliverEmailRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PusherServiceServer).DeliverEmail(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: PusherService_DeliverEmail_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PusherServiceServer).DeliverEmail(ctx, req.(*DeliverEmailRequest))
}
return interceptor(ctx, in, info, handler)
}
func _PusherService_DeliverEmailBatch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DeliverEmailBatchRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PusherServiceServer).DeliverEmailBatch(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: PusherService_DeliverEmailBatch_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PusherServiceServer).DeliverEmailBatch(ctx, req.(*DeliverEmailBatchRequest))
}
return interceptor(ctx, in, info, handler)
}
// PusherService_ServiceDesc is the grpc.ServiceDesc for PusherService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var PusherService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "proto.PusherService",
HandlerType: (*PusherServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "PushNotification",
Handler: _PusherService_PushNotification_Handler,
},
{
MethodName: "PushNotificationBatch",
Handler: _PusherService_PushNotificationBatch_Handler,
},
{
MethodName: "DeliverEmail",
Handler: _PusherService_DeliverEmail_Handler,
},
{
MethodName: "DeliverEmailBatch",
Handler: _PusherService_DeliverEmailBatch_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "pusher.proto",
}