Pushcon SDK

This commit is contained in:
LittleSheep 2024-10-26 23:30:52 +08:00
parent 478d18d75f
commit cd2c326efa
3 changed files with 45 additions and 0 deletions

1
go.mod
View File

@ -12,6 +12,7 @@ require (
github.com/nats-io/nats.go v1.37.0
github.com/robfig/cron/v3 v3.0.1
github.com/rs/zerolog v1.33.0
github.com/samber/lo v1.47.0
github.com/sideshow/apns2 v0.24.0
github.com/spf13/viper v1.19.0
google.golang.org/api v0.171.0

2
go.sum
View File

@ -279,6 +279,8 @@ github.com/sagikazarmark/locafero v0.6.0 h1:ON7AQg37yzcRPU69mt7gwhFEBwxI6P9T4Qu3
github.com/sagikazarmark/locafero v0.6.0/go.mod h1:77OmuIc6VTraTXKXIs/uvUxKGUXjE1GbemJYHqdNjX0=
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
github.com/samber/lo v1.47.0 h1:z7RynLwP5nbyRscyvcD043DWYoOcYRv3mV8lBeqOCLc=
github.com/samber/lo v1.47.0/go.mod h1:RmDH9Ct32Qy3gduHQuKJ3gW1fMHAnE/fAzQuf6He5cU=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/sideshow/apns2 v0.24.0 h1:syofL4rd8ZeqUVySgYyBSYr/oLMU/HzJi++r3FIp6Z4=

View File

@ -0,0 +1,42 @@
package pushcon
import (
"git.solsynth.dev/hypernet/nexus/pkg/nex"
"git.solsynth.dev/hypernet/nexus/pkg/nex/rx"
"git.solsynth.dev/hypernet/pusher/pkg/pushkit"
)
type Conn struct {
n *nex.Conn
mq *rx.MqConn
}
func NewConn(conn *nex.Conn) (*Conn, error) {
c := &Conn{
n: conn,
}
if mq, err := rx.NewMqConn(conn); err != nil {
return nil, err
} else {
c.mq = mq
}
return c, nil
}
func (v *Conn) PushNotify(in pushkit.NotificationPushRequest) error {
return v.mq.Nt.Publish(pushkit.PushNotificationMqTopic, nex.EncodeMap(in))
}
func (v *Conn) PushNotifyBatch(in pushkit.NotificationPushBatchRequest) error {
return v.mq.Nt.Publish(pushkit.PushNotificationBatchMqTopic, nex.EncodeMap(in))
}
func (v *Conn) PushEmail(in pushkit.EmailDeliverRequest) error {
return v.mq.Nt.Publish(pushkit.PushEmailMqTopic, nex.EncodeMap(in))
}
func (v *Conn) PushEmailBatch(in pushkit.EmailDeliverBatchRequest) error {
return v.mq.Nt.Publish(pushkit.PushEmailBatchMqTopic, nex.EncodeMap(in))
}