scheduler

package
v1.16.4 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: GPL-2.0, GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrJobRunning      = errors.New("job already running")
	ErrJobIsNotRunning = errors.New("job is not running")
	ErrJobFinished     = errors.New("job already finished")
	ErrJobSkipped      = errors.New("job skipped")
	ErrJobSuccess      = errors.New("job already successful")
)

Error variables for job states.

Functions

This section is empty.

Types

type Job added in v1.16.1

type Job interface {
	// Start starts the DAG.
	Start(ctx context.Context) error
	// Stop stops the DAG.
	Stop(ctx context.Context) error
	// Restart restarts the DAG.
	Restart(ctx context.Context) error
}

Job is the interface for the actual DAG.

type JobManager added in v1.16.1

type JobManager interface {
	// Start initializes and starts the process of managing scheduled Jobs.
	Start(ctx context.Context, done chan any) error
	// Next returns the next scheduled jobs.
	Next(ctx context.Context, now time.Time) ([]*ScheduledJob, error)
}

JobManager is responsible for managing scheduled Jobs.

func NewDAGJobManager added in v1.16.1

func NewDAGJobManager(dir string, client client.Client, executable, workDir string) JobManager

NewDAGJobManager creates a new DAG manager with the given configuration.

type ScheduleType added in v1.16.1

type ScheduleType int

ScheduleType is the type of schedule (start, stop, restart).

const (
	ScheduleTypeStart ScheduleType = iota
	ScheduleTypeStop
	ScheduleTypeRestart
)

func (ScheduleType) String added in v1.16.1

func (s ScheduleType) String() string

type ScheduledJob added in v1.16.1

type ScheduledJob struct {
	Next time.Time // Next is the time when the job should be run.
	Job  Job
	Type ScheduleType // start, stop, restart
}

ScheduledJob stores the next time a job should be run and the job itself.

func NewScheduledJob added in v1.16.1

func NewScheduledJob(next time.Time, job Job, typ ScheduleType) *ScheduledJob

NewScheduledJob creates a new ScheduledJob.

type Scheduler

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

func New

func New(cfg *config.Config, manager JobManager) *Scheduler

func (*Scheduler) Start

func (s *Scheduler) Start(ctx context.Context) error

func (*Scheduler) Stop

func (s *Scheduler) Stop(ctx context.Context)

Directories

Path Synopsis
Package filenotify provides a mechanism for watching file(s) for changes.
Package filenotify provides a mechanism for watching file(s) for changes.

Jump to

Keyboard shortcuts

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