-
Notifications
You must be signed in to change notification settings - Fork 0
/
status.go
43 lines (35 loc) · 981 Bytes
/
status.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
package ecflow_watchman
import (
"encoding/json"
"github.com/nwpc-oper/ecflow-client-go"
log "github.com/sirupsen/logrus"
"time"
)
type EcflowServerStatus struct {
StatusRecords json.RawMessage `json:"status_records"`
CollectedTime time.Time `json:"collected_time"`
}
func GetEcflowStatus(config EcflowServerConfig, client *ecflow_client.EcflowClient) *EcflowServerStatus {
log.WithFields(log.Fields{
"owner": config.Owner,
"repo": config.Repo,
}).Infof("get nodes...")
ret := client.Sync()
if ret != 0 {
log.WithFields(log.Fields{
"owner": config.Owner,
"repo": config.Repo,
}).Errorf("sync has error: %v", ret)
return nil
}
recordsJson := client.StatusRecordsJson()
ecflowServerStatus := &EcflowServerStatus{
StatusRecords: json.RawMessage(recordsJson),
CollectedTime: client.CollectedTime,
}
log.WithFields(log.Fields{
"owner": config.Owner,
"repo": config.Repo,
}).Infof("get nodes...done")
return ecflowServerStatus
}