Documentation
¶
Overview ¶
Package runner is the loop every worker runs: register with the backend, lease jobs, run the handler of the job's kind while renewing the lease, and report how it ended. It knows nothing about providers; a provider package registers handlers for its kinds with Handle.
The fail-safes a worker contributes: the attempt runs under the backend's time limit; a lost lease or a cancel stops the handler; a handler that panics or returns an unclassified error ends the attempt as a retry (the backend bounds the retries); a worker that is shutting down gives its jobs back instead of leaving them to time out. A worker has no database: everything it learns or must remember goes through the backend.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsPermanent ¶
IsPermanent reports whether err was marked with Permanent.
func IsRetryable ¶
IsRetryable reports whether err was marked with Retryable, and the wait it asked for.
Types ¶
type Handler ¶
Handler runs one job. It returns the result (anything JSON-encodable, or nil) or an error. Return Permanent(err) for a problem trying again cannot fix (a wrong password, a revoked token, a bad request), Retryable(err, after) for a temporary one with a wait the provider asked for; any other error counts as temporary. The error text reaches the administrator and sometimes the person: never put a credential in it. Stop when ctx ends.
type Job ¶
type Job struct {
workerapi.Job
// Config is the administrator's configuration of the job's kind, as it was when the job started.
Config workerapi.KindConfig
// contains filtered or unexported fields
}
Job is what a handler works on.
type Options ¶
type Options struct {
ID string // unique per process; empty: random
Version string
Concurrency int // jobs run at once by this process (default 2)
// Poll is how long a lease request waits for a job (default workerapi.MaxWaitSeconds).
Poll time.Duration
// ConfigEvery is how often the configuration is re-read (default 15 s).
ConfigEvery time.Duration
}
Options configure a Runner.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner is one worker process.
func (*Runner) Ready ¶
Ready reports whether the worker is registered and has heard from the backend within maxAge: the readiness check of the worker's health listener. A worker that waits for a job is in contact all the time (it asks, and the backend answers when there is none), so a long silence means the backend or the link is down.