-
Notifications
You must be signed in to change notification settings - Fork 488
/
types.go
93 lines (74 loc) · 2.53 KB
/
types.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
88
89
90
91
92
93
package v2
const (
queryTaskIDKey = "task_id"
)
// ParamApply describe the protocol of applying a piece of resources for distribute workers
// and there will be a TaskBasic to maintain the resource lifetime.
type ParamApply struct {
// project_id describe which project this task belongs to
// project is used to check whitelist and get static settings.
ProjectID string `json:"project_id"`
// scene describe the addition unique part of this project.
// If it is empty, the project_id is the final project_id,
// else, the project_id should be made of project_id + scene
Scene string `json:"scene"`
// build_id is not used during the whole lifetime, just a specific key for query
BuildID string `json:"build_id"`
// client_version
ClientVersion string `json:"client_version"`
Message string `json:"message"`
ClientCPU int `json:"client_cpu"`
// extra is a raw string contains the extra configurations for specific engine,
// it will be parsed in engine handler.
Extra string `json:"extra"`
}
// RespTaskInfo contains the return data of Apply and Query
type RespTaskInfo struct {
TaskID string `json:"task_id"`
Status string `json:"status"`
HostList []string `json:"host_list"`
QueueNumber int `json:"queue_number"`
Message string `json:"message"`
Extra string `json:"extra"`
}
// ParamHeartbeat contains the UpdateHeartbeat request data
type ParamHeartbeat struct {
TaskID string `json:"task_id"`
Type string `json:"type"`
}
// RespHeartbeat contains the return data of UpdateHeartbeat
type RespHeartbeat struct {
TaskID string `json:"task_id"`
Type string `json:"type"`
}
type HeartBeatType string
// get string data from heartbeat type
func (h HeartBeatType) String() string {
return string(h)
}
const (
HeartBeatPing HeartBeatType = "ping"
HeartBeatPong HeartBeatType = "pong"
)
// ParamRelease contains the ReleaseTask request data
type ParamRelease struct {
TaskID string `json:"task_id"`
Message string `json:"message"`
Success bool `json:"success"`
// extra is a raw string contains the summary data from client for specific engine,
// it will be parsed in engine handler.
Extra string `json:"extra"`
}
// ParamMessage contains the SendMessage request data
type ParamMessage struct {
Type MessageType `json:"type"`
TaskID string `json:"task_id"`
ProjectID string `json:"project_id"`
Scene string `json:"scene"`
Extra string `json:"extra"`
}
type MessageType string
const (
MessageTask MessageType = "task"
MessageProject MessageType = "project"
)