sqlite的api,便于内部使用
liuxiaolong
2019-08-22 342a7be1c4c9d216d6d985bb9873ce419a7b57a1
cluster.go
@@ -6,6 +6,22 @@
}
func (api ClusterApi) FindCluster() (bool,interface{}) {
   url := BASIC_URL + DATA_URL_PREFIX + "/cluster/findCluster"
   client := NewClient()
   body,err := client.DoGetRequest(url, nil,nil)
   if err != nil {
      return false,nil
   }
   var res Result
   if err = json.Unmarshal(body, &res); err != nil {
      return false,nil
   }
   return res.Success,res.Data
}
func (api ClusterApi) Create(clusterName string, password string) (bool,interface{}) {
   url := BASIC_URL + DATA_URL_PREFIX + "/cluster/create"
   client := NewClient()
@@ -47,7 +63,7 @@
}
func (api ClusterApi) GetSearchNodes() (bool,interface{}) {
   url := BASIC_URL + DATA_URL_PREFIX + "/cluster/getNodesByNum"
   url := BASIC_URL + DATA_URL_PREFIX + "/cluster/getSearchNodes"
   client := NewClient()
   body,err := client.DoGetRequest(url, nil,nil)
   if err != nil {
@@ -81,6 +97,42 @@
   return res.Success,res.Data
}
func (api ClusterApi) UpdateClusterName(clusterName string) (bool,interface{}) {
   url := BASIC_URL + DATA_URL_PREFIX + "/cluster/updateClusterName"
   client := NewClient()
   paramBody := map[string]interface{}{
      "clusterName": clusterName,
   }
   body,err := client.DoPostRequest(url,CONTENT_TYPE_FORM, paramBody,nil,nil)
   if err != nil {
      return false,nil
   }
   var res Result
   if err = json.Unmarshal(body, &res); err != nil {
      return false,nil
   }
   return res.Success,res.Data
}
func (api ClusterApi) Leave() (bool,interface{}) {
   url := BASIC_URL + DATA_URL_PREFIX + "/cluster/leave"
   client := NewClient()
   body,err := client.DoPostRequest(url,CONTENT_TYPE_FORM, nil,nil,nil)
   if err != nil {
      return false,nil
   }
   var res Result
   if err = json.Unmarshal(body, &res); err != nil {
      return false,nil
   }
   return res.Success,res.Data
}
func (api ClusterApi) JoinCluster(paramBody map[string]interface{}) (bool,interface{}) {
   url := BASIC_URL + DATA_URL_PREFIX + "/cluster/joinCluster"
   client := NewClient()
@@ -98,3 +150,4 @@
}