message

package
v0.0.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hash

type Hash string

Hash 消息哈希.

const (
	HashDatetime       = "060102150405" // 240506091011
	HashUndefined Hash = ""
)

func NewHash

func NewHash() Hash

NewHash 创建消息哈希.

此方法产生的消息哈希(格式: 日期-时间戳-随机数-随机数), 同一个微秒级内有重复的概率(极低).

func (Hash) String

func (o Hash) String() string

String 消息ID字符串.

func (Hash) Undefined

func (o Hash) Undefined() bool

Undefined 是否未定义, 若 Hash 值为空, 则为未定义.

type Message

type Message struct {
	ConsumedCount int // 消费次数(从队列出取出次数).
	ProducedCount int // 发布次数(发布到主题次数,如延时,死信等).

	Body      []byte         // 消息内容.
	MessageId string         // 消息ID.
	Queue     name.QueueName // 队列名.
	Tag       string         // 消息标签名.
	Time      time.Time      // 消息发布时间.
	Topic     name.TopicName // 消息主题名.
	// contains filtered or unexported fields
}

Message 从MQ中收到的消息.

func NewMessage

func NewMessage(ctx context.Context) *Message

NewMessage 从池中取中实例.

func NewMessageFromRabbitmq

func NewMessageFromRabbitmq(ctx context.Context, msg amqp.Delivery) *Message

NewMessageFromRabbitmq 从池中取中实例.

实例取出后, 将 Rabbitmq 消息格式转换成标准消息.

func (*Message) Context

func (o *Message) Context() context.Context

Context 消息上下文.

func (*Message) Release

func (o *Message) Release()

Release 释放消息回池.

type Payload

type Payload struct {

	// 2. 消息字段.
	Body    []byte
	Keyword string
	Tag     string
	Topic   string
	// contains filtered or unexported fields
}

Payload 向MQ发送的消息.

func NewPayload

func NewPayload(ctx context.Context) *Payload

NewPayload 从池中取中实例.

func (*Payload) Context

func (o *Payload) Context() context.Context

Context 消息上下文.

func (*Payload) Hash

func (o *Payload) Hash() Hash

Hash 取消息哈希.

func (*Payload) Release

func (o *Payload) Release()

Release 释放消息回池.

func (*Payload) Time

func (o *Payload) Time() time.Time

Time 消息生产时间.

func (*Payload) ToRabbitmq

func (o *Payload) ToRabbitmq() amqp.Publishing

Jump to

Keyboard shortcuts

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