| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- package paopaoqueue
- import (
- "context"
- "encoding/json"
- "git.banshen.xyz/huangguangrong/slow_wild_queue/types"
- "github.com/zeromicro/go-queue/kq"
- )
- type MsgChatTransferClient interface {
- Push(msg *types.MsgChatTransfer) error
- }
- type msgChatTransferClient struct {
- pusher *kq.Pusher
- }
- func NewMsgChatTransferClient(addr []string, topic string, opts ...kq.Pusher) MsgChatTransferClient {
- return &msgChatTransferClient{pusher: kq.NewPusher(addr, topic)}
- }
- func (m *msgChatTransferClient) Push(msg *types.MsgChatTransfer) error {
- data, err := json.Marshal(msg)
- if err != nil {
- return err
- }
- return m.pusher.Push(context.Background(), string(data))
- }
- type MsgReadTransferClient interface {
- Push(msg *types.MsgMarkRead) error
- }
- type msgReadTransferClient struct {
- pusher *kq.Pusher
- }
- func NewMsgReadTransferClient(addr []string, topic string, opts ...kq.Pusher) MsgReadTransferClient {
- return &msgReadTransferClient{pusher: kq.NewPusher(addr, topic)}
- }
- func (m *msgReadTransferClient) Push(msg *types.MsgMarkRead) error {
- data, err := json.Marshal(msg)
- if err != nil {
- return err
- }
- return m.pusher.Push(context.Background(), string(data))
- }
- // 消息推送
- type MsgPushClientTransferClient interface {
- Push(msg *types.MessagePushData) error
- }
- type msgPushClientTransferClient struct {
- pusher *kq.Pusher
- }
- func NewMsgPushClientTransferClient(addr []string, topic string, opts ...kq.Pusher) MsgPushClientTransferClient {
- return &msgPushClientTransferClient{pusher: kq.NewPusher(addr, topic)}
- }
- func (m *msgPushClientTransferClient) Push(msg *types.MessagePushData) error {
- data, err := json.Marshal(msg)
- if err != nil {
- return err
- }
- return m.pusher.Push(context.Background(), string(data))
- }
|