From 7ef6e95d701f65a25ad2dcb9ced6d5e76e4b1403 Mon Sep 17 00:00:00 2001 From: "insanity@loafle.com" Date: Tue, 16 May 2017 18:04:04 +0900 Subject: [PATCH] poller --- poller.go | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/poller.go b/poller.go index 3c81e9a..a33a2cd 100644 --- a/poller.go +++ b/poller.go @@ -25,7 +25,7 @@ type Poller struct { taskCh chan interface{} } -func Start(ch chan bool, conf *cm.GlobalConfig) error { +func Start(ch chan bool, conf *cm.GlobalConfig) error { p := GetInstance() p.gconf = conf p.startPolling() @@ -39,7 +39,6 @@ func GetTaskCh() chan interface{} { return p.taskCh } - func Stop(polStopped chan bool) error { GetInstance().stop() polStopped <- true @@ -62,7 +61,7 @@ func UpdateInterval(interval string) error { return nil } -func (p *Poller) startPolling() { +func (p *Poller) startPolling() { go func() { p.scheduler = &s.Scheduler{} @@ -93,23 +92,23 @@ func (p *Poller) polling(agentId string) { go func() { log.Println("POLLING....") /* - addr := p.gconf.Central.Address + ":" + string(p.gconf.Central.Port) - conn, err := grpc.Dial(addr, grpc.WithInsecure()) - if err != nil { - log.Println(err) - return - } - defer conn.Close() + addr := p.gconf.Central.Address + ":" + string(p.gconf.Central.Port) + conn, err := grpc.Dial(addr, grpc.WithInsecure()) + if err != nil { + log.Println(err) + return + } + defer conn.Close() - //todo temporary - client := pb.NewStatusClient(conn) - //printStatusStream(client) //stream - out, err := client.Status(context.Background(), &pb.Empty{}) - if err != nil { - log.Println(err) - } + //todo temporary + client := pb.NewStatusClient(conn) + //printStatusStream(client) //stream + out, err := client.Status(context.Background(), &pb.Empty{}) + if err != nil { + log.Println(err) + } - p.taskCh <- out + p.taskCh <- out */ }() }