Documentation
¶
Overview ¶
Package apitask provides a background execution context for background work that limits the execution time to the current request.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrTask = errors.New("apitask")
ErrTask is the base of all errors originating from apitasks.
Functions ¶
func Middleware ¶
Middleware wraps next with an http.Handler which adds apitasks handling to the request context and waits for all tasks to exit before returning.
func Run ¶
Run will run a request-scoped background task in a separate goroutine immediately if the current context supports it. Otherwise it makes an immediate blocking call to task.Run(ctx).
It is invalid to call Run within a tasks Run method.
Types ¶
type Task ¶
type Task interface {
// Type return a basic name for a task. It is not expected to be consistent
// with the underlying type, but it should be low cardinality.
Type() string
// Run should run this task.
Run(context.Context) error
}
Task is implemented by objects which may be ran in the background.
Click to show internal directories.
Click to hide internal directories.