Documentation
¶
Overview ¶
Package maintenance runs the leader-only background services and the cancel poller.
Index ¶
- Constants
- func RescueCompletion(row *job.Row, now time.Time, retry func(*job.Row, time.Time) time.Time) job.Completion
- func RunAll(ctx context.Context, services ...Service)
- type Base
- type CancelPoller
- type Cleaner
- type DepthSampler
- type Periodic
- type PeriodicJob
- type Reindexer
- type Rescuer
- type Scheduler
- type Service
Constants ¶
View Source
const ( DefaultSchedulerInterval = time.Second DefaultCleanerInterval = 30 * time.Second DefaultDepthInterval = 15 * time.Second DefaultPeriodicInterval = time.Second DefaultBatch = 1000 RunTimeout = 2 * time.Minute ReindexTimeout = time.Hour )
View Source
const DefaultTickRetention = 7 * 24 * time.Hour
View Source
const PeriodicGrace = 15 * time.Second
Variables ¶
This section is empty.
Functions ¶
func RescueCompletion ¶
Types ¶
type CancelPoller ¶
type CancelPoller struct {
Store job.CancelPoller
Clock clock.Clock
Logger *slog.Logger
Interval time.Duration
Running func() []int64
OnCancel func(id int64)
}
CancelPoller finds cancel requests for this client's running jobs by polling.
func (*CancelPoller) Poll ¶
func (p *CancelPoller) Poll(ctx context.Context)
type Cleaner ¶
type Cleaner struct {
Base
Interval time.Duration
Retention map[job.State]time.Duration
TickRetention time.Duration
Batch int
}
Cleaner deletes finalized jobs older than their retention.
type DepthSampler ¶
type DepthSampler struct {
Base
Interval time.Duration
OnDepths func([]job.QueueDepth)
}
DepthSampler samples the queue depth per state for metrics.
type Periodic ¶
type Periodic struct {
Base
Jobs []PeriodicJob
Interval time.Duration
OnSkipped func(name string, n int)
OnEnqueued func(name string, tick time.Time)
}
Periodic enqueues each periodic job once per tick.
type PeriodicJob ¶
type Rescuer ¶
type Rescuer struct {
Base
Interval time.Duration
StuckAfter time.Duration
Retry func(row *job.Row, now time.Time) time.Time
Batch int
OnRescued func(n int)
}
Rescuer returns running jobs without a heartbeat to retryable, or discards them when attempts run out.
Click to show internal directories.
Click to hide internal directories.