crontask

package
v0.0.0-...-65f3376 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrJobNotFound   = errors.New("job cannot be found")
	ErrRegDuplicated = errors.New("duplicated Job key are not allowed")

	ErrRegValidateFailed = errors.New("register validate failed")
)

Functions

func NewExecutor

func NewExecutor(parser cron.Parser, entry *logrus.Entry) *executor

Types

type Crontab

type Crontab string

type CtxMaker

type CtxMaker func(ctx context.Context) context.Context

type Job

type Job struct {
	ID int64

	JobMeta
	// contains filtered or unexported fields
}

func (*Job) MakeCtx

func (j *Job) MakeCtx(ctx context.Context) context.Context

func (*Job) Run

func (j *Job) Run()

func (*Job) RunWithCtx

func (j *Job) RunWithCtx(ctx context.Context) error

type JobMeta

type JobMeta struct {
	Key     string
	Crontab string

	// Punch is the real method to be executed
	Punch Punch

	// RegValid is used to validate the service instance it is on
	// during the registration process. If the service instance does
	// not meet certain conditions, the Job will not be registered to
	// this instance.
	RegValid RegValidator

	// CtxMaker creates the context for the timed execution of the
	// Job, if set to nil, then context.Background() is used by default
	CtxMaker CtxMaker

	JobStrategy
}

type JobStrategy

type JobStrategy struct {
	ExecuteGroup string // 在哪个 Group 里执行, 这个字段存在时, 只在对应 Group 的 Participant Instance 里才会执行
}

type Punch

type Punch func(ctx context.Context) error

type RegValidator

type RegValidator func(ctx context.Context) error

Jump to

Keyboard shortcuts

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