This commit is contained in:
withchao
2023-02-24 19:16:26 +08:00
parent d7640ca864
commit c019dd5f1e
12 changed files with 239 additions and 211 deletions
+23 -2
View File
@@ -3,8 +3,11 @@ package common
import (
"OpenIM/internal/api2rpc"
"OpenIM/pkg/proto/group"
"fmt"
"github.com/gin-gonic/gin"
"reflect"
"testing"
"time"
)
type AReq struct {
@@ -15,7 +18,7 @@ type AResp struct {
func KickGroupMember(c *gin.Context) {
// 默认 全部自动
api2rpc.NewRpc(api2rpc.NewGin[AReq, AResp](c), group.NewGroupClient, group.GroupClient.KickGroupMember).Name("group").Call()
api2rpc.NewRpc(api2rpc.NewGin[AReq, AResp](c), group.NewGroupClient, group.GroupClient.KickGroupMember).Call()
//// 可以自定义编辑请求和响应
//a := NewRpc(NewGin[apistruct.KickGroupMemberReq, apistruct.KickGroupMemberResp](c), group.NewGroupClient, group.GroupClient.KickGroupMember)
@@ -26,6 +29,24 @@ func KickGroupMember(c *gin.Context) {
//}).Name("group").Call()
}
//func getInterfaceName(handler PackerHandler) string {
// funcInfo := runtime.FuncForPC(reflect.ValueOf(handler).Pointer())
// name := funcInfo.Name()
// names := strings.Split(name, "/")
// if len(names) == 0 {
// return ""
// }
//
// return names[len(names)-1]
//}
func TestName(t *testing.T) {
KickGroupMember(nil)
n := 100000000
start := time.Now().UnixNano()
for i := 0; i < n; i++ {
var val group.GroupClient
reflect.TypeOf(&val).Elem().String()
}
end := time.Now().UnixNano()
fmt.Println(time.Duration(end-start) / time.Duration(n))
}