grpc conn

This commit is contained in:
wangchuxiao
2023-05-29 18:04:22 +08:00
parent 232abf46a4
commit 290d7cffde
2 changed files with 17 additions and 15 deletions
+8 -7
View File
@@ -8,22 +8,23 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/auth"
"github.com/gin-gonic/gin"
"google.golang.org/grpc"
)
func NewAuth(c discoveryregistry.SvcDiscoveryRegistry) *Auth {
return &Auth{c: c}
conn, err := c.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImAuthName)
if err != nil {
panic(err)
}
return &Auth{conn: conn}
}
type Auth struct {
c discoveryregistry.SvcDiscoveryRegistry
conn *grpc.ClientConn
}
func (o *Auth) client(ctx context.Context) (auth.AuthClient, error) {
conn, err := o.c.GetConn(ctx, config.Config.RpcRegisterName.OpenImAuthName)
if err != nil {
return nil, err
}
return auth.NewAuthClient(conn), nil
return auth.NewAuthClient(o.conn), nil
}
func (o *Auth) UserRegister(c *gin.Context) {