cronroutine

package module
v0.0.0-...-070ac4e Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

README

Cronroutine

Cronroutine is a library for managing cron-like routines in Go.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StopScheduler

func StopScheduler(s *Scheduler) error

Types

type Cron

type Cron struct {
	Minute     []int
	Hour       []int
	DayOfMonth []int
	Month      []int
	DayOfWeek  []int
}

func NewCron

func NewCron(minute, hour, dayOfMonth, month, dayOfWeek string) (*Cron, error)

func ParseCron

func ParseCron(cronConfig string) (*Cron, error)

func (*Cron) Next

func (c *Cron) Next() time.Time

func (*Cron) NextFor

func (c *Cron) NextFor(t time.Duration) []time.Time

type ErrJobRunning

type ErrJobRunning struct{}

func (ErrJobRunning) Error

func (e ErrJobRunning) Error() string

type ErrJobTimeout

type ErrJobTimeout struct{}

func (ErrJobTimeout) Error

func (e ErrJobTimeout) Error() string

type ErrPastStartingDeadline

type ErrPastStartingDeadline struct{}

func (ErrPastStartingDeadline) Error

func (e ErrPastStartingDeadline) Error() string

type History

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

func (*History) Error

func (h *History) Error() error

func (*History) JobID

func (h *History) JobID() string

func (*History) RanAt

func (h *History) RanAt() time.Time

type Job

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

func (*Job) AllowConccurentRuns

func (j *Job) AllowConccurentRuns() bool

func (*Job) History

func (j *Job) History() []*History

func (*Job) ID

func (j *Job) ID() string

func (*Job) NextFor

func (j *Job) NextFor(t time.Duration) []time.Time

func (*Job) NextRun

func (j *Job) NextRun() time.Time

func (*Job) Schedule

func (j *Job) Schedule() string

func (*Job) StartingDeadline

func (j *Job) StartingDeadline() time.Duration

func (*Job) Timeout

func (j *Job) Timeout() time.Duration

type JobConfig

type JobConfig struct {
	// ID is the unique identifier of the job.
	ID string

	// Schedule is the cron schedule that determines when the job will run.
	Schedule string

	// Timeout is the amount of time each instance of the job is allowed to
	// run before it is killed.
	Timeout time.Duration

	// StartingDeadline is the maximum time the job can be delayed. If the
	// job is delayed more than this, it will be skipped.
	StartingDeadline time.Duration

	// AllowConccurentRuns determines whether the next job will start
	// if it is currently running.
	AllowConccurentRuns bool

	// This function will be run when the job is executed.
	Func func(context.Context) error
}

type Scheduler

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

func StartNewScheduler

func StartNewScheduler(cfg *SchedulerConfig) *Scheduler

func (*Scheduler) AddJob

func (s *Scheduler) AddJob(job JobConfig) error

func (*Scheduler) GetJob

func (s *Scheduler) GetJob(jobID string) (*Job, error)

func (*Scheduler) ListJobs

func (s *Scheduler) ListJobs() []*Job

func (*Scheduler) RemoveJob

func (s *Scheduler) RemoveJob(jobID string) error

type SchedulerConfig

type SchedulerConfig struct {
	Logger       logr.Logger
	HistoryLimit int
	WorkerCount  int
}

func DefaultSchedulerConfig

func DefaultSchedulerConfig() *SchedulerConfig

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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