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 {