-
Notifications
You must be signed in to change notification settings - Fork 488
/
manager.go
84 lines (62 loc) · 2.83 KB
/
manager.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
package manager
import (
"build-booster/server/pkg/engine"
)
// Manager describe the build-booster server exported methods
// beyond this we can write a http-server to provide build service.
type Manager interface {
// Run brings up the manager processor
Run()
// CreateTask receive TaskCreateParam and create a new task from setting.
// since task was created, its lifetime begins with procedure, until it has been released.
CreateTask(param *TaskCreateParam) (*engine.TaskBasic, error)
// ReleaseTask receive TaskReleaseParam and release a task into terminated status.
ReleaseTask(param *TaskReleaseParam) error
// SendMessage receive the raw data and send it into engine, then get the message back
SendProjectMessage(projectID string, data []byte) ([]byte, error)
// SendMessage receive the raw data and send it into engine, then get the message back
SendTaskMessage(taskID string, data []byte) ([]byte, error)
// GetTaskRank return the rank of the specified task in waiting queue.
GetTaskRank(taskID string) (int, error)
// GetTaskExtension return the task extension with given taskID .
GetTaskExtension(taskID string) (engine.TaskExtension, error)
// GetTaskBasic return the unterminated task basic from cache.
// if task basic does not exist or has already in terminated status, it return error ErrorUnterminatedTaskNoFound
GetTaskBasic(taskID string) (*engine.TaskBasic, error)
// GetTask return both task extension and task basic with given taskID .
GetTask(taskID string) (*engine.TaskBasic, engine.TaskExtension, error)
// UpdateHeartbeat support update heartbeat for unterminated task
UpdateHeartbeat(taskID string) error
}
// TaskCreateParam describe the param struct when creating a new task
type TaskCreateParam struct {
// specify which projectID the task belongs to
// project settings will be pulled and set into task settings.
ProjectID string
// specify which buildID the task belongs to
// does not matter in build-booster server, just a manual index for task
BuildID string
// client version for requesting for the creation action
ClientVersion string
// client local cpu num from the requesting machine
ClientCPU int
// IP v4 of the requesting machine
ClientIP string
// Client message for this task
Message string
// Extra contains the raw string for different engines' settings
// it is the engine's responsibility to decode from it.
Extra string
}
// TaskReleaseParam describe the param struct when releasing a unterminated task
type TaskReleaseParam struct {
// specify which task will be released
TaskID string
// Client message for this task
Message string
// if the task success or not, deciding the status of the task in terminated, success or failed.
Success bool
// Extra contains the raw string for different engines' settings
// it is the engine's responsibility to decode from it.
Extra string
}