Documentation
¶
Overview ¶
Package scanjobs runs long administrative work, such as schema scans, on the Scan lane of the execution bus, off the request path: a request starts a job and polls it, so a slow database ties up neither the request nor the service.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrBusy = errors.New("scanjobs: too many jobs queued; retry later")
ErrBusy is returned when the queue is full.
Functions ¶
This section is empty.
Types ¶
type Job ¶
type Job[T any] struct { ID string // Label says what the job works on (a datasource name). Label string State State Result T Err string }
Job is a snapshot of one job.
type Options ¶
type Options struct {
// Bus runs the jobs on its Scan lane, whose limits then replace Workers
// and Queue; without one the pool has a lane of its own.
Bus *bus.Bus
Workers int // concurrent jobs (default 2)
Queue int // jobs waiting for a worker (default 8)
Timeout time.Duration // per job (default 5m)
// Keep is how long a finished job stays readable (default 10m).
Keep time.Duration
}
Options size the pool.
type Pool ¶
type Pool[T any] struct { // contains filtered or unexported fields }
Pool runs jobs that produce a T.
func (*Pool[T]) Cancel ¶
Cancel stops job id: a pending job never runs, a running one has its context canceled.
Click to show internal directories.
Click to hide internal directories.