-
Notifications
You must be signed in to change notification settings - Fork 0
/
job.go
68 lines (62 loc) · 1.26 KB
/
job.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
package gomsf
import "strconv"
const (
jobinfo = "job.info"
joblist = "job.list"
jobstop = "job.stop"
)
type Job struct {
Id int
Name string
}
type JobDetail struct {
Id int `msgpack:"jid"`
Name string `msgpack:"name"`
StartT int64 `msgpack:"start_time"`
Uri string `msgpack:"uripath"`
DataStore map[string]interface{} `msgpack:"datastore"`
}
func JobList(cli MsfCli, token string) ([]*Job, error) {
var (
sts = []string{joblist, token}
infos []*Job
)
var retvar map[string]string
err := cli.Send(sts, &retvar)
if err != nil {
return nil, err
}
for k, v := range retvar {
kint, err := strconv.Atoi(k)
if err != nil {
continue
}
infos = append(infos, &Job{
Id: kint,
Name: v,
})
}
return infos, nil
}
func JobStop(cli MsfCli, token, jobid string) (*Generic, error) {
var (
retv *Generic
sts = []string{jobstop, token, jobid}
)
err := cli.Send(sts, &retv)
if err != nil {
return nil, err
}
return retv, nil
}
func JobInfo(cli MsfCli, token, jobid string) (*JobDetail, error) {
var (
retv *JobDetail
sts = []string{jobinfo, token, jobid}
)
err := cli.Send(sts, &retv)
if err != nil {
return nil, err
}
return retv, nil
}