-
Notifications
You must be signed in to change notification settings - Fork 54
/
protocol.go
188 lines (165 loc) · 4.18 KB
/
protocol.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
package forest
import (
"context"
"github.com/coreos/etcd/clientv3"
"github.com/robfig/cron"
"time"
)
const (
KeyCreateChangeEvent = iota
KeyUpdateChangeEvent
KeyDeleteChangeEvent
)
const (
JobCreateChangeEvent = iota
JobUpdateChangeEvent
JobDeleteChangeEvent
)
const (
JobRunningStatus = iota + 1
JobStopStatus
)
const (
NodeFollowerState = iota
NodeLeaderState
)
const (
JobExecuteSnapshotDoingStatus = 1
JobExecuteSnapshotSuccessStatus = 2
JobExecuteSnapshotUnkonwStatus = 3
JobExecuteSnapshotErrorStatus = -1
)
// key 变化事件
type KeyChangeEvent struct {
Type int
Key string
Value []byte
}
// 监听key 变化响应
type WatchKeyChangeResponse struct {
Event chan *KeyChangeEvent
CancelFunc context.CancelFunc
Watcher clientv3.Watcher
}
type TxResponse struct {
Success bool
LeaseID clientv3.LeaseID
Lease clientv3.Lease
Key string
Value string
}
type JobClientDeleteEvent struct {
Client *Client
Group *Group
}
// job
type JobConf struct {
Id string `json:"id"`
Name string `json:"name"`
Group string `json:"group"`
Cron string `json:"cron"`
Status int `json:"status"`
Target string `json:"target"`
Params string `json:"params"`
Mobile string `json:"mobile"`
Remark string `json:"remark"`
Version int `json:"version"`
}
type Result struct {
Code int `json:"code"`
Data interface{} `json:"data"`
Message string `json:"message"`
}
type GroupConf struct {
Name string `json:"name"`
Remark string `json:"remark"`
}
type JobChangeEvent struct {
Type int
Conf *JobConf
}
type SchedulePlan struct {
Id string `json:"id"`
Name string `json:"name"`
Group string `json:"group"`
Cron string `json:"cron"`
Status int `json:"status"`
Target string `json:"target"`
Params string `json:"params"`
Mobile string `json:"mobile"`
Remark string `json:"remark"`
schedule cron.Schedule
NextTime time.Time `json:"nextTime"`
BeforeTime time.Time `json:"beforeTime"`
Version int `json:"version"`
}
type JobSnapshot struct {
Id string `json:"id"`
JobId string `json:"jobId"`
Name string `json:"name"`
Ip string `json:"ip"`
Group string `json:"group"`
Cron string `json:"cron"`
Target string `json:"target"`
Params string `json:"params"`
Mobile string `json:"mobile"`
Remark string `json:"remark"`
CreateTime string `json:"createTime"`
}
type QueryClientParam struct {
Group string `json:"group"`
}
type JobClient struct {
Name string `json:"name"`
Path string `json:"path"`
Group string `json:"group"`
}
type QuerySnapshotParam struct {
Group string `json:"group"`
Id string `json:"id"`
Ip string `json:"ip"`
}
// node
type Node struct {
Name string `json:"name"`
State int `json:"state"`
}
type JobExecuteSnapshot struct {
Id string `json:"id",xorm:"pk"`
JobId string `json:"jobId",xorm:"job_id"`
Name string `json:"name",xorm:"name"`
Ip string `json:"ip",xorm:"ip"`
Group string `json:"group",xorm:"group"`
Cron string `json:"cron",xorm:"cron"`
Target string `json:"target",xorm:"target"`
Params string `json:"params",xorm:"params"`
Mobile string `json:"mobile",xorm:"mobile"`
Remark string `json:"remark",xorm:"remark"`
CreateTime string `json:"createTime",xorm:"create_time"`
StartTime string `json:"startTime",xorm:"start_time"`
FinishTime string `json:"finishTime",xorm:"finish_time"`
Times int `json:"times",xorm:"times"`
Status int `json:"status",xorm:"status"`
Result string `json:"result",xorm:"result"`
}
type QueryExecuteSnapshotParam struct {
Group string `json:"group"`
Id string `json:"id"`
Ip string `json:"ip"`
JobId string `json:"jobId"`
Name string `json:"name"`
Status int `json:"status"`
PageSize int `json:"pageSize"`
PageNo int `json:"pageNo"`
}
type PageResult struct {
TotalPage int `json:"totalPage"`
TotalCount int `json:"totalCount"`
List interface{} `json:"list"`
}
// manual execute job
type ManualExecuteJobParam struct {
Id string `json:"id"`
Name string `json:"name"`
Group string `json:"group"`
}