in proxy/protocol/dubbo/client/dubbo_client.go [74:108]
func (this *ClientMgr) GetClient(addr string, timeout time.Duration) (*DubboClient, error) {
this.mapMutex.Lock()
defer this.mapMutex.Unlock()
if tmp, ok := this.clients[addr]; ok {
if timeout <= 0 {
timeout = 30 * time.Second
}
if tmp.Timeout != timeout {
tmp.Timeout = timeout
this.clients[addr] = tmp
}
if !tmp.Closed() {
openlog.Info("GetClient from cached addr:" + addr)
return tmp, nil
} else {
err := tmp.ReOpen()
openlog.Info("GetClient repopen addr:" + addr)
if err != nil {
delete(this.clients, addr)
return nil, err
} else {
return tmp, nil
}
}
}
openlog.Info("GetClient from new open addr:" + addr)
tmp := NewDubboClient(addr, nil, timeout)
err := tmp.Open()
if err != nil {
return nil, err
} else {
this.clients[addr] = tmp
return tmp, nil
}
}