Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cnf ¶
type Cnf struct {
//mysql dsn config
MySQLDsn *gormx.Dsn `json:"mysql"`
//LogGorm -- log gorm or not
LogGorm bool `json:"logGorm"`
//topic tbl string
TopicTbl string `json:"topicTbl"`
//cursor tbl string
CursorTbl string `json:"cursorTbl"`
//client id
ID string `json:"id"`
//n -- read n in each fetch
N int `json:"n"`
//tick -- time duration
Tick tex.JsDuration `json:"tick"`
// -- after msg consumed count to submit cursor
CatchN int64 `json:"catchN"`
// -- after msg consumed time to submit cursor
CatchT tex.JsDuration `json:"catchT"`
// -- submit retry
SubmitRetryNum int `json:"submitRetryNum"`
}
Cnf : consumer config
type Consumer ¶
type Consumer struct {
// contains filtered or unexported fields
}
Consumer : consumer
func NewConsumer ¶
func NewConsumer(cnf *Cnf, mh MsgHandler, eh *ErrHandler) (*Consumer, error)
NewConsumer new consumer
func (*Consumer) ExitSignal ¶
func (c *Consumer) ExitSignal() <-chan struct{}
ExitSignal : exit consumer signal
type Cursor ¶
type Cursor struct {
//ClientID client id
ClientID string `gorm:"column:cid"`
//ConsumedID client consumed id
ConsumedID int64 `gorm:"column:sid"`
//UpdatedAt updated time
UpdatedAt time.Time `gorm:"column:updated_at"`
}
Cursor message consumer cursor
type ErrHandler ¶
ErrHandler : error handler
type Hooker ¶
type Hooker interface {
//Save : save function
Save() func(*gorm.DB) error
//Msg : generate msg
Msg() interface{}
}
Hooker -- write data with message hook
type Msg ¶
type Msg struct {
//ID message id
ID int64 `gorm:"column:id"`
//P message protocol
P Protocol `gorm:"column:p"`
//Data -- max size 16M
Data []byte `gorm:"column:data"`
//CreatedAt -- created time
CreatedAt time.Time `gorm:"column:created_at"`
}
Msg message define
Click to show internal directories.
Click to hide internal directories.