diff --git a/crawler_manager.go b/crawler_manager.go index 8502153..b1a981c 100644 --- a/crawler_manager.go +++ b/crawler_manager.go @@ -45,17 +45,17 @@ func init() { g_CrawlerMananger.init() } -func GetClient(container string) (*grpc.ClientConn, error) { - crm := GetInstance() - b := crm.checkContainer(&container) +func (c *CrawlerManager)GetClient(container string) (*grpc.ClientConn, error) { + + b := c.checkContainer(&container) if b == false { - err := crm.runAndInitContainer(&container) + err := c.runAndInitContainer(&container) if err != nil { return nil, err } } - gport := crm.portMap[container] + gport := c.portMap[container] return grpc.Dial(address+gport, grpc.WithInsecure()) } diff --git a/crawler_manager_test.go b/crawler_manager_test.go index acadf3b..5afb13c 100644 --- a/crawler_manager_test.go +++ b/crawler_manager_test.go @@ -209,6 +209,15 @@ func TestInitCM(t *testing.T) { GetInstance().stopContainerAll() } +func TestCallStatus(t *testing.T) { + c := "java" + GetInstance().runAndInitContainer(&c) + + callStatus(&c) + + GetInstance().stopContainer(&c) +} + func TestCallAdd(t *testing.T) { // c := "java"