Documentation
¶
Index ¶
- type Hash
- type Job
- type JobWarpper
- type Map
- type NodePool
- type Option
- func CronOptionChain(wrappers ...cron.JobWrapper) Option
- func CronOptionLocation(loc *time.Location) Option
- func CronOptionParser(p cron.ScheduleParser) Option
- func CronOptionSeconds() Option
- func WithHashReplicas(d int) Option
- func WithNodeUpdateDuration(d time.Duration) Option
- func WithRecoverFunc(recoverFunc RecoverFuncType) Option
- type RecoverFuncType
- type StableJob
- type Task
- func (d *Task) AddFunc(jobName, cronStr string, cmd func()) (err error)
- func (d *Task) AddJob(jobName, cronStr string, job Job) (err error)
- func (d *Task) Remove(jobName string)
- func (d *Task) Run()
- func (d *Task) Start()
- func (d *Task) Stop()
- func (d *Task) Total() int64
- func (t *Task) WorkerStart() error
- func (t *Task) WorkerStop() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JobWarpper ¶
type JobWarpper struct {
ID cron.EntryID
Task *Task
Name string
CronStr string
Func func()
Job Job
}
JobWarpper is a job warpper
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
type NodePool ¶
type NodePool struct {
NodeID string
Driver driver.Driver
// contains filtered or unexported fields
}
NodePool is a node pool
func (*NodePool) PickNodeByJobName ¶
PickNodeByJobName : 使用一致性hash算法根据任务名获取一个执行节点
type Option ¶
type Option func(*Task)
Option is Task Option
func CronOptionChain ¶
func CronOptionChain(wrappers ...cron.JobWrapper) Option
CronOptionChain is Warp cron with chain
func CronOptionLocation ¶
CronOptionLocation is warp cron with location
func CronOptionParser ¶
func CronOptionParser(p cron.ScheduleParser) Option
CronOptionParser is warp cron with schedules.
func CronOptionSeconds ¶
func CronOptionSeconds() Option
CronOptionSeconds is warp cron with seconds
func WithNodeUpdateDuration ¶
WithNodeUpdateDuration set node update duration
func WithRecoverFunc ¶
func WithRecoverFunc(recoverFunc RecoverFuncType) Option
You can defined yourself recover function to make the job will be added to your task when the process restart
type RecoverFuncType ¶
type RecoverFuncType func(d *Task)
type StableJob ¶
type StableJob interface {
Job
GetCron() string
Serialize() ([]byte, error)
UnSerialize([]byte) error
}
This type of Job will be recovered in a node of service restarting.
type Task ¶
type Task struct {
ServerName string
RecoverFunc RecoverFuncType
// contains filtered or unexported fields
}
Task is main struct
func NewTaskWithOption ¶
NewTaskWithOption create a Task with Task Option
Click to show internal directories.
Click to hide internal directories.