cron

package
v0.0.0-...-d843dc6 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const RunAlways = -1

Variables

This section is empty.

Functions

This section is empty.

Types

type Cron

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

func (*Cron) Add

func (c *Cron) Add(task *Task)

func (*Cron) Len

func (c *Cron) Len() int

func (*Cron) Remove

func (c *Cron) Remove(name string)

func (*Cron) Run

func (c *Cron) Run() error

func (*Cron) Stop

func (c *Cron) Stop()

type Interface

type Interface interface {
	Run() error
	Stop()
	Add(*Task)
	Remove(string)
	Len() int
}

func NewCron

func NewCron(logger logr.Logger) Interface

func NewTimeWheel

func NewTimeWheel(interval time.Duration, slots int, logger logr.Logger) Interface

type Job

type Job interface {
	Name() string
	Exec() error
}

func SimpleJob

func SimpleJob(name string, exec func() error) Job

type Schedule

type Schedule interface {
	Next(time.Time) time.Time
}

func At

func At(from time.Time, duration time.Duration, times int) Schedule

func Every

func Every(duration time.Duration) Schedule

func EveryAt

func EveryAt(from time.Time, duration time.Duration) Schedule

func Once

func Once(at time.Time) Schedule

type Task

type Task struct {
	Job
	Schedule
	// contains filtered or unexported fields
}

type TimeWheel

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

func (*TimeWheel) Add

func (tw *TimeWheel) Add(task *Task)

func (*TimeWheel) Len

func (tw *TimeWheel) Len() int

func (*TimeWheel) Remove

func (tw *TimeWheel) Remove(name string)

func (*TimeWheel) Run

func (tw *TimeWheel) Run() error

func (*TimeWheel) RunTask

func (tw *TimeWheel) RunTask(now time.Time, slot int)

func (*TimeWheel) Stop

func (tw *TimeWheel) Stop()

type TimeWheelTask

type TimeWheelTask struct {
	Task
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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