增加实例的删除
This commit is contained in:
parent
f98497fc0d
commit
d18837e297
@ -84,3 +84,12 @@ type WrapperClient struct {
|
||||
func (wc *WrapperClient) GetClient() *clientv3.Client {
|
||||
return wc.client
|
||||
}
|
||||
|
||||
// Close 关闭
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 14:38 2023/8/15
|
||||
func (wc *WrapperClient) Close() error {
|
||||
return wc.GetClient().Close()
|
||||
}
|
||||
|
18
init.go
18
init.go
@ -101,3 +101,21 @@ func (c *client) GetClientWithError(flag string) (*WrapperClient, error) {
|
||||
}
|
||||
return c.table[flag], nil
|
||||
}
|
||||
|
||||
// RemoveClient 删除client连接
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 14:37 2023/8/15
|
||||
func (c *client) RemoveClient(flag string) {
|
||||
c.lock.RLock()
|
||||
defer c.lock.RUnlock()
|
||||
if _, exist := c.table[flag]; !exist {
|
||||
return
|
||||
}
|
||||
// 关闭连接
|
||||
_ = c.table[flag].Close()
|
||||
// 清除实例
|
||||
delete(c.table, flag)
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user