浏览代码

feat:增加积分中台

wangchuanjin 1 年之前
父节点
当前提交
76db4f3c4b
共有 1 个文件被更改,包括 41 次插入0 次删除
  1. 41 0
      middleground/jypoints.go

+ 41 - 0
middleground/jypoints.go

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