collector

This commit is contained in:
insanity@loafle.com 2017-05-16 18:03:45 +09:00
parent f205c2e550
commit c75555a71c

View File

@ -63,29 +63,29 @@ func (c *Collector) stop() {
} }
func (c *Collector) collect(id string) { 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) dc := grpc.NewDataClient(conn)
log.Printf("COLLECT %s - [ID: %s] [Crawler : %s]", time.Now(), conf.Id, conf.Crawler.Name) in := &grpc.Input{}
conn, err := crm.GetInstance().GetClient(conf.Crawler.Container)
if err != nil {
log.Println(err)
}
defer conn.Close()
dc := grpc.NewDataClient(conn) in.Id = id
in := &grpc.Input{} in.Name = grpc.Crawlers(grpc.Crawlers_value[conf.Crawler.Name])
in.Id = id out, err := dc.Get(context.Background(), in)
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
if err != nil {
log.Println(err)
}
log.Println("collector get result : ", out)
c.dataCh <- out
}()
} }
func (c *Collector) addSensor(sensorId string) error { func (c *Collector) addSensor(sensorId string) error {