Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CronJob ¶
type CronJob struct {
ID uuid.UUID
Name string
Type string
Payload []byte
Schedule string
MaxRetries int
LastFiredAt *time.Time
}
CronJob is the in-memory representation of a cron_jobs row.
type PGCronStore ¶
type PGCronStore struct {
// contains filtered or unexported fields
}
PGCronStore implements cron.Store against PostgreSQL.
func NewPGCronStore ¶
func NewPGCronStore(pool *pgxpool.Pool) *PGCronStore
func (*PGCronStore) ListEnabledCronJobs ¶
func (s *PGCronStore) ListEnabledCronJobs(ctx context.Context) ([]*CronJob, error)
func (*PGCronStore) UpdateLastFired ¶
func (*PGCronStore) UpsertCronJob ¶
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner manages cron job definitions and spawns one-off job entries into the jobs table when a cron expression fires.
Design: cron entries create rows in the jobs table; the existing scheduler claims and executes them. This gives cron jobs retry semantics for free and makes them visible in ListJobs without any special-casing.
func (*Runner) LoadAndStart ¶
LoadAndStart reads all enabled cron definitions from the DB, registers them with robfig/cron, then starts the internal ticker goroutine. Must be called once after migrations complete.
The provided ctx is used for all jobs spawned by this runner. When ctx is cancelled (e.g. on leadership loss), new job insertions are aborted rather than using context.Background(), which would keep writing to a DB that may no longer be owned by this node.
type Store ¶
type Store interface {
ListEnabledCronJobs(ctx context.Context) ([]*CronJob, error)
UpdateLastFired(ctx context.Context, id uuid.UUID, firedAt time.Time) error
UpsertCronJob(ctx context.Context, cj *CronJob) (*CronJob, error)
}
Store is the persistence interface for cron job definitions.