mirror of
https://github.com/gmsec/gmsec.git
synced 2025-09-26 20:01:21 +08:00
fix: 导包路径不规范
feat: 调整server&client测试用例
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -13,3 +13,5 @@
|
|||||||
|
|
||||||
# Dependency directories (remove the comment below to include it)
|
# Dependency directories (remove the comment below to include it)
|
||||||
# vendor/
|
# vendor/
|
||||||
|
/.idea
|
||||||
|
*.iml
|
@@ -67,7 +67,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
proto "gmsec/rpc"
|
proto "github.com/gmsec/gmsec/rpc"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/gmsec/goplugins/plugin"
|
"github.com/gmsec/goplugins/plugin"
|
||||||
@@ -113,7 +113,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
proto "gmsec/rpc"
|
proto "github.com/gmsec/gmsec/rpc"
|
||||||
|
|
||||||
"github.com/gmsec/micro"
|
"github.com/gmsec/micro"
|
||||||
)
|
)
|
||||||
|
@@ -4,14 +4,15 @@ go 1.14
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/gin-gonic/gin v1.6.3
|
github.com/gin-gonic/gin v1.6.3
|
||||||
|
github.com/gmsec/gmsec v0.0.0-20200516110103-d523c5e963e4
|
||||||
github.com/gmsec/goplugins v0.0.0-20200512170621-7d971e4eeea6
|
github.com/gmsec/goplugins v0.0.0-20200512170621-7d971e4eeea6
|
||||||
github.com/gmsec/micro v0.0.0-20200512171333-e02c4bc357e0
|
github.com/gmsec/micro v0.0.0-20200512171333-e02c4bc357e0
|
||||||
github.com/golang/protobuf v1.4.1
|
github.com/golang/protobuf v1.4.1 // indirect
|
||||||
github.com/xxjwxc/ginrpc v0.0.0-20200513173523-76244eb25d46
|
github.com/xxjwxc/ginrpc v0.0.0-20200513173523-76244eb25d46
|
||||||
github.com/xxjwxc/gowp v0.0.0-20200512110932-2a0c7dbb5cb8
|
github.com/xxjwxc/gowp v0.0.0-20200512110932-2a0c7dbb5cb8
|
||||||
github.com/xxjwxc/public v0.0.0-20200512075732-ac398d0e55d0
|
github.com/xxjwxc/public v0.0.0-20200512075732-ac398d0e55d0
|
||||||
google.golang.org/grpc v1.29.1
|
google.golang.org/grpc v1.29.1
|
||||||
google.golang.org/protobuf v1.22.0
|
google.golang.org/protobuf v1.22.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200506231410-2ff61e1afc86
|
gopkg.in/yaml.v3 v3.0.0-20200506231410-2ff61e1afc86
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -30,6 +30,8 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE
|
|||||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||||
github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14=
|
github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14=
|
||||||
github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=
|
github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=
|
||||||
|
github.com/gmsec/gmsec v0.0.0-20200516110103-d523c5e963e4 h1:6d+g9n4END8hOTmWKZvYXaA7JI9vOfJY63kYnyZe7uI=
|
||||||
|
github.com/gmsec/gmsec v0.0.0-20200516110103-d523c5e963e4/go.mod h1:BXI4GvIfCnQ7Izs7tKGoe/3m36XhgstvDwBXUqWwhe4=
|
||||||
github.com/gmsec/goplugins v0.0.0-20200512170621-7d971e4eeea6 h1:iCWzc/3Knyj7AEcDujZEKUoS4FL3hDENhk7B/eMQ+VU=
|
github.com/gmsec/goplugins v0.0.0-20200512170621-7d971e4eeea6 h1:iCWzc/3Knyj7AEcDujZEKUoS4FL3hDENhk7B/eMQ+VU=
|
||||||
github.com/gmsec/goplugins v0.0.0-20200512170621-7d971e4eeea6/go.mod h1:HumjBltVYT0U23Xv6+KAGQwK2q7jRsRVVDotOxQbOC4=
|
github.com/gmsec/goplugins v0.0.0-20200512170621-7d971e4eeea6/go.mod h1:HumjBltVYT0U23Xv6+KAGQwK2q7jRsRVVDotOxQbOC4=
|
||||||
github.com/gmsec/micro v0.0.0-20200512170207-8dff54fc0fa7 h1:j1h/OE4RN3mYUoLRpcLDd+przhFVmeHEbAq18xBqCNM=
|
github.com/gmsec/micro v0.0.0-20200512170207-8dff54fc0fa7 h1:j1h/OE4RN3mYUoLRpcLDd+przhFVmeHEbAq18xBqCNM=
|
||||||
|
@@ -3,7 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
proto "gmsec/rpc"
|
proto "github.com/gmsec/gmsec/rpc"
|
||||||
|
|
||||||
"github.com/xxjwxc/public/tools"
|
"github.com/xxjwxc/public/tools"
|
||||||
|
|
||||||
|
@@ -5,7 +5,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
proto "gmsec/rpc"
|
proto "github.com/gmsec/gmsec/rpc"
|
||||||
|
|
||||||
"github.com/xxjwxc/public/dev"
|
"github.com/xxjwxc/public/dev"
|
||||||
|
|
||||||
|
@@ -13,7 +13,7 @@ import (
|
|||||||
|
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
proto "gmsec/rpc"
|
proto "github.com/gmsec/gmsec/rpc"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/gmsec/goplugins/plugin"
|
"github.com/gmsec/goplugins/plugin"
|
||||||
@@ -23,7 +23,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// TestMain test main
|
// TestMain test main
|
||||||
func TestMain(t *testing.T) {
|
func TestServer(m *testing.T) {
|
||||||
// swagger
|
// swagger
|
||||||
myswagger.SetHost("https://localhost:8080")
|
myswagger.SetHost("https://localhost:8080")
|
||||||
myswagger.SetBasePath("gmsec")
|
myswagger.SetBasePath("gmsec")
|
||||||
@@ -53,35 +53,40 @@ func TestMain(t *testing.T) {
|
|||||||
plg, _ := plugin.Run(plugin.WithMicro(service),
|
plg, _ := plugin.Run(plugin.WithMicro(service),
|
||||||
plugin.WithGin(router),
|
plugin.WithGin(router),
|
||||||
plugin.WithAddr("localhost:8080"))
|
plugin.WithAddr("localhost:8080"))
|
||||||
|
defer plg.Stop()
|
||||||
clientTest() // client test
|
// TestClient() // client test
|
||||||
|
plg.Wait()
|
||||||
time.Sleep(3 * time.Second)
|
/*time.Sleep(3 * time.Second)
|
||||||
plg.Stop()
|
plg.Stop()
|
||||||
fmt.Println("done")
|
fmt.Println("done")*/
|
||||||
}
|
}
|
||||||
|
|
||||||
func clientTest() {
|
func TestClient(m *testing.T) {
|
||||||
micro.SetClientServiceName(proto.GetHelloName(), "lp.srv.eg1") // set client group
|
micro.SetClientServiceName(proto.GetHelloName(), "lp.srv.eg1") // set client group
|
||||||
// first
|
// first
|
||||||
// service := micro.NewService(
|
micro.NewService(
|
||||||
// micro.WithName("lp.srv.eg1"),
|
micro.WithName("lp.srv.eg1"),
|
||||||
// // micro.WithRegisterTTL(time.Second*30), //指定服务注册时间
|
// micro.WithRegisterTTL(time.Second*30), //指定服务注册时间
|
||||||
// micro.WithRegisterInterval(time.Second*15), //让服务在指定时间内重新注册
|
micro.WithRegisterInterval(time.Second*15), //让服务在指定时间内重新注册
|
||||||
// //micro.WithRegistryNameing(reg),
|
//micro.WithRegistryNameing(reg),
|
||||||
// )
|
)
|
||||||
go func() {
|
wp := workpool.New(2) //设置最大线程数
|
||||||
wp := workpool.New(2) //设置最大线程数
|
for i := 0; i < 20; i++ { //开启20个请求
|
||||||
for i := 0; i < 20; i++ { //开启20个请求
|
wp.Do(func() error {
|
||||||
wp.Do(func() error {
|
say := proto.GetHelloClient()
|
||||||
run()
|
var request proto.HelloRequest
|
||||||
return nil
|
request.Name = fmt.Sprintf("%v", rand.Intn(500))
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
wp.Wait()
|
ctx := context.Background()
|
||||||
fmt.Println("clinet down")
|
resp, err := say.SayHello(ctx, &request)
|
||||||
}()
|
if err != nil {
|
||||||
|
fmt.Println("==========err:", err)
|
||||||
|
}
|
||||||
|
fmt.Println(resp)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
wp.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
func run() {
|
func run() {
|
||||||
|
Reference in New Issue
Block a user