Documentation ¶
Index ¶
- Constants
- Variables
- type INodePool
- type IRecentJobPacker
- type Job
- type JobWarpper
- type JobWithTime
- type JobWithTimeHeap
- func (jobHeap *JobWithTimeHeap) Index(i int) interface{}
- func (jobHeap *JobWithTimeHeap) Len() int
- func (jobHeap *JobWithTimeHeap) Less(i, j int) bool
- func (jobHeap *JobWithTimeHeap) Pop() (ret interface{})
- func (jobHeap *JobWithTimeHeap) Push(x interface{})
- func (jobHeap *JobWithTimeHeap) Swap(i, j int)
- 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 RunningLocally() Option
- func WithClusterStable(timeWindow time.Duration) Option
- func WithHashReplicas(d int) Option
- func WithNodeUpdateDuration(d time.Duration) Option
- func WithRecoverFunc(recoverFunc RecoverFuncType) Option
- type RecentJobPacker
- 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) GetJob(jobName string, thisNodeOnly bool) (*JobWarpper, error)
- func (d *Task) GetJobs(thisNodeOnly bool) []*JobWarpper
- func (d *Task) NodeID() string
- func (d *Task) Remove(jobName string)
- func (d *Task) Run()
- func (d *Task) Start()
- func (d *Task) Stop()
Constants ¶
const ( NodePoolStateSteady = "NodePoolStateSteady" NodePoolStateUpgrade = "NodePoolStateUpgrade" )
Variables ¶
var ( ErrNodePoolIsUpgrading = errors.New("nodePool is upgrading") ErrNodePoolIsNil = errors.New("nodePool is nil") )
Functions ¶
This section is empty.
Types ¶
type INodePool ¶ added in v3.8.0
type IRecentJobPacker ¶ added in v3.8.0
type IRecentJobPacker interface { // goroutine safety. // Add a job to packer // will save recent jobs (like 2 * heartbeat duration) AddJob(jobName string, t time.Time) error // goroutine safety. // Pop out all jobs in packer PopAllJobs() (jobNames []string) }
IRecentJobPacker this is an interface which be used to pack the jobs running in the cluster state is `unstable`. like some nodes broken or new nodes were add.
func NewRecentJobPacker ¶ added in v3.8.0
func NewRecentJobPacker(timeWindow time.Duration) IRecentJobPacker
type JobWarpper ¶
JobWarpper is a job warpper
func (JobWarpper) Execute ¶ added in v3.8.0
func (job JobWarpper) Execute()
type JobWithTime ¶ added in v3.8.0
type JobWithTimeHeap ¶ added in v3.8.0
type JobWithTimeHeap []JobWithTime
func (*JobWithTimeHeap) Index ¶ added in v3.8.0
func (jobHeap *JobWithTimeHeap) Index(i int) interface{}
func (*JobWithTimeHeap) Len ¶ added in v3.8.0
func (jobHeap *JobWithTimeHeap) Len() int
func (*JobWithTimeHeap) Less ¶ added in v3.8.0
func (jobHeap *JobWithTimeHeap) Less(i, j int) bool
func (*JobWithTimeHeap) Pop ¶ added in v3.8.0
func (jobHeap *JobWithTimeHeap) Pop() (ret interface{})
func (*JobWithTimeHeap) Push ¶ added in v3.8.0
func (jobHeap *JobWithTimeHeap) Push(x interface{})
func (*JobWithTimeHeap) Swap ¶ added in v3.8.0
func (jobHeap *JobWithTimeHeap) Swap(i, j int)
type NodePool ¶
type NodePool struct {
// contains filtered or unexported fields
}
NodePool For cluster steable. NodePool has 2 states:
- Steady If this nodePoolLists is the same as the last update, we will mark this node's state to Steady. In this state, this node can run jobs.
- Upgrade If this nodePoolLists is different to the last update, we will mark this node's state to Upgrade. In this state, this node can not run jobs.
func (*NodePool) CheckJobAvailable ¶ added in v3.8.0
Check if this job can be run in this node.
func (*NodePool) GetLastNodesUpdateTime ¶ added in v3.8.0
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 RunningLocally ¶ added in v3.8.0
func RunningLocally() Option
func WithClusterStable ¶ added in v3.8.0
You can use this option to start the recent jobs rerun after the cluster upgrading.
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 RecentJobPacker ¶ added in v3.8.0
func (*RecentJobPacker) AddJob ¶ added in v3.8.0
func (rjp *RecentJobPacker) AddJob(jobName string, t time.Time) (err error)
func (*RecentJobPacker) PopAllJobs ¶ added in v3.8.0
func (rjp *RecentJobPacker) PopAllJobs() (jobNames []string)
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
func (*Task) GetJob ¶ added in v3.8.0
func (d *Task) GetJob(jobName string, thisNodeOnly bool) (*JobWarpper, error)
Get job by jobName if this jobName not exist, will return error.
if `thisNodeOnly` is true if this job is not available in this node, will return error. otherwise return the struct of JobWarpper whose name is jobName.
func (*Task) GetJobs ¶ added in v3.8.0
func (d *Task) GetJobs(thisNodeOnly bool) []*JobWarpper
Get job list.
if `thisNodeOnly` is true return all jobs available in this node. otherwise return all jobs added to task.
we never return nil. If there is no job. this func will return an empty slice.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package cron implements a cron spec parser and job runner.
|
Package cron implements a cron spec parser and job runner. |