message

package
v0.0.0-...-5891a38 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Header map[string]interface{}

func (Header) Get

func (m Header) Get(key string) interface{}

func (Header) Set

func (m Header) Set(key string, value interface{})

type Message

type Message struct {
	UUID    string
	Topic   string
	SvcName string
	Header  Header
	Payload []byte
	Policy  *Policy

	AckChan    chan struct{} `msgpack:"-"`
	RejectChan chan struct{} `msgpack:"-"`
	// contains filtered or unexported fields
}

func NewMessage

func NewMessage(uuid, topic string, payload []byte, opts ...PolicyOption) *Message

func (*Message) Ack

func (m *Message) Ack()

func (*Message) Acked

func (m *Message) Acked() <-chan struct{}

func (*Message) Reject

func (m *Message) Reject()

func (*Message) Rejected

func (m *Message) Rejected() <-chan struct{}

func (*Message) Reset

func (m *Message) Reset(uuid, topic string, payload []byte, opts ...PolicyOption)

type Policy

type Policy struct {
	Confirm bool
	Durable bool
	TTL     time.Duration
	Delay   int64
}

Policy Message Policy

func DefaultMessagePolicy

func DefaultMessagePolicy() *Policy

type PolicyOption

type PolicyOption func(c *Policy)

func WithConfirm

func WithConfirm(use bool) PolicyOption

WithConfirm 开启Confirm,会使用本地消息表保存消息,联合mq的Confirm机制

func WithDelay

func WithDelay(delay int64) PolicyOption

WithDelay 延时队列

func WithDurable

func WithDurable(use bool) PolicyOption

WithDurable 是否消息持久化,默认开启

func WithTTL

func WithTTL(duration time.Duration) PolicyOption

WithTTL 关联消息过期时间 默认

Jump to

Keyboard shortcuts

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