wangchuanjin 2 жил өмнө
parent
commit
fa3158558d

+ 11 - 2
middleground/middleground.go

@@ -1,11 +1,20 @@
 package middleground
 package middleground
 
 
 type Middleground struct {
 type Middleground struct {
+	hosts      []string
 	UserCenter *userCenter
 	UserCenter *userCenter
 }
 }
 
 
-func NewMiddleground(hosts []string, key string) *Middleground {
+func NewMiddleground(hosts []string) *Middleground {
 	return &Middleground{
 	return &Middleground{
-		UserCenter: newUserCenter(hosts, key),
+		hosts: hosts,
 	}
 	}
 }
 }
+
+func (m *Middleground) RegUserCenter(key string) {
+	m.UserCenter = newUserCenter(m.hosts, key)
+}
+
+func (m *Middleground) RegPowerCheckCenter(key string) {
+
+}

+ 34 - 0
middleground/powercheckcenter.go

@@ -0,0 +1,34 @@
+package middleground
+
+import (
+	"log"
+
+	"github.com/zeromicro/go-zero/core/discov"
+	"github.com/zeromicro/go-zero/zrpc"
+)
+
+type powerCheckCenter struct {
+	hosts []string
+	key   string
+}
+
+func newPowerCheckCenter(hosts []string, key string) *userCenter {
+	return &userCenter{
+		hosts: hosts,
+		key:   key,
+	}
+}
+
+func (p *powerCheckCenter) newClient() zrpc.Client {
+	client, err := zrpc.NewClient(zrpc.RpcClientConf{
+		Etcd: discov.EtcdConf{
+			Hosts: p.hosts,
+			Key:   p.key,
+		},
+	})
+	if err != nil {
+		log.Println(err)
+		return nil
+	}
+	return client
+}