message_queue

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 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

推送 - 系统通知

func PublishUserMessage added in v0.7.0

func PublishUserMessage(messageID string) error

推送 - 用户个人消息

Types

type BodySendActivationEmail

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

type BodySendNotify

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

func (*BodySendNotify) ToByte

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

type Chanel

type Chanel string

type PayloadPublishCheckUserLoginStatus

type PayloadPublishCheckUserLoginStatus struct {
	UserID string `json:"user_id" validate:"required" comment:"用户ID"`
}

type PayloadPublishSystemNotification

type PayloadPublishSystemNotification struct {
	NotificationID string `json:"notification_id" validate:"required" comment:"系统通知 ID"`
}

type PayloadPublishUserMessage added in v0.7.0

type PayloadPublishUserMessage struct {
	MessageID string `json:"message_id"`
}

type PayloadToAllUsers

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

type PayloadToSpecificUsers

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

type Topic

type Topic string

Jump to

Keyboard shortcuts

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