浏览代码

cluster admin from client (#1415)

Artem Denisov 6 年之前
父节点
当前提交
43f1fb8c69
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      admin.go

+ 6 - 1
admin.go

@@ -105,9 +105,14 @@ func NewClusterAdmin(addrs []string, conf *Config) (ClusterAdmin, error) {
 	if err != nil {
 		return nil, err
 	}
+	return NewClusterAdminFromClient(client)
+}
 
+// NewClusterAdminFromClient creates a new ClusterAdmin using the given client.
+// Note that underlying client will also be closed on admin's Close() call.
+func NewClusterAdminFromClient(client Client) (ClusterAdmin, error) {
 	//make sure we can retrieve the controller
-	_, err = client.Controller()
+	_, err := client.Controller()
 	if err != nil {
 		return nil, err
 	}