Help us shape the future of Go! Take the 2026 Go Developer Survey

scheduler

package
v1.0.7 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job struct {
	Name     string
	Interval time.Duration
	Run      func(ctx context.Context) error
}

Job represents a periodic task.

type LastRunProvider

type LastRunProvider interface {
	LastFinished(ctx context.Context, jobName string) (time.Time, bool, error)
}

LastRunProvider exposes last finished run for a job.

type Logger

type Logger interface {
	Info(msg string, args ...any)
	Error(msg string, args ...any)
}

Logger is a minimal interface for logging.

type Recorder

type Recorder interface {
	Record(ctx context.Context, jobName string, startedAt, finishedAt time.Time, success bool, errMsg string) error
}

Recorder persists job runs.

type RecorderFunc

type RecorderFunc func(ctx context.Context, jobName string, startedAt, finishedAt time.Time, success bool, errMsg string) error

RecorderFunc turns a function into a Recorder.

func (RecorderFunc) Record

func (f RecorderFunc) Record(ctx context.Context, jobName string, startedAt, finishedAt time.Time, success bool, errMsg string) error

type Runner

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

Runner executes jobs on a ticker until ctx is cancelled.

func New

func New(log Logger, rec Recorder, last LastRunProvider, jobs ...Job) *Runner

New creates a Runner.

func (*Runner) Start

func (r *Runner) Start(ctx context.Context)

Start launches all jobs in separate goroutines.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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