Documentation ¶
Index ¶
- Variables
- func AddPolling(taskType string, f func(*PollingTaskItem) error)
- func AddPollingItem(taskType string, data map[string]interface{}) error
- func AddTicker(taskType string, f func(item *TickerTaskItem) error)
- func AddTickerItem(taskType string, data map[string]interface{}, expiredAt time.Time) error
- func InitDb(config interface{}) (err error)
- func InitDbByConfig(config interface{}) (err error)
- func LaunchPolling(number int)
- func LaunchTicker()
- func RecoveryTickerItem(uniqueId string, expiredAts ...time.Time) error
- func RemoveTicker(taskType string)
- func RemoveTickerItem(uniqueId string) error
- func RunPollingItem(item *PollingTaskItem) error
- func RunTickerItem(item *TickerTaskItem) error
- type PollingTaskItem
- type TickerTaskItem
Constants ¶
This section is empty.
Variables ¶
View Source
var PollingHandleMap = new(sync.Map)
View Source
var TickerHandleMap = new(sync.Map)
Functions ¶
func AddPolling ¶
func AddPolling(taskType string, f func(*PollingTaskItem) error)
func AddPollingItem ¶
func AddTicker ¶
func AddTicker(taskType string, f func(item *TickerTaskItem) error)
func AddTickerItem ¶
增加任务
func InitDbByConfig ¶
func InitDbByConfig(config interface{}) (err error)
func LaunchTicker ¶
func LaunchTicker()
func RemoveTicker ¶
func RemoveTicker(taskType string)
func RemoveTickerItem ¶
func RunPollingItem ¶
func RunPollingItem(item *PollingTaskItem) error
func RunTickerItem ¶
func RunTickerItem(item *TickerTaskItem) error
Types ¶
type PollingTaskItem ¶
type PollingTaskItem struct { hskmodel.SoftDeleteModel `xorm:"extends"` UniqueId string `json:"unique_id" xorm:"not null default '' comment('唯一标识') VARCHAR(255)"` // 唯一iD Flag int `json:"flag" xorm:"not null default 0 comment('处理状态[0/1/2/3/4:未处理/处理中/已处理/出现错误/移除]')"` // 处理状态 TaskType string `json:"task_type" xorm:"not null default '' comment('任务类型') VARCHAR(255)"` ErrLog string `json:"err_log" xorm:"TEXT comment('错误信息')"` Data map[string]interface{} `json:"data" xorm:"json comment('处理信息')"` }
轮询任务 思路: 某些分库数据添加进去,
func ListPollingItem ¶
func ListPollingItem(number int) (items []*PollingTaskItem, err error)
type TickerTaskItem ¶
type TickerTaskItem struct { hskmodel.SoftDeleteModel `xorm:"extends"` UniqueId string `json:"unique_id" xorm:"not null default '' comment('唯一标识') VARCHAR(255)"` // 唯一iD Flag int `json:"flag" xorm:"not null default 0 comment('处理状态[0/1/2/3/4:未处理/处理中/已处理/出现错误/移除]')"` // 处理状态 TaskType string `json:"task_type" xorm:"not null default '' comment('任务类型') VARCHAR(255)"` ErrLog string `json:"err_log" xorm:"TEXT comment('错误信息')"` ExpiredAt time.Time `json:"expired_at" xorm:"DATETIME comment('过期时间')"` // 过期时间 Data map[string]interface{} `json:"data" xorm:"json comment('处理信息')"` }
func RandomTickerItem ¶
func RandomTickerItem() (*TickerTaskItem, error)
Click to show internal directories.
Click to hide internal directories.