diff --git a/crawler_manager.go b/crawler_manager.go index 101cedd..3114a11 100644 --- a/crawler_manager.go +++ b/crawler_manager.go @@ -11,8 +11,9 @@ import ( "os" "log" - "github.com/kataras/go-errors" + "path/filepath" + "errors" ) const ( @@ -44,27 +45,25 @@ func init() { //g_CrawlerMananger.init() } -func GetInstance() *CrawlerManager { - return g_CrawlerMananger; -} +func GetClient(container string) (*grpc.ClientConn, error) { + crm := GetInstance() + b := crm.checkContainer(&container) -func (c *CrawlerManager)GetClient(container string,port string) (*grpc.ClientConn, error) { - - b := c.checkContainer(&container) if b == false { - //c.runContainer(&container) - //CallInit() - err := c.runAndInitContainer(&container) + err := crm.runAndInitContainer(&container) if err != nil { return nil, err } } - - gport := c.portMap[container] + gport := crm.portMap[container] return grpc.Dial(address+gport, grpc.WithInsecure()) } +func GetInstance() *CrawlerManager { + return g_CrawlerMananger; +} + func readConfig(path string ) *config.Config {