This commit is contained in:
insanity@loafle.com 2017-05-16 18:04:04 +09:00
parent 41d98d4b91
commit 7ef6e95d70

View File

@ -25,7 +25,7 @@ type Poller struct {
taskCh chan interface{} taskCh chan interface{}
} }
func Start(ch chan bool, conf *cm.GlobalConfig) error { func Start(ch chan bool, conf *cm.GlobalConfig) error {
p := GetInstance() p := GetInstance()
p.gconf = conf p.gconf = conf
p.startPolling() p.startPolling()
@ -39,7 +39,6 @@ func GetTaskCh() chan interface{} {
return p.taskCh return p.taskCh
} }
func Stop(polStopped chan bool) error { func Stop(polStopped chan bool) error {
GetInstance().stop() GetInstance().stop()
polStopped <- true polStopped <- true
@ -62,7 +61,7 @@ func UpdateInterval(interval string) error {
return nil return nil
} }
func (p *Poller) startPolling() { func (p *Poller) startPolling() {
go func() { go func() {
p.scheduler = &s.Scheduler{} p.scheduler = &s.Scheduler{}
@ -93,23 +92,23 @@ func (p *Poller) polling(agentId string) {
go func() { go func() {
log.Println("POLLING....") log.Println("POLLING....")
/* /*
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())
if err != nil { if err != nil {
log.Println(err) log.Println(err)
return return
} }
defer conn.Close() defer conn.Close()
//todo temporary //todo temporary
client := pb.NewStatusClient(conn) client := pb.NewStatusClient(conn)
//printStatusStream(client) //stream //printStatusStream(client) //stream
out, err := client.Status(context.Background(), &pb.Empty{}) out, err := client.Status(context.Background(), &pb.Empty{})
if err != nil { if err != nil {
log.Println(err) log.Println(err)
} }
p.taskCh <- out p.taskCh <- out
*/ */
}() }()
} }