mq

package
v0.0.0-...-a9153d3 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WechatKey   = "notify.wechat"
	DingTalkKey = "notify.dingtalk"

	UserIdKey = "userId"
)

Variables

This section is empty.

Functions

func MarshalDingTalkBody

func MarshalDingTalkBody(staffId string, msg *DingTalkNoticeBody) (data []byte, err error)

func MarshalWechatBody

func MarshalWechatBody(staffId string, msg *WeChatNoticeBody) (data []byte, err error)

Types

type Consumer

type Consumer struct {
	Conn       *amqp.Connection
	Channel    *amqp.Channel
	Tag        string
	Done       chan error
	Deliveries <-chan amqp.Delivery
}

func NewConsumer

func NewConsumer(amqpURI, key string) (*Consumer, error)

func (*Consumer) Shutdown

func (c *Consumer) Shutdown() error

type DingTalkBody

type DingTalkBody struct {
	StaffId string `json:"staffId"`
	*DingTalkNoticeBody
	MessageId string `json:"messageId"`
}

type DingTalkMsgLinkInput

type DingTalkMsgLinkInput struct {
	MessageUrl string `json:"messageUrl"`
	PicUrl     string `json:"picUrl"`
	Title      string `json:"title"`
	Text       string `json:"text"`
}

type DingTalkMsgMarkdownInput

type DingTalkMsgMarkdownInput struct {
	Title string `json:"title"` // 这个是点进推送列表前显示的简短的消息(进入后不可见)
	Text  string `json:"text"`  // 这个是进入后显示的详细的消息
}

type DingTalkMsgPlainTextInput

type DingTalkMsgPlainTextInput struct {
	Content string `json:"content"`
}

type DingTalkNoticeBody

type DingTalkNoticeBody struct {
	MsgType  string                     `json:"msgtype"`
	Text     *DingTalkMsgPlainTextInput `json:"text,omitempty"`
	Link     *DingTalkMsgLinkInput      `json:"link,omitempty"`
	Markdown *DingTalkMsgMarkdownInput  `json:"markdown,omitempty"`
}

func UnmarshalDingTalkBody

func UnmarshalDingTalkBody(data []byte) (*DingTalkNoticeBody, error)

func (*DingTalkNoticeBody) LinkMsg

func (t *DingTalkNoticeBody) LinkMsg(messageUrl, picUrl, title, text string)

func (*DingTalkNoticeBody) MarkdownMsg

func (t *DingTalkNoticeBody) MarkdownMsg(title, text string)

func (*DingTalkNoticeBody) PlainText

func (t *DingTalkNoticeBody) PlainText(content string)

type NoticeTemplate

type NoticeTemplate struct {
	StaffID  []string            `json:"StaffID"`
	WeChat   *WeChatNoticeBody   `json:"template,omitempty"`
	DingTalk *DingTalkNoticeBody `json:"dingtalk,omitempty"`
	// contains filtered or unexported fields
}

func New

func New() *NoticeTemplate

func (*NoticeTemplate) NewDingTalk

func (t *NoticeTemplate) NewDingTalk() *DingTalkNoticeBody

func (*NoticeTemplate) NewWeChat

func (t *NoticeTemplate) NewWeChat() *WeChatNoticeBody

func (*NoticeTemplate) Receiver

func (t *NoticeTemplate) Receiver(staffId ...string) *NoticeTemplate

func (*NoticeTemplate) WithContext

func (t *NoticeTemplate) WithContext(ctx context.Context) *NoticeTemplate

type Producer

type Producer struct {
	Conn    *amqp.Connection
	Channel *amqp.Channel
	// contains filtered or unexported fields
}

func NewProducer

func NewProducer(appId string, amqpURI string) (*Producer, error)

func (*Producer) PublishNotice

func (p *Producer) PublishNotice(ctx context.Context, data *NoticeTemplate, options ...string) error

func (*Producer) Shutdown

func (p *Producer) Shutdown() error

type RabbitMQHeaderCarrier

type RabbitMQHeaderCarrier amqp.Table

RabbitMQHeaderCarrier adapts http.Header to satisfy the TextMapCarrier interface.

func (RabbitMQHeaderCarrier) Get

func (hc RabbitMQHeaderCarrier) Get(key string) string

Get returns the value associated with the passed key.

func (RabbitMQHeaderCarrier) Keys

func (hc RabbitMQHeaderCarrier) Keys() []string

Keys lists the keys stored in this carrier.

func (RabbitMQHeaderCarrier) Set

func (hc RabbitMQHeaderCarrier) Set(key string, value string)

Set stores the key-value pair.

type UniNotifyInput

type UniNotifyInput struct {
	Title    string
	SubTitle string
	Content  string
	Extra    string
}

type WeChatNoticeBody

type WeChatNoticeBody struct {
	Data       map[string]*message.TemplateDataItem `json:"data"`
	TemplateID string                               `json:"template_id"`
	ToUser     string                               `json:"touser"`
	URL        string                               `json:"url"`
}

func (*WeChatNoticeBody) SetData

func (t *WeChatNoticeBody) SetData(key, value, color string) *WeChatNoticeBody

func (*WeChatNoticeBody) SetTmpl

func (t *WeChatNoticeBody) SetTmpl(templateId string) *WeChatNoticeBody

func (*WeChatNoticeBody) Url

type WechatBody

type WechatBody struct {
	StaffId string `json:"staffId"`
	*WeChatNoticeBody
	MessageId string `json:"messageId"`
}

func UnmarshalWechatBody

func UnmarshalWechatBody(data []byte) (*WechatBody, error)

Jump to

Keyboard shortcuts

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