根据服务名获取服务实例列表
chengjianxi opened this issue · comments
添加一个需求,根据服务名获取注册的服务列表
func (c *Client) GetApplicationInstance(name string) []Instance {
instances := make([]Instance, 0)
c.mutex.Lock()
if c.Applications != nil {
for _, app := range c.Applications.Applications {
if app.Name == name {
instances = append(instances, app.Instances...)
}
}
}
c.mutex.Unlock()
return instances
}
虽然现在可以用client.Applications
获取所有实例,但是没有锁我觉得不太安全
你可以提交一个PR,我合并进来
别忘了发布个版本