poller
This commit is contained in:
parent
7ef6e95d70
commit
ce344d6f50
22
poller.go
22
poller.go
|
@ -7,6 +7,8 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
"loafle.com/overflow/agent_api/messages"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -87,10 +89,29 @@ func (p *Poller) stop() {
|
||||||
p.scheduler.Stop()
|
p.scheduler.Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var once1 sync.Once
|
||||||
func (p *Poller) polling(agentId string) {
|
func (p *Poller) polling(agentId string) {
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
log.Println("POLLING....")
|
log.Println("POLLING....")
|
||||||
|
|
||||||
|
time.Sleep(time.Second * 20)
|
||||||
|
|
||||||
|
|
||||||
|
once1.Do(func() {
|
||||||
|
|
||||||
|
newTask := messages.AgentTask{}
|
||||||
|
newTask.Command = messages.TASK_POL_INTERVAL_UPDATE
|
||||||
|
param := make(map[string]string)
|
||||||
|
param["interval"] = "3"
|
||||||
|
newTask.Params = param
|
||||||
|
|
||||||
|
p.taskCh <- newTask
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
addr := p.gconf.Central.Address + ":" + string(p.gconf.Central.Port)
|
addr := p.gconf.Central.Address + ":" + string(p.gconf.Central.Port)
|
||||||
conn, err := grpc.Dial(addr, grpc.WithInsecure())
|
conn, err := grpc.Dial(addr, grpc.WithInsecure())
|
||||||
|
@ -115,6 +136,7 @@ func (p *Poller) polling(agentId string) {
|
||||||
|
|
||||||
func (p *Poller) updateInterval(interval int) {
|
func (p *Poller) updateInterval(interval int) {
|
||||||
p.scheduler.UpdateInterval(POLLING_ID, uint64(interval))
|
p.scheduler.UpdateInterval(POLLING_ID, uint64(interval))
|
||||||
|
log.Printf("Polling interval has changed to %d seconds.\n", interval)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue
Block a user