ActivityFetcher/jobs/registry.go
2025-10-14 10:45:43 +02:00

27 lines
522 B
Go

package jobs
import (
"context"
"time"
)
// Job describes an executable unit that provides its own run cadence.
type Job interface {
Name() string
Interval() time.Duration
Run(context.Context) error
}
var registry []Job
// Register makes a job discoverable by the scheduler. Typically invoked in init.
func Register(job Job) {
registry = append(registry, job)
}
// All returns a snapshot of the currently registered jobs.
func All() []Job {
out := make([]Job, len(registry))
copy(out, registry)
return out
}