1package jobs
 2
 3import (
 4	"context"
 5	"sync"
 6)
 7
 8// Job is a job that can be registered with the scheduler.
 9type Job struct {
10	ID   int
11	Spec string
12	Func func(context.Context) func()
13}
14
15var (
16	mtx  sync.Mutex
17	jobs = make(map[string]*Job, 0)
18)
19
20// Register registers a job.
21func Register(name, spec string, fn func(context.Context) func()) {
22	mtx.Lock()
23	defer mtx.Unlock()
24	jobs[name] = &Job{Spec: spec, Func: fn}
25}
26
27// List returns a map of registered jobs.
28func List() map[string]*Job {
29	mtx.Lock()
30	defer mtx.Unlock()
31	return jobs
32}