From c75555a71c5dd99ef9a6f5022a10b898d1b0f1c9 Mon Sep 17 00:00:00 2001 From: "insanity@loafle.com" Date: Tue, 16 May 2017 18:03:45 +0900 Subject: [PATCH] collector --- collector.go | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/collector.go b/collector.go index 07edbe0..fbbbb12 100644 --- a/collector.go +++ b/collector.go @@ -63,29 +63,29 @@ func (c *Collector) stop() { } func (c *Collector) collect(id string) { + go func() { + conf := c.cm.GetSensorById(id) + log.Printf("COLLECT %s - [ID: %s] [Crawler : %s]", time.Now(), conf.Id, conf.Crawler.Name) + conn, err := crm.GetInstance().GetClient(conf.Crawler.Container) + if err != nil { + log.Println(err) + } + defer conn.Close() - conf := c.cm.GetSensorById(id) - log.Printf("COLLECT %s - [ID: %s] [Crawler : %s]", time.Now(), conf.Id, conf.Crawler.Name) - conn, err := crm.GetInstance().GetClient(conf.Crawler.Container) - if err != nil { - log.Println(err) - } - defer conn.Close() + dc := grpc.NewDataClient(conn) + in := &grpc.Input{} - dc := grpc.NewDataClient(conn) - in := &grpc.Input{} + in.Id = id + in.Name = grpc.Crawlers(grpc.Crawlers_value[conf.Crawler.Name]) - in.Id = id - in.Name = grpc.Crawlers(grpc.Crawlers_value[conf.Crawler.Name]) - - out, err := dc.Get(context.Background(), in) - - if err != nil { - log.Println(err) - } - log.Println("collector get result : ", out) - c.dataCh <- out + out, err := dc.Get(context.Background(), in) + if err != nil { + log.Println(err) + } + log.Println("collector get result : ", out) + c.dataCh <- out + }() } func (c *Collector) addSensor(sensorId string) error {