message_queue

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Copyright 2019-2020 Axetroy. All rights reserved. MIT license.

Index

Constants

This section is empty.

Variables

View Source
var (
	TopicSendEmail   Topic       = "topic_send_email"
	ChanelSendEmail  Chanel      = "chanel_send_email"
	TopicPushNotify  Topic       = "topic_push_notify"
	ChanelPushNotify Chanel      = "chanel_push_notify"
	Address                      = net.JoinHostPort(config.MessageQueue.Host, config.MessageQueue.Port) // 消息队列地址
	Config           *nsq.Config                                                                        // 消息队列的配置
)

Functions

func CreateConsumer

func CreateConsumer(topic Topic, channel Chanel, handler nsq.Handler) (c *nsq.Consumer, err error)

创建消费者

func DeferredPublish

func DeferredPublish(topic Topic, delay time.Duration, message []byte) (err error)

func Publish

func Publish(topic Topic, message []byte) (err error)

发布消息

func PublishCheckUserLogin

func PublishCheckUserLogin(userID string) error

推送 - 检查用户的登录状态

func PublishNotifyToAllUser

func PublishNotifyToAllUser(title string, content string, delay time.Duration, data map[string]interface{}) error

发送到消息队列 - 发送推送给所有用户

func PublishNotifyToSpecificUser

func PublishNotifyToSpecificUser(userId []string, title string, content string, delay time.Duration, data map[string]interface{}) error

发送到消息队列 - 发送推送给特定用户

func PublishSystemNotify

func PublishSystemNotify(notificationID string) error

推送 - 系统通知

Types

type BodySendActivationEmail

type BodySendActivationEmail struct {
	Email string `json:"email" valid:"required"` // 要发送的邮箱
	Code  string `json:"code" valid:"required"`  // 发送的激活码
}

type BodySendNotify

type BodySendNotify struct {
	Event   notify.Event `json:"event" valid:"required"`   // 事件名称
	Payload interface{}  `json:"payload" valid:"required"` // 数据体
}

func (*BodySendNotify) ToByte

func (c *BodySendNotify) ToByte() ([]byte, error)

type Chanel

type Chanel string

type PayloadPublishCheckUserLoginStatus

type PayloadPublishCheckUserLoginStatus struct {
	UserID string `json:"user_id" valid:"required"`
}

type PayloadPublishSystemNotification

type PayloadPublishSystemNotification struct {
	NotificationID string `json:"notification_id" valid:"required"`
}

type PayloadToAllUsers

type PayloadToAllUsers struct {
	Title   string                 `json:"title" valid:"required"`   // 推送的标题
	Content string                 `json:"content" valid:"required"` // 推送的内容
	Data    map[string]interface{} `json:"data"`                     // 附带给 APP 的数据
}

type PayloadToSpecificUsers

type PayloadToSpecificUsers struct {
	UserID  []string               `json:"user_id" valid:"required"` // 要指定的推送用户 ID
	Title   string                 `json:"title" valid:"required"`   // 推送的标题
	Content string                 `json:"content" valid:"required"` // 推送的内容
	Data    map[string]interface{} `json:"data"`                     // 附带给 APP 的数据
}

type Topic

type Topic string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL