1package jobs23import (4 "context"5 "sync"6)78// Job is a job that can be registered with the scheduler.9type Job struct {10 ID int11 Runner Runner12}1314// Runner is a job runner.15type Runner interface {16 Spec(context.Context) string17 Func(context.Context) func()18}1920var (21 mtx sync.Mutex22 jobs = make(map[string]*Job, 0)23)2425// Register registers a job.26func Register(name string, runner Runner) {27 mtx.Lock()28 defer mtx.Unlock()29 jobs[name] = &Job{Runner: runner}30}3132// List returns a map of registered jobs.33func List() map[string]*Job {34 mtx.Lock()35 defer mtx.Unlock()36 return jobs37}