summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLvbo163 <lv.bo163@zte.com.cn>2018-08-02 09:15:56 +0800
committerLvbo163 <lv.bo163@zte.com.cn>2018-08-02 09:15:56 +0800
commit2919645aa79e54f9a3f0da8d799dc266f961f64f (patch)
tree8a504489ef2e33c3293b2d161732f22dbd206e36
parent355d078327c728c626c437f8c882c87897f1d0ab (diff)
get data from consul
Issue-ID: MSB-243 Change-Id: I00cc63ef47d107c98e8fc9a46f668eae876e7381 Signed-off-by: Lvbo163 <lv.bo163@zte.com.cn>
-rw-r--r--msb2pilot/src/msb2pilot/consul/controller.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/msb2pilot/src/msb2pilot/consul/controller.go b/msb2pilot/src/msb2pilot/consul/controller.go
index ca57bd2..1ba2cd8 100644
--- a/msb2pilot/src/msb2pilot/consul/controller.go
+++ b/msb2pilot/src/msb2pilot/consul/controller.go
@@ -71,3 +71,21 @@ func loadCfgInfo(path string) (map[interface{}]interface{}, error) {
}
return result, nil
}
+
+func GetServices() (map[string][]string, error) {
+ data, _, err := client.Catalog().Services(nil)
+
+ if err != nil {
+ return nil, err
+ }
+ return data, nil
+}
+
+func GetInstances(serviceName string) ([]*api.CatalogService, error) {
+ endpoints, _, err := client.Catalog().Service(serviceName, "", nil)
+ if err != nil {
+ log.Log.Error("can not get endpoints of ", serviceName)
+ return nil, err
+ }
+ return endpoints, nil
+}