Documentation
¶
Index ¶
- Constants
- Variables
- type CronSchedule
- type FixedInterval
- type Job
- type JobRecord
- type Logger
- type NextRunCalculator
- type Scheduler
- func (s *Scheduler) CancelJob(name, key string) error
- func (s *Scheduler) GetJob(name, key string) (*JobRecord, error)
- func (s *Scheduler) Init() error
- func (s *Scheduler) RegisterJob(job Job) error
- func (s *Scheduler) ScheduleJob(job Job) error
- func (s *Scheduler) Shutdown()
- func (s *Scheduler) Start() error
- type SchedulerConfig
- type Status
Constants ¶
View Source
const (
ClusterSchedulerParametersKey = "ClusterSchedulerParametersKey"
)
Variables ¶
View Source
var ( ErrJobNotFound = errors.New("job not found") ErrJobRunning = errors.New("job is currently running") ErrJobNotRunning = errors.New("job exists but is not currently running") )
Custom errors
Functions ¶
This section is empty.
Types ¶
type CronSchedule ¶ added in v0.1.4
type CronSchedule struct {
// contains filtered or unexported fields
}
CronSchedule implements NextRunCalculator using cron expressions
func NewCronSchedule ¶ added in v0.1.4
func NewCronSchedule(expression string) (*CronSchedule, error)
type FixedInterval ¶ added in v0.1.4
type FixedInterval struct {
// contains filtered or unexported fields
}
FixedInterval implements NextRunCalculator using fixed time intervals
func NewFixedInterval ¶ added in v0.1.4
func NewFixedInterval(interval time.Duration) *FixedInterval
type Job ¶
type Job interface {
Name() string
Key() string
Run(ctx context.Context) error
NextRunCalculator() NextRunCalculator
Parameters() interface{}
MaxRetries() int
}
Job defines the interface for a schedulable job
type JobRecord ¶ added in v0.1.4
type JobRecord struct {
Name string `db:"name"`
Key string `db:"key"`
LastRun sql.NullTime `db:"last_run"`
Picked bool `db:"picked"`
PickedBy uuid.NullUUID `db:"picked_by"`
Heartbeat sql.NullTime `db:"heartbeat"`
NextRun *time.Time `db:"next_run"`
Parameters json.RawMessage `db:"parameters"`
Status Status `db:"status"`
Retries int `db:"retries"`
ExecutionTime sql.NullInt64 `db:"execution_time"`
LastSuccess sql.NullTime `db:"last_success"`
LastFailure sql.NullTime `db:"last_failure"`
ConsecutiveFailures int `db:"consecutive_failures"`
CancelRequested bool `db:"cancel_requested"`
}
type NextRunCalculator ¶ added in v0.1.4
NextRunCalculator defines how to calculate the next run time
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
func NewScheduler ¶
func NewScheduler(config SchedulerConfig) (*Scheduler, error)
func (*Scheduler) RegisterJob ¶ added in v0.1.4
func (*Scheduler) ScheduleJob ¶
type SchedulerConfig ¶
type SchedulerConfig struct {
Ctx context.Context
DB *sql.DB
DBDriverName string
MaxRunningJobs int
JobCheckInterval time.Duration
OrphanedJobTimeout time.Duration
HeartbeatInterval time.Duration
NoHeartbeatTimeout time.Duration
CreateSchema bool
Logger Logger
RunImmediately bool
TablePrefix string
ShutdownTimeout time.Duration
FailedAndCompletedJobCleanupInterval time.Duration
CancelCheckPeriod time.Duration
NotificationDebounceInterval time.Duration
JobStatusChangeCallback func(name, key string, prevStatus, newStatus Status)
Schema string
PGLNInstance *pgln.PGListenNotify
// contains filtered or unexported fields
}
SchedulerConfig represents the configuration for the Scheduler
Click to show internal directories.
Click to hide internal directories.