From 985d4476989e808a2ab5aa0e4fed92a46f7ec0a6 Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期六, 17 十月 2020 15:23:13 +0800
Subject: [PATCH] findCluster use proto

---
 cluster.go |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/cluster.go b/cluster.go
index f3992ce..3f97bca 100644
--- a/cluster.go
+++ b/cluster.go
@@ -1,6 +1,7 @@
 package dbapi
 
 import (
+	"basic.com/pubsub/protomsg.git"
 	"encoding/json"
 	"strconv"
 )
@@ -23,20 +24,21 @@
 	return "http://"+api.Ip+":"+strconv.Itoa(api.Port)
 }
 
-func (api ClusterApi) FindCluster() (bool,interface{}) {
+func (api ClusterApi) FindCluster() (b bool,c protomsg.ClusterAndNodes) {
 	url := api.getBasicUrl() + DATA_URL_PREFIX + "/cluster/findCluster"
 	client := NewClient()
 	body,err := client.DoGetRequest(url, nil,nil)
 	if err != nil {
-		return false,nil
+		return false,c
 	}
 
 	var res Result
 	if err = json.Unmarshal(body, &res); err != nil {
-		return false,nil
+		return false,c
 	}
-
-	return res.Success,res.Data
+	bytes, _ := json.Marshal(res.Data)
+	err = json.Unmarshal(bytes, &c)
+	return res.Success,c
 }
 
 func (api ClusterApi) Create(clusterName string, password string, virtualIp string) (bool,interface{}) {

--
Gitblit v1.8.0