Task is a setup action that can conditionally run based on the state of a previous run.
| 42 | // Task is a setup action that can conditionally run based on the state of a |
| 43 | // previous run. |
| 44 | type Task interface { |
| 45 | Run(ctx context.Context) error |
| 46 | |
| 47 | // NeedsRun returns true if the task needs to be run. It should assume |
| 48 | // that lastRun persists across executions of the program and is unique |
| 49 | // for each user. |
| 50 | // |
| 51 | // A task that should only run once can check if lastRun.Time is the zero value. |
| 52 | // A task that only runs after an update can check if lastRun.Version < build.Version. |
| 53 | // A retryable task can check lastRun.Error to see if the previous run failed. |
| 54 | NeedsRun(ctx context.Context, lastRun RunInfo) bool |
| 55 | } |
| 56 | |
| 57 | // RunInfo contains metadata that describes the most recent run of a task. |
| 58 | type RunInfo struct { |
no outgoing calls
no test coverage detected