package paopaoqueue import ( "context" "encoding/json" "fmt" "git.banshen.xyz/huangguangrong/paopaoqueue/types" "github.com/zeromicro/go-queue/kq" ) type UserBillTransferClient interface { Push(msg *types.UserBillContentData) error } type userBillTransferClient struct { pusher *kq.Pusher } func NewUserBillTransferClient(addr []string, topic string, opts ...kq.Pusher) UserBillTransferClient { fmt.Println("topic: ", topic) return &userBillTransferClient{pusher: kq.NewPusher(addr, topic)} } func (m *userBillTransferClient) Push(msg *types.UserBillContentData) error { data, err := json.Marshal(msg) if err != nil { return err } return m.pusher.Push(context.Background(), string(data)) }