v1.2.1

Timeouts

Last updated

This page explains how a per-task execution limit and its timeout callback behave.

Setting a Limit

_, err := c.Add("@every 1m", slowJob, "slow job", 3*time.Second, func() {
    log.Println("slow job timed out")
})
if err != nil {
    log.Fatal(err)
}

The time.Duration argument is the execution limit, not a start delay; the func() argument is called only when that limit is exceeded.

Timeout Behavior

Behavior Description
Timer start When the action begins
On timeout Task marked TaskFailed; timeout callback invoked
Action goroutine Not interrupted; runs until it returns
No limit set Action runs synchronously until it returns

See Configuration for the full list of Add options.

中文