WH01243 4 yıl önce
ebeveyn
işleme
4632295704
3 değiştirilmiş dosya ile 55 ekleme ve 3 silme
  1. 5 3
      rpc/internal/config/config.go
  2. 14 0
      rpc/test/integral.yaml
  3. 36 0
      rpc/test/test1_test.go

+ 5 - 3
rpc/internal/config/config.go

@@ -8,7 +8,9 @@ import (
 
 type Config struct {
 	zrpc.RpcServerConf
-	DataSource string             // 手动代码
-	Cache      cache.CacheConf    // 手动代码
+	FileSystemConf zrpc.RpcClientConf
+	DataSource     string          // 手动代码
+	Cache          cache.CacheConf // 手动代码
 }
-var Engine *xorm.Engine
+
+var Engine *xorm.Engine

+ 14 - 0
rpc/test/integral.yaml

@@ -0,0 +1,14 @@
+Name: integral.rpc
+ListenOn: 127.0.0.1:8080
+Etcd:
+  Hosts:
+    - 127.0.0.1:2379
+  Key: integral.rpc
+DataSource: admin:123456@tcp(192.168.3.14:3306)/jyintegral?charset=utf8
+Cache:
+  - Host: localhost:6379
+FileSystemConf:
+  Etcd:
+    Hosts:
+      - 127.0.0.1:2379
+    Key: integral.rpc

+ 36 - 0
rpc/test/test1_test.go

@@ -0,0 +1,36 @@
+package test
+
+import (
+	"context"
+	"flag"
+	"github.com/tal-tech/go-zero/core/conf"
+	"github.com/tal-tech/go-zero/zrpc"
+	"log"
+	"points_service/rpc/integral"
+	"points_service/rpc/integralclient"
+	"points_service/rpc/internal/config"
+	"testing"
+	"time"
+)
+var configFile = flag.String("f", "integral.yaml", "the config file")
+var c config.Config
+
+func init() {
+	conf.MustLoad(*configFile, &c)
+}
+
+/*func Test_add(t *testing.T) {
+	var c config.Config
+	conf.MustLoad(*configFile, &c)
+	ctx := svc.NewServiceContext(c)
+	srv := server.NewAdderServer(ctx)
+	fmt.Println(srv.Add(context.Background(), &add.AddReq{Book: "lz-zero",Price:120}))
+}*/
+func  Test_add(t *testing.T)  {
+	ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
+	FileSystem :=integralclient.NewIntegral(zrpc.MustNewClient(c.FileSystemConf))
+	req := &integral.AddReq{UserId: "xzh", CountPoints: 123}
+	res, err := FileSystem.IntegralBalanceCheck(ctx, req)
+	log.Println("err ", err)
+	log.Println("req ", res)
+}