collector

This commit is contained in:
insanity@loafle.com 2017-05-17 12:55:08 +09:00
parent c75555a71c
commit fd7ea8daf6

View File

@ -9,7 +9,6 @@ import (
"log" "log"
"strconv" "strconv"
"sync" "sync"
"time"
) )
var ( var (
@ -65,7 +64,6 @@ func (c *Collector) stop() {
func (c *Collector) collect(id string) { func (c *Collector) collect(id string) {
go func() { go func() {
conf := c.cm.GetSensorById(id) 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) conn, err := crm.GetInstance().GetClient(conf.Crawler.Container)
if err != nil { if err != nil {
log.Println(err) log.Println(err)
@ -77,13 +75,11 @@ func (c *Collector) collect(id string) {
in.Id = id in.Id = id
in.Name = grpc.Crawlers(grpc.Crawlers_value[conf.Crawler.Name]) in.Name = grpc.Crawlers(grpc.Crawlers_value[conf.Crawler.Name])
out, err := dc.Get(context.Background(), in) out, err := dc.Get(context.Background(), in)
if err != nil { if err != nil {
log.Println(err) log.Printf("Cannot collect [ID: %s] [Crawler : %s] - [Err : %s]\n", conf.Id, conf.Crawler.Name, err)
} }
log.Println("collector get result : ", out) log.Printf("COLLECTED. [ID: %s] [Crawler : %s] [Result : %s]\n", conf.Id, conf.Crawler.Name, out.GetData() )
c.dataCh <- out c.dataCh <- out
}() }()
} }