-
Notifications
You must be signed in to change notification settings - Fork 151
/
push.go
42 lines (35 loc) · 830 Bytes
/
push.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
package cron
import (
"log"
"time"
"github.com/710leo/urlooker/dataobj"
"github.com/710leo/urlooker/modules/agent/backend"
"github.com/710leo/urlooker/modules/agent/g"
)
func Push() {
for {
checkResults := make([]*dataobj.CheckResult, 0)
itemResults := g.CheckResultQueue.PopBack(500)
if len(itemResults) == 0 {
time.Sleep(1 * time.Second)
continue
}
for _, itemResult := range itemResults {
checkResult := itemResult.(*dataobj.CheckResult)
checkResults = append(checkResults, checkResult)
}
var resp string
sendResultReq := dataobj.SendResultReq{
Ip: g.IP,
CheckResults: checkResults,
}
err := backend.CallRpc("Web.SendResult", sendResultReq, &resp)
if err != nil {
log.Println("error:", err)
}
if g.Config.Debug {
log.Println("<=", resp)
}
}
return
}