-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
Copy pathtask.go
87 lines (70 loc) · 2.44 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package platform
import "context"
// Task is a task. 🎊
type Task struct {
ID ID `json:"id,omitempty"`
Organization ID `json:"organizationId"`
Name string `json:"name"`
Status string `json:"status"`
Owner User `json:"owner"`
Flux string `json:"flux"`
Every string `json:"every,omitempty"`
Cron string `json:"cron,omitempty"`
Last Run `json:"last,omitempty"`
}
// Run is a record created when a run of a task is queued.
type Run struct {
ID ID `json:"id,omitempty"`
Status string `json:"status"`
QueuedAt string `json:"queuedAt"`
StartTime string `json:"startTime"`
EndTime string `json:"endTime"`
Log Log `json:"log"`
}
// Log represents a link to a log resource
type Log string
// TaskService represents a service for managing one-off and recurring tasks.
type TaskService interface {
// Returns a single task
FindTaskByID(ctx context.Context, id ID) (*Task, error)
// Returns a list of tasks that match a filter (limit 100) and the total count
// of matching tasks.
FindTasks(ctx context.Context, filter TaskFilter) ([]*Task, int, error)
// Creates a new task
CreateTask(ctx context.Context, t *Task) error
// Updates a single task with changeset
UpdateTask(ctx context.Context, id ID, upd TaskUpdate) (*Task, error)
// Removes a task by ID and purges all associated data and scheduled runs
DeleteTask(ctx context.Context, id ID) error
// Returns logs for a run.
FindLogs(ctx context.Context, filter LogFilter) ([]*Log, int, error)
// Returns a list of runs that match a filter and the total count of returned runs.
FindRuns(ctx context.Context, filter RunFilter) ([]*Run, int, error)
// Returns a single run
FindRunByID(ctx context.Context, id ID) (*Run, error)
// Creates and returns a new run (which is a retry of another run)
RetryRun(ctx context.Context, id ID) (*Run, error)
}
// TaskUpdate represents updates to a task
type TaskUpdate struct {
Flux *string `json:"flux"`
}
// TaskFilter represents a set of filters that restrict the returned results
type TaskFilter struct {
After *ID
Organization *ID
User *ID
}
// RunFilter represents a set of filters that restrict the returned results
type RunFilter struct {
Task *ID
After *ID
Limit int
AfterTime string
BeforeTime string
}
// LogFilter represents a set of filters that restrict the returned results
type LogFilter struct {
Task *ID
Run *ID
}