Browse Source

cluster admin from client (#1415)

Artem Denisov 6 years ago
parent
commit
43f1fb8c69
1 changed files with 6 additions and 1 deletions
  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
 	}