-
Notifications
You must be signed in to change notification settings - Fork 492
/
task.go
32 lines (23 loc) · 1.37 KB
/
task.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package backend
import (
"context"
"time"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/kapacitor/task/taskmodel"
)
// TaskControlService is a low-level controller interface, intended to be passed to
// task executors and schedulers, which allows creation, completion, and status updates of runs.
type TaskControlService interface {
// CreateRun creates a run with a scheduled for time.
CreateRun(ctx context.Context, taskID platform.ID, scheduledFor time.Time, runAt time.Time) (*taskmodel.Run, error)
CurrentlyRunning(ctx context.Context, taskID platform.ID) ([]*taskmodel.Run, error)
ManualRuns(ctx context.Context, taskID platform.ID) ([]*taskmodel.Run, error)
// StartManualRun pulls a manual run from the list and moves it to currently running.
StartManualRun(ctx context.Context, taskID, runID platform.ID) (*taskmodel.Run, error)
// FinishRun removes runID from the list of running tasks and if its `ScheduledFor` is later then last completed update it.
FinishRun(ctx context.Context, taskID, runID platform.ID) (*taskmodel.Run, error)
// UpdateRunState sets the run state at the respective time.
UpdateRunState(ctx context.Context, taskID, runID platform.ID, when time.Time, state taskmodel.RunStatus) error
// AddRunLog adds a log line to the run.
AddRunLog(ctx context.Context, taskID, runID platform.ID, when time.Time, log string) error
}