tecmq

package
v0.0.0-...-f77605d Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MulanPSL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SourceDigital         = 1
	SourceDigitalProduce  = 2
	DigitalProduceSubject = "digital.produce"
)
View Source
const (
	ChannelTypeEmail    = 1 // 邮件
	ChannelTypeWebhook  = 2 // WebHook
	ChannelTypeDingDing = 3 // 钉钉

	DefaultMessageSubject = "message-service.message"
)

Variables

This section is empty.

Functions

func HandlerFucAndAck

func HandlerFucAndAck(f func(msgC *MqMsg)) func(msg *nats.Msg)

func JsHandlerFucAndAck

func JsHandlerFucAndAck(f func(msgC *JsMqMsg)) func(msg jetstream.Msg)

JsHandlerFucAndAck func(msg Msg)

func NatsJsClient

func NatsJsClient(url string, jsName string, subjects []string) (*nats.Conn, nats.JetStreamContext, error)

func NewEncodedNatsClient

func NewEncodedNatsClient(url string) (*nats.EncodedConn, error)

func NewNatsClient

func NewNatsClient(url string) (*nats.Conn, error)

Types

type DigitalProduceMsg

type DigitalProduceMsg struct {
	Source           uint8                    `json:"source"` // 服务来源类型 1-事件监控系统 2-监控告警系统 3-....
	Data             []*DigitalProduceMsgData // 发送消息信息
	SourceCreateTime time.Time                // 消息创建时间
}

type DigitalProduceMsgData

type DigitalProduceMsgData struct {
	BackgroundUri       string `json:"background_uri"`
	FaceVideo           string `json:"face_video"`
	AudionUri           string `json:"audion_uri"`
	StoryboardId        int32  `json:"storyboard_id"`
	StoryboardSectionId int32  `json:"storyboard_section_id"`
	Payload             string `json:"payload"`
}

DigitalProduceMsgData 订阅主题使用的消息

type JsMqMsg

type JsMqMsg struct {
	Msg jetstream.Msg
}

type JsMsgHandlerFunc

type JsMsgHandlerFunc func(msg jetstream.Msg) // 回调处理方法

type MqMsg

type MqMsg struct {
	Msg *nats.Msg
}

type MqSub

type MqSub struct {
	Sub *nats.Subscription
}

type MsgData

type MsgData struct {
	Title      string                 `json:"title"`
	Payload    map[string]interface{} `json:"payload"`     // 消息体
	TemplateId int                    `json:"template_id"` // 模板id
	Receivers  []Receiver             `json:"receivers"`   // 消息接收者
	Type       uint8                  `json:"type"`        // 通道类型 1-邮件 2-WebHook
}

type MsgHandlerFunc

type MsgHandlerFunc func(msg *nats.Msg) // 回调处理方法

type Msgs

type Msgs struct {
	Source           uint8      `json:"source"` // 服务来源类型 1-事件监控系统 2-监控告警系统 3-....
	Data             []*MsgData // 发送消息信息
	SourceCreateTime time.Time  // 消息创建时间
}

func NewTestMsg

func NewTestMsg() *Msgs

NewTestMsg 测试消息生成例子

type NatJs

type NatJs struct {
	Url     string
	JsName  string
	Subject []string
	JsCtx   nats.JetStreamContext
	Js      jetstream.JetStream
	Nc      *nats.Conn
}

func NewNatsJsSubPushQueueClient

func NewNatsJsSubPushQueueClient(url, jsName string, subject []string) (*NatJs, error)

func (*NatJs) CloseNc

func (n *NatJs) CloseNc()

func (*NatJs) CreateOrUpdateConsumer

func (n *NatJs) CreateOrUpdateConsumer(conName string) (jetstream.Consumer, error)

func (*NatJs) Drain

func (n *NatJs) Drain()

func (*NatJs) Flush

func (n *NatJs) Flush()

func (*NatJs) JsConsumerSub

func (n *NatJs) JsConsumerSub(conName string, f func(msg *JsMqMsg)) (jetstream.ConsumeContext, error)

func (*NatJs) JsConsumerSubStop

func (n *NatJs) JsConsumerSubStop(c jetstream.ConsumeContext)

func (*NatJs) JsPushMessage

func (n *NatJs) JsPushMessage(subject string, b []byte) error

JsPushMessage 发送消息

func (*NatJs) JsQueueSub

func (n *NatJs) JsQueueSub(subject, queue, consumer string, f func(msgC *MqMsg)) (*MqSub, error)

JsQueueSub 订阅一个js队列消息

func (*NatJs) JsQueueSubSync

func (n *NatJs) JsQueueSubSync(subject, queue string) (*MqSub, error)

func (*NatJs) PushProduceCallBack

func (n *NatJs) PushProduceCallBack(subject string, msgD *ProduceResultMsg) error

func (*NatJs) PushProduceMessage

func (n *NatJs) PushProduceMessage(subject string, msgD *DigitalProduceMsg) error

PushProduceMessage to ProduceServer 发送生产视频的消息

type NatQueueCon

type NatQueueCon struct {
	Url string
	Nc  *nats.Conn
}

func NewNatsSubPushClient

func NewNatsSubPushClient(url string) (*NatQueueCon, error)

func (*NatQueueCon) CloseNc

func (n *NatQueueCon) CloseNc()

func (*NatQueueCon) Drain

func (n *NatQueueCon) Drain() error

func (*NatQueueCon) Flush

func (n *NatQueueCon) Flush() error

func (*NatQueueCon) Push

func (n *NatQueueCon) Push(subject string, b []byte) error

func (*NatQueueCon) PushMessage

func (n *NatQueueCon) PushMessage(subject string, msgD *Msgs) error

PushMessage to MessageService 发送消息

func (*NatQueueCon) QueueSub

func (n *NatQueueCon) QueueSub(subject, queue string, f func(msgC *MqMsg)) (*MqSub, error)

QueueSub 订阅一个队列消息

func (*NatQueueCon) QueueSubSync

func (n *NatQueueCon) QueueSubSync(subject, queue string) (*MqSub, error)

QueueSubSync 订阅一个js队列消息

func (*NatQueueCon) Sub

func (n *NatQueueCon) Sub(subject string, f func(msgC *MqMsg)) (*MqSub, error)

func (*NatQueueCon) SubSync

func (n *NatQueueCon) SubSync(subject string) (*MqSub, error)

type ProduceCallbackMsg

type ProduceCallbackMsg struct {
	StoryboardId        int32  `json:"storyboard_id"`
	StoryboardSectionId int32  `json:"storyboard_section_id"`
	OutFile             string `json:"out_file"`
	IsSuccess           int32  `json:"is_success"`
	Duration            string `json:"duration"`
}

type ProduceResultMsg

type ProduceResultMsg struct {
	Source           uint8               `json:"source"` // 服务来源类型 1-事件监控系统 2-监控告警系统 3-....
	Data             *ProduceCallbackMsg // 发送消息信息
	SourceCreateTime time.Time           // 消息创建时间
}

type Receiver

type Receiver struct {
	Id      string `json:"contacts_id"`   // 联系人ID
	Name    string `json:"contacts_name"` // 联系人名称
	Address string `json:"address"`       // 通知地址
}

type SnapShotMap

type SnapShotMap struct {
	Namespace    string
	NotebookName string
	ProjectId    string
	SaveStatus   bool
	Address      string
}

type UserMsgUser

type UserMsgUser struct {
	ID    string // 用户在casdoor的id  uuid
	Name  string
	Email string
}

Jump to

Keyboard shortcuts

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