Documentation
¶
Index ¶
- func RegisterCron(cronName string, cron Interface)
- func Run(ctx context.Context, configPath string)
- type Base
- func (b *Base) AddBaseTaskList(task func(context.Context))
- func (b *Base) AddProcessAddTaskList(task func(context.Context))
- func (b *Base) Before(name, lockName string, deadLockExpireTime time.Duration, maxConcurrencyCnt int)
- func (b *Base) Defer(ctx context.Context)
- func (b *Base) GetIsRun(ctx context.Context) bool
- func (b *Base) Init(_ Interface)
- func (b *Base) Process(context.Context)
- func (b *Base) Run(ctx context.Context)
- type Config
- type ConfigItem
- type CronJobParams
- type DurationJobParams
- type DurationRandomJobParams
- type Interface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterCron ¶
Types ¶
type Base ¶
type Base struct {
RedisClient *redis.Client
LockName string
IsRun bool
// contains filtered or unexported fields
}
func (*Base) AddBaseTaskList ¶
func (*Base) AddProcessAddTaskList ¶
type Config ¶
type Config struct {
LockPreName string `json:"lockPreName"`
IsRunCron bool `json:"isRunCron"`
CronList []ConfigItem `json:"cronList"`
}
type ConfigItem ¶
type ConfigItem struct {
Name string `json:"name"`
DeadLockExpireMillisecond int64 `json:"deadLockExpireMillisecond"`
MaxConcurrencyCnt int `json:"maxConcurrencyCnt"`
JobType string `json:"jobType"`
CronJobParams CronJobParams `json:"cronJobParams"`
DurationJobParams DurationJobParams `json:"durationJobParams"`
DurationRandomJobParams DurationRandomJobParams `json:"durationRandomJobParams"`
}
type CronJobParams ¶
type DurationJobParams ¶
type DurationJobParams struct {
EveryMillisecond int64 `json:"everyMillisecond"`
}
type DurationRandomJobParams ¶
type Interface ¶
type Interface interface {
GetIsRun(context.Context) bool
AddBaseTaskList(task func(context.Context))
AddProcessAddTaskList(task func(context.Context))
// Init 初始化只会执行一次
Init(base Interface)
Process(context.Context)
Before(name, lockName string, deadLockExpireTime time.Duration, maxConcurrencyCnt int)
Run(context.Context)
Defer(context.Context)
}
Interface 执行顺序 Before->Process->Run->Defer 只建议重写 Init 和 Process Init 添加固定执行的脚本,使用 AddBaseTaskList 添加,尽量通过该方法添加 Process 添加运行中才能确定执行的脚本,使用 AddProcessAddTaskList 添加
Click to show internal directories.
Click to hide internal directories.