hasaki_ticker_task

package
v0.0.0-...-89dd690 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2021 License: BSD-2-Clause Imports: 8 Imported by: 1

Documentation

Index

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 AddPollingItem(taskType string, data map[string]interface{}) error

func AddTicker

func AddTicker(taskType string, f func(item *TickerTaskItem) error)

func AddTickerItem

func AddTickerItem(taskType string, data map[string]interface{}, expiredAt time.Time) error

增加任务

func InitDb

func InitDb(config interface{}) (err error)

func InitDbByConfig

func InitDbByConfig(config interface{}) (err error)

func LaunchPolling

func LaunchPolling(number int)

每次取出多少条

func LaunchTicker

func LaunchTicker()

func RecoveryTickerItem

func RecoveryTickerItem(uniqueId string, expiredAts ...time.Time) error

func RemoveTicker

func RemoveTicker(taskType string)

func RemoveTickerItem

func RemoveTickerItem(uniqueId string) error

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)

Jump to

Keyboard shortcuts

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