rmqtool

package
v0.0.59 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitializeConsumer

func InitializeConsumer(config *RmqConfig, consumerConfig *ConsumerConfig, opts ...consumer.Option)

func SetRLogLevelToError added in v0.0.30

func SetRLogLevelToError()

Types

type ConsumerConfig

type ConsumerConfig struct {
	Topic                      string
	Tag                        string
	Group                      string // consumer group
	Order                      bool   // fifo message
	ConsumerMode               ConsumerMode
	ConsumeConcurrentlyMaxSpan int // default 1000
	MsgHandler                 func(ctx context.Context, msgs ...*primitive.MessageExt) (consumer.ConsumeResult, error)
}

type ConsumerMode

type ConsumerMode int
const (
	SingleMode ConsumerMode = iota // 同樣group中的的consumer 只會有一個consumer收到訊息
	PubSubMode                     // pub/sub mode 用於水平擴展 group 中的所有consumer 都會收到同一條消息
)

type Rmq

type Rmq struct {
	Producer *rocketmq.Producer
}

func InitializePublisher

func InitializePublisher(config *RmqConfig) *Rmq

func InitializeQueuePublisher added in v0.0.59

func InitializeQueuePublisher(config *RmqConfig) *Rmq

func (*Rmq) Send

func (rmq *Rmq) Send(msg *RmqMsg, shardingKey ...string) error

func (*Rmq) SendAsync added in v0.0.32

func (rmq *Rmq) SendAsync(msg *RmqMsg) error

func (*Rmq) SendOneWay added in v0.0.51

func (rmq *Rmq) SendOneWay(msg *RmqMsg) error

type RmqConfig

type RmqConfig struct {
	NameServers []string
}

type RmqMsg

type RmqMsg struct {
	Topic string
	Tag   string
	Keys  []string
	Body  []byte
}

Jump to

Keyboard shortcuts

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