Documentation
¶
Index ¶
- func GetCatchUpTimes(t *models.Trigger, to time.Time) ([]time.Time, error)
- func ListActiveScheduleTriggers(ctx context.Context, repo interfaces.TriggerRepo) ([]*models.Trigger, error)
- func ParseSchedule(t *models.Trigger) (cron.Schedule, error)
- func StartTime(t *models.Trigger) (time.Time, error)
- func TriggerKey(t *models.Trigger) string
- type Executor
- type GoCronJob
- type GoCronScheduler
- type ScheduleSyncer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCatchUpTimes ¶
GetCatchUpTimes returns all scheduled times in (lastExecTime, to] for a trigger.
func ListActiveScheduleTriggers ¶
func ListActiveScheduleTriggers(ctx context.Context, repo interfaces.TriggerRepo) ([]*models.Trigger, error)
ListActiveScheduleTriggers returns all non-deleted, active triggers with automation_type = TYPE_SCHEDULE.
func ParseSchedule ¶
ParseSchedule returns a cron.Schedule for the trigger's automation spec. Supports both cron expressions and fixed-rate schedules. Returns (nil, nil) if the trigger has no schedule automation.
func StartTime ¶
StartTime returns the earliest point from which to start scheduling. For fixed-rate schedules with a start_time, returns that start_time advanced past the last execution time. Otherwise falls back to TriggeredAt or DeployedAt.
func TriggerKey ¶
TriggerKey returns a stable string key for this job (used as the cron job name).
Types ¶
type Executor ¶
type Executor interface {
Execute(ctx context.Context, t *models.Trigger, scheduledAt time.Time) error
}
Executor fires a single scheduled run.
type GoCronJob ¶
type GoCronJob struct {
// contains filtered or unexported fields
}
GoCronJob wraps a *models.Trigger and fires the executor at each scheduled time. It implements cron.TimedJob so the scheduler passes the exact scheduled time to Run.
func NewGoCronJob ¶
NewGoCronJob constructs a GoCronJob.
type GoCronScheduler ¶
type GoCronScheduler struct {
// contains filtered or unexported fields
}
GoCronScheduler manages a set of cron jobs, one per active trigger. It is safe for concurrent use.
func NewGoCronScheduler ¶
func NewGoCronScheduler(executor Executor) *GoCronScheduler
NewGoCronScheduler constructs a GoCronScheduler.
func (*GoCronScheduler) CatchupAll ¶
func (s *GoCronScheduler) CatchupAll( ctx context.Context, triggers []*models.Trigger, now time.Time, maxRunsPerLoop int, )
CatchupAll fires catchup runs for all triggers that have missed scheduled times. It processes at most maxRunsPerLoop total runs across all triggers.
func (*GoCronScheduler) Start ¶
func (s *GoCronScheduler) Start()
Start starts the underlying cron scheduler. It is non-blocking.
func (*GoCronScheduler) Stop ¶
func (s *GoCronScheduler) Stop() context.Context
Stop gracefully stops the cron scheduler, waiting for running jobs to finish.
func (*GoCronScheduler) UpdateSchedules ¶
func (s *GoCronScheduler) UpdateSchedules(ctx context.Context, triggers []*models.Trigger)
UpdateSchedules reconciles the set of running cron jobs with the supplied active triggers. New triggers are added; triggers no longer present are removed; triggers whose spec changed are replaced.
type ScheduleSyncer ¶
type ScheduleSyncer struct {
// contains filtered or unexported fields
}
ScheduleSyncer periodically reloads active schedule triggers from the database and reconciles the running cron jobs via GoCronScheduler.
func NewScheduleSyncer ¶
func NewScheduleSyncer( triggerRepo interfaces.TriggerRepo, scheduler *GoCronScheduler, resyncInterval time.Duration, ) *ScheduleSyncer
NewScheduleSyncer constructs a ScheduleSyncer.