scheduler

package
v0.0.0-...-ea0be71 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateSpec

func ValidateSpec(spec JobSpec) (cron.Schedule, error)

Types

type Controller

type Controller struct {
	SnapshotReady chan []JobSpec
	// contains filtered or unexported fields
}

func New

func New(
	jobs []*Job,
	jobLogger *log.Logger,
	start func(func(context.Context) error),
) *Controller

func (*Controller) Snapshot

func (s *Controller) Snapshot() []JobSpec

gets an atomic snapshot of scheduler's internal state

func (*Controller) Trigger

func (s *Controller) Trigger(jobId string)

type Job

type Job struct {
	Spec     JobSpec
	Run      JobFn
	Schedule cron.Schedule
}

func NewJob

func NewJob(spec JobSpec, run JobFn, now time.Time) (*Job, error)

type JobFn

type JobFn func(ctx context.Context, logger *log.Logger) error

type JobLastRun

type JobLastRun struct {
	Started  time.Time
	Finished time.Time
	Error    string
}

type JobSpec

type JobSpec struct {
	Id          string
	Description string
	NextRun     time.Time
	Running     bool
	Schedule    string
	LastRun     *JobLastRun
}

Jump to

Keyboard shortcuts

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