cron

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(ctx context.Context, mc *model.Client, cs JobCreators) (err error)

Register executes all job creators and schedules the returning task with the returning expression.

func StartCorrecter added in v0.3.1

func StartCorrecter(ctx context.Context, opts StartCorrecterOptions) error

StartCorrecter starts a corrector to calibrate the jobs.

func Sync

Sync observes the cron expr setting changes, and replaces the jobs that have changed expression.

Types

type Expr

type Expr = cron.Expr

Expr holds the definition of cron expression.

func AwaitedExpr

func AwaitedExpr(raw string) Expr

AwaitedExpr returns an Expr and runs in the next round.

func ImmediateExpr

func ImmediateExpr(raw string) Expr

ImmediateExpr returns an Expr and runs in the next round.

type JobCreator

type JobCreator func(logger log.Logger, expr string) (Expr, Task, error)

JobCreator is the creator for creating {cron.Expr, cron.Task} tuple.

type JobCreators

type JobCreators map[JobExpressionName]JobCreator

JobCreators holds JobCreator with its expression name.

type JobExpressionName added in v0.3.1

type JobExpressionName = string

JobExpressionName holds the name of the cron.Expr.

type Lock

type Lock struct {
	// contains filtered or unexported fields
}

Lock implement the cronjob go-co-op/gocron Lock interface.

func (*Lock) Unlock

func (lk *Lock) Unlock(ctx context.Context) error

Unlock release the lock.

type Locker

type Locker struct {
	// contains filtered or unexported fields
}

Locker implement the cronjob go-co-op/gocron Locker interface.

func NewLocker

func NewLocker(logger log.Logger, client *model.Client, options ...Option) *Locker

NewLocker create locker with model client and options.

func (*Locker) Lock

func (l *Locker) Lock(ctx context.Context, key string) (cron.Lock, error)

Lock try to lock the key provided, return error while failed to lock key.

type Option

type Option func(*Locker)

Option is a function that configures a locker.

func WithExpiryInterval

func WithExpiryInterval(expiry time.Duration) Option

WithExpiryInterval can be used to set the expiry of a locker to set to every key.

func WithRenewConfig

func WithRenewConfig(renewInterval, maxExecuteDuration time.Duration) Option

WithRenewConfig can be used to set renew interval and max execute duration of a locker.

type StartCorrecterOptions added in v0.3.1

type StartCorrecterOptions struct {
	ModelClient model.ClientSet
	Interval    time.Duration
}

type Task

type Task = cron.Task

Task defines the interface to hold the job executing main logic.

Jump to

Keyboard shortcuts

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