From 9815ccc84bfd043e3ca2de3eb4256514d43e7d0e Mon Sep 17 00:00:00 2001 From: "jackdaw@loafle.com" Date: Mon, 17 Apr 2017 14:09:22 +0900 Subject: [PATCH] get --- collector.go | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/collector.go b/collector.go index 4b67c78..11bca8d 100644 --- a/collector.go +++ b/collector.go @@ -12,7 +12,9 @@ import ( "path/filepath" "strings" "time" - //crm "loafle.com/overflow/crawler_manager_go" + crm "loafle.com/overflow/crawler_manager_go" + "context" + g "loafle.com/overflow/crawler_go/grpc" ) const CONFIG_ROOT = "/config/container" @@ -48,24 +50,24 @@ func (c *Collector) collect(id string) { log.Printf("COLLECT %s - [ID: %s] [Crawler : %s]", time.Now(), conf.Id, conf.Crawler.Name) - //conn, err := crm.GetClient(conf.Crawler.Container) - //if err != nil { - // log.Println(err) - //} - //defer conn.Close() + conn, err := crm.GetInstance().GetClient(conf.Crawler.Container) + if err != nil { + log.Println(err) + } + defer conn.Close() - //dc := g.NewDataClient(conn); - //in := &g.Input{} - // - //in.Id = id - //in.Name = g.Crawlers_HEALTH_MONGODB - // - //out, err := dc.Get(context.Background(), in) - // - //if err != nil { - // log.Println(err) - //} - //log.Println(out) + dc := g.NewDataClient(conn); + in := &g.Input{} + + in.Id = id + in.Name = g.Crawlers(g.Crawlers_value[conf.Crawler.Name]) + + out, err := dc.Get(context.Background(), in) + + if err != nil { + log.Println(err) + } + log.Println(out) } func (c *Collector) AddSensor(path string) {