Documentation
¶
Index ¶
- Constants
- type Bus
- func (bus *Bus) Publish(topic string, payload []byte, opts ...message.PolicyOption) error
- func (bus *Bus) Shutdown() error
- func (bus *Bus) Start() error
- func (bus *Bus) Subscribe(topic string) *routerTopic
- func (bus *Bus) Transaction(tx *sql.Tx, fc func(txBus *TxBus) error) error
- func (bus *Bus) WithTx(tx *sql.Tx) *TxBus
- type Context
- type HandlerFunc
- type HandlerMiddleware
- type Options
- func (opt Options) WithNumAcker(val int) Options
- func (opt Options) WithNumSubscriber(val int) Options
- func (opt Options) WithOutboxScanAgoTime(val int64) Options
- func (opt Options) WithOutboxScanInterval(val time.Duration) Options
- func (opt Options) WithOutboxScanOffset(val int64) Options
- func (opt Options) WithPurgeOnStartup(val bool) Options
- func (opt Options) WithRetryCount(val uint) Options
- func (opt Options) WithRetryInterval(val time.Duration) Options
- type TxBus
Constants ¶
const (
OutBoxRecordStatusPending uint8 = iota // 客户端发送消息,消息表中的默认状态, 等待 mq 的 confirm ack
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bus ¶
type Bus struct {
// contains filtered or unexported fields
}
func New ¶
New 初始化Bus db sql.DB 本地消息表使用到的db mqProvider mq.IProvider mq驱动实现,用于与消息队列交互, amqp 的实现 amqp_provider.Provider
func (*Bus) Transaction ¶
type Context ¶
type HandlerFunc ¶
type HandlerMiddleware ¶
type HandlerMiddleware func(h HandlerFunc) HandlerFunc
type Options ¶
type Options struct { PurgeOnStartup bool // 启动Bus时是否清除遗留的消息,包含(mq遗留的消息,和本地消息表遗留的消息) // RetryCount retry count of message processing failed // Does not include the first attempt RetryCount uint // RetryCount retry interval of message processing failed RetryInterval time.Duration // outbox opt OutboxScanInterval time.Duration // 扫描outbox没有收到ack的消息间隔 OutboxScanOffset int64 // 扫描outbox没有收到ack的消息偏移量 OutboxScanAgoTime time.Duration // 扫描多久之前的消息 NumSubscriber int // subscriber number NumAcker int // acker number }
func (Options) WithNumAcker ¶
WithNumAcker sets the number of acker Each acker runs in an independent goroutine The default value of NumAcker is 5.
func (Options) WithNumSubscriber ¶
WithNumSubscriber sets the number of subscriber Each subscriber runs in an independent goroutine The default value of NumSubscriber is 5.
func (Options) WithOutboxScanAgoTime ¶
WithOutboxScanAgoTime 设置扫描多久之前的消息 The default value of OutboxScanAgoTime is 1 minute.
func (Options) WithOutboxScanInterval ¶
WithOutboxScanInterval 设置扫描outbox没有收到ack的消息间隔 The default value of OutboxScanInterval is 1 minute.
func (Options) WithOutboxScanOffset ¶
WithOutboxScanOffset 设置扫描outbox没有收到ack的消息的偏移量 The default value of OutboxScanOffset is 500.
func (Options) WithPurgeOnStartup ¶
WithPurgeOnStartup 设置启动Bus时是否清除遗留的消息 包含(mq遗留的消息,和本地消息表遗留的消息) The default value of PurgeOnStartup is false.
func (Options) WithRetryCount ¶
WithRetryCount sets the retry count of message processing failed Does not include the first attempt The default value of RetryCount is 3.