broker

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Defaultopt = Options{
	SerializeProtocol: "JSON",
	ClientID:          randomkey.GetMachineID(),
	UUIDType:          "sonyflake",
	BlockTime:         1000 * time.Millisecond,
	RecvBatchSize:     1,
	Group:             "",
	AckMode:           AckModeAckWhenGet,
	Start:             "",
}
View Source
var ErrUnSupportSerializeProtocol = errors.New("未支持的序列化协议")

ErrUnSupportSerializeProtocol 未支持的序列化协议

Functions

This section is empty.

Types

type AckModeType

type AckModeType uint16

AckModeType stream的Ack模式

const (

	//AckModeAckWhenGet 获取到后确认
	AckModeAckWhenGet AckModeType = iota
	//AckModeAckWhenDone 处理完后确认
	AckModeAckWhenDone
	//AckModeNoAck 不做确认,消费者需要自己实现ack操作,最好别这么用
	AckModeNoAck
)

type Option

type Option interface {
	Apply(*Options)
}

Option configures how we set up the connection.

func SerializeWithJSON

func SerializeWithJSON() Option

SerializeWithJSON 使用JSON作为序列化反序列化的协议

func SerializeWithMsgpack

func SerializeWithMsgpack() Option

SerializeWithMsgpack 使用JSON作为序列化反序列化的协议

func WithBlockTime

func WithBlockTime(d time.Duration) Option

WithBlockTime 设置客户端阻塞等待消息的时长

func WithClientID

func WithClientID(clientID uint16) Option

WithClientID 设置

func WithStreamComsumerAckMode

func WithStreamComsumerAckMode(ack AckModeType) Option

WithStreamComsumerAckMode stream消费者专用,用于设定同步校验规则

func WithStreamComsumerGroupName

func WithStreamComsumerGroupName(groupname string) Option

WithStreamComsumerGroupName stream消费者专用,用于设定客户端组

func WithStreamComsumerRecvBatchSize

func WithStreamComsumerRecvBatchSize(size int64) Option

WithStreamComsumerRecvBatchSize stream消费者专用,用于设定一次获取的消息批长度

func WithStreamComsumerStartAt

func WithStreamComsumerStartAt(t time.Time) Option

WithStreamComsumerAckMode stream消费者专用,用于设定同步校验规则

func WithStreamComsumerStartAtID

func WithStreamComsumerStartAtID(id string) Option

WithStreamComsumerAckMode stream消费者专用,用于设定同步校验规则

func WithUUIDSonyflake

func WithUUIDSonyflake() Option

WithUUIDSonyflake 使用sonyflake作为uuid的生成器

func WithUUIDv4

func WithUUIDv4() Option

WithUUIDv4 使用uuid4作为uuid的生成器

type Options

type Options struct {
	SerializeProtocol string
	ClientID          uint16
	UUIDType          string
	BlockTime         time.Duration //stream和queue结构使用的参数,用于设置每次拉取的阻塞时长
	RecvBatchSize     int64         //stream消费者专用,用于设定一次获取的消息批长度
	Group             string        //stream消费者专用,用于设定客户端组
	AckMode           AckModeType   //stream消费者专用,用于设定同步校验规则
	Start             string        //stream消费者专用,用于设定监听的起始位置,"则从最近的开始监听"
}

Options broker的配置

Directories

Path Synopsis
Package 发布订阅器对象 Package pubsub 发布订阅器对象 非常适合作为简单的广播模式的中间件
Package 发布订阅器对象 Package pubsub 发布订阅器对象 非常适合作为简单的广播模式的中间件
Package queue 队列对象 非常适合作为简单的生产者消费者模式的中间件 Package queue 队列对象 非常适合作为简单的生产者消费者模式的中间件 Package queue 队列对象 非常适合作为简单的生产者消费者模式的中间件
Package queue 队列对象 非常适合作为简单的生产者消费者模式的中间件 Package queue 队列对象 非常适合作为简单的生产者消费者模式的中间件 Package queue 队列对象 非常适合作为简单的生产者消费者模式的中间件
Package stream 流及相关对象的包 Package stream 流及相关对象的包
Package stream 流及相关对象的包 Package stream 流及相关对象的包

Jump to

Keyboard shortcuts

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