instance GetClient
This commit is contained in:
snoop 2017-04-17 13:33:11 +09:00
parent 4b602c5b18
commit 837b3070bb
2 changed files with 14 additions and 5 deletions

View File

@ -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())
}

View File

@ -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"