| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- package mqClient
- import (
- "context"
- "encoding/json"
- "github.com/zeromicro/go-queue/kq"
- "paopaoimtask/mq"
- )
- type MsgChatTransferClient interface {
- Push(msg *mq.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 *mq.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 *mq.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 *mq.MsgMarkRead) error {
- data, err := json.Marshal(msg)
- if err != nil {
- return err
- }
- return m.pusher.Push(context.Background(), string(data))
- }
|