commit
45421de2ca
@ -1,49 +1,27 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/a2r"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/a2r"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/auth"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/auth"
|
||||||
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"google.golang.org/grpc"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewAuth(discov discoveryregistry.SvcDiscoveryRegistry) *Auth {
|
type AuthApi rpcclient.Auth
|
||||||
// conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImAuthName)
|
|
||||||
// if err != nil {
|
|
||||||
// panic(err)
|
|
||||||
// }
|
|
||||||
return &Auth{discov: discov}
|
|
||||||
}
|
|
||||||
|
|
||||||
type Auth struct {
|
|
||||||
conn *grpc.ClientConn
|
|
||||||
discov discoveryregistry.SvcDiscoveryRegistry
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Auth) client(ctx context.Context) (auth.AuthClient, error) {
|
|
||||||
c, err := o.discov.GetConn(ctx, config.Config.RpcRegisterName.OpenImAuthName)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return auth.NewAuthClient(c), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Auth) UserRegister(c *gin.Context) {
|
func NewAuthApi(discov discoveryregistry.SvcDiscoveryRegistry) AuthApi {
|
||||||
//a2r.Call(auth.AuthClient.UserRegister, o.userClient, c) // todo
|
return AuthApi(*rpcclient.NewAuth(discov))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Auth) UserToken(c *gin.Context) {
|
func (o *AuthApi) UserToken(c *gin.Context) {
|
||||||
a2r.Call(auth.AuthClient.UserToken, o.client, c)
|
a2r.Call(auth.AuthClient.UserToken, o.Client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Auth) ParseToken(c *gin.Context) {
|
func (o *AuthApi) ParseToken(c *gin.Context) {
|
||||||
a2r.Call(auth.AuthClient.ParseToken, o.client, c)
|
a2r.Call(auth.AuthClient.ParseToken, o.Client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Auth) ForceLogout(c *gin.Context) {
|
func (o *AuthApi) ForceLogout(c *gin.Context) {
|
||||||
a2r.Call(auth.AuthClient.ForceLogout, o.client, c)
|
a2r.Call(auth.AuthClient.ForceLogout, o.Client, c)
|
||||||
}
|
}
|
||||||
|
@ -1,67 +1,49 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/a2r"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/a2r"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation"
|
||||||
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"google.golang.org/grpc"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewConversation(discov discoveryregistry.SvcDiscoveryRegistry) *Conversation {
|
type ConversationApi rpcclient.Conversation
|
||||||
// conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImConversationName)
|
|
||||||
// if err != nil {
|
|
||||||
// panic(err)
|
|
||||||
// }
|
|
||||||
return &Conversation{discov: discov}
|
|
||||||
}
|
|
||||||
|
|
||||||
type Conversation struct {
|
|
||||||
conn *grpc.ClientConn
|
|
||||||
discov discoveryregistry.SvcDiscoveryRegistry
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Conversation) client(ctx context.Context) (conversation.ConversationClient, error) {
|
func NewConversationApi(discov discoveryregistry.SvcDiscoveryRegistry) ConversationApi {
|
||||||
c, err := o.discov.GetConn(ctx, config.Config.RpcRegisterName.OpenImConversationName)
|
return ConversationApi(*rpcclient.NewConversation(discov))
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return conversation.NewConversationClient(c), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Conversation) GetAllConversations(c *gin.Context) {
|
func (o *ConversationApi) GetAllConversations(c *gin.Context) {
|
||||||
a2r.Call(conversation.ConversationClient.GetAllConversations, o.client, c)
|
a2r.Call(conversation.ConversationClient.GetAllConversations, o.Client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Conversation) GetConversation(c *gin.Context) {
|
func (o *ConversationApi) GetConversation(c *gin.Context) {
|
||||||
a2r.Call(conversation.ConversationClient.GetConversation, o.client, c)
|
a2r.Call(conversation.ConversationClient.GetConversation, o.Client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Conversation) GetConversations(c *gin.Context) {
|
func (o *ConversationApi) GetConversations(c *gin.Context) {
|
||||||
a2r.Call(conversation.ConversationClient.GetConversations, o.client, c)
|
a2r.Call(conversation.ConversationClient.GetConversations, o.Client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// deprecated
|
// deprecated
|
||||||
func (o *Conversation) SetConversation(c *gin.Context) {
|
func (o *ConversationApi) SetConversation(c *gin.Context) {
|
||||||
a2r.Call(conversation.ConversationClient.SetConversation, o.client, c)
|
a2r.Call(conversation.ConversationClient.SetConversation, o.Client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// deprecated
|
// deprecated
|
||||||
func (o *Conversation) BatchSetConversations(c *gin.Context) {
|
func (o *ConversationApi) BatchSetConversations(c *gin.Context) {
|
||||||
a2r.Call(conversation.ConversationClient.BatchSetConversations, o.client, c)
|
a2r.Call(conversation.ConversationClient.BatchSetConversations, o.Client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Conversation) SetRecvMsgOpt(c *gin.Context) {
|
func (o *ConversationApi) SetRecvMsgOpt(c *gin.Context) {
|
||||||
a2r.Call(conversation.ConversationClient.SetRecvMsgOpt, o.client, c)
|
a2r.Call(conversation.ConversationClient.SetRecvMsgOpt, o.Client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Conversation) ModifyConversationField(c *gin.Context) {
|
func (o *ConversationApi) ModifyConversationField(c *gin.Context) {
|
||||||
a2r.Call(conversation.ConversationClient.ModifyConversationField, o.client, c)
|
a2r.Call(conversation.ConversationClient.ModifyConversationField, o.Client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Conversation) SetConversations(c *gin.Context) {
|
func (o *ConversationApi) SetConversations(c *gin.Context) {
|
||||||
a2r.Call(conversation.ConversationClient.SetConversations, o.client, c)
|
a2r.Call(conversation.ConversationClient.SetConversations, o.Client, c)
|
||||||
}
|
}
|
||||||
|
@ -1,82 +1,64 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/a2r"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/a2r"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/friend"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/friend"
|
||||||
"google.golang.org/grpc"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewFriend(discov discoveryregistry.SvcDiscoveryRegistry) *Friend {
|
type FriendApi rpcclient.Friend
|
||||||
// conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImFriendName)
|
|
||||||
// if err != nil {
|
|
||||||
// panic(err)
|
|
||||||
// }
|
|
||||||
return &Friend{discov: discov}
|
|
||||||
}
|
|
||||||
|
|
||||||
type Friend struct {
|
|
||||||
conn *grpc.ClientConn
|
|
||||||
discov discoveryregistry.SvcDiscoveryRegistry
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *Friend) client(ctx context.Context) (friend.FriendClient, error) {
|
func NewFriendApi(discov discoveryregistry.SvcDiscoveryRegistry) FriendApi {
|
||||||
c, err := o.discov.GetConn(ctx, config.Config.RpcRegisterName.OpenImFriendName)
|
return FriendApi(*rpcclient.NewFriend(discov))
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return friend.NewFriendClient(c), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Friend) ApplyToAddFriend(c *gin.Context) {
|
func (o *FriendApi) ApplyToAddFriend(c *gin.Context) {
|
||||||
a2r.Call(friend.FriendClient.ApplyToAddFriend, o.client, c)
|
a2r.Call(friend.FriendClient.ApplyToAddFriend, o.Client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Friend) RespondFriendApply(c *gin.Context) {
|
func (o *FriendApi) RespondFriendApply(c *gin.Context) {
|
||||||
a2r.Call(friend.FriendClient.RespondFriendApply, o.client, c)
|
a2r.Call(friend.FriendClient.RespondFriendApply, o.Client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Friend) DeleteFriend(c *gin.Context) {
|
func (o *FriendApi) DeleteFriend(c *gin.Context) {
|
||||||
a2r.Call(friend.FriendClient.DeleteFriend, o.client, c)
|
a2r.Call(friend.FriendClient.DeleteFriend, o.Client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Friend) GetFriendApplyList(c *gin.Context) {
|
func (o *FriendApi) GetFriendApplyList(c *gin.Context) {
|
||||||
a2r.Call(friend.FriendClient.GetPaginationFriendsApplyTo, o.client, c)
|
a2r.Call(friend.FriendClient.GetPaginationFriendsApplyTo, o.Client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Friend) GetSelfApplyList(c *gin.Context) {
|
func (o *FriendApi) GetSelfApplyList(c *gin.Context) {
|
||||||
a2r.Call(friend.FriendClient.GetPaginationFriendsApplyFrom, o.client, c)
|
a2r.Call(friend.FriendClient.GetPaginationFriendsApplyFrom, o.Client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Friend) GetFriendList(c *gin.Context) {
|
func (o *FriendApi) GetFriendList(c *gin.Context) {
|
||||||
a2r.Call(friend.FriendClient.GetPaginationFriends, o.client, c)
|
a2r.Call(friend.FriendClient.GetPaginationFriends, o.Client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Friend) SetFriendRemark(c *gin.Context) {
|
func (o *FriendApi) SetFriendRemark(c *gin.Context) {
|
||||||
a2r.Call(friend.FriendClient.SetFriendRemark, o.client, c)
|
a2r.Call(friend.FriendClient.SetFriendRemark, o.Client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Friend) AddBlack(c *gin.Context) {
|
func (o *FriendApi) AddBlack(c *gin.Context) {
|
||||||
a2r.Call(friend.FriendClient.AddBlack, o.client, c)
|
a2r.Call(friend.FriendClient.AddBlack, o.Client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Friend) GetPaginationBlacks(c *gin.Context) {
|
func (o *FriendApi) GetPaginationBlacks(c *gin.Context) {
|
||||||
a2r.Call(friend.FriendClient.GetPaginationBlacks, o.client, c)
|
a2r.Call(friend.FriendClient.GetPaginationBlacks, o.Client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Friend) RemoveBlack(c *gin.Context) {
|
func (o *FriendApi) RemoveBlack(c *gin.Context) {
|
||||||
a2r.Call(friend.FriendClient.RemoveBlack, o.client, c)
|
a2r.Call(friend.FriendClient.RemoveBlack, o.Client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Friend) ImportFriends(c *gin.Context) {
|
func (o *FriendApi) ImportFriends(c *gin.Context) {
|
||||||
a2r.Call(friend.FriendClient.ImportFriends, o.client, c)
|
a2r.Call(friend.FriendClient.ImportFriends, o.Client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Friend) IsFriend(c *gin.Context) {
|
func (o *FriendApi) IsFriend(c *gin.Context) {
|
||||||
a2r.Call(friend.FriendClient.IsFriend, o.client, c)
|
a2r.Call(friend.FriendClient.IsFriend, o.Client, c)
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,19 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/a2r"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/a2r"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/user"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/user"
|
||||||
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewStatistics(discov discoveryregistry.SvcDiscoveryRegistry) *Statistics {
|
type StatisticsApi rpcclient.User
|
||||||
return &Statistics{discov: discov}
|
|
||||||
}
|
|
||||||
|
|
||||||
type Statistics struct {
|
|
||||||
discov discoveryregistry.SvcDiscoveryRegistry
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Statistics) userClient(ctx context.Context) (user.UserClient, error) {
|
func NewStatisticsApi(discov discoveryregistry.SvcDiscoveryRegistry) StatisticsApi {
|
||||||
conn, err := s.discov.GetConn(ctx, config.Config.RpcRegisterName.OpenImUserName)
|
return StatisticsApi(*rpcclient.NewUser(discov))
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return user.NewUserClient(conn), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Statistics) UserRegister(c *gin.Context) {
|
func (s *StatisticsApi) UserRegister(c *gin.Context) {
|
||||||
a2r.Call(user.UserClient.UserRegisterCount, s.userClient, c)
|
a2r.Call(user.UserClient.UserRegisterCount, s.Client, c)
|
||||||
}
|
}
|
||||||
|
@ -1,51 +0,0 @@
|
|||||||
package discoveryregistry
|
|
||||||
|
|
||||||
// type DnsDiscoveryRegistry struct {
|
|
||||||
// opts []grpc.DialOption
|
|
||||||
// namespace string
|
|
||||||
// clientset *kubernetes.Clientset
|
|
||||||
// }
|
|
||||||
|
|
||||||
// func NewDnsDiscoveryRegistry(namespace string, opts []grpc.DialOption) (*DnsDiscoveryRegistry, error) {
|
|
||||||
// config, err := rest.InClusterConfig()
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
// clientset, err := kubernetes.NewForConfig(config)
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
// return &DnsDiscoveryRegistry{
|
|
||||||
// clientset: clientset,
|
|
||||||
// namespace: namespace,
|
|
||||||
// opts: opts,
|
|
||||||
// }, nil
|
|
||||||
// }
|
|
||||||
|
|
||||||
// func (d DnsDiscoveryRegistry) GetConns(ctx context.Context, serviceName string, opts ...grpc.DialOption) ([]*grpc.ClientConn, error) {
|
|
||||||
// endpoints, err := d.clientset.CoreV1().Endpoints(d.namespace).Get(context.TODO(), serviceName, metav1.GetOptions{})
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
// var conns []*grpc.ClientConn
|
|
||||||
// for _, subset := range endpoints.Subsets {
|
|
||||||
// for _, address := range subset.Addresses {
|
|
||||||
// for _, port := range subset.Ports {
|
|
||||||
// conn, err := grpc.DialContext(ctx, net.JoinHostPort(address.IP, string(port.Port)), append(d.opts, opts...)...)
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
// conns = append(conns, conn)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return conns, nil
|
|
||||||
// }
|
|
||||||
|
|
||||||
// func (d DnsDiscoveryRegistry) GetConn(ctx context.Context, serviceName string, opts ...grpc.DialOption) (*grpc.ClientConn, error) {
|
|
||||||
// return grpc.DialContext(ctx, fmt.Sprintf("%s.%s.svc.cluster.local", serviceName, d.namespace), append(d.opts, opts...)...)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// func (d *DnsDiscoveryRegistry) AddOption(opts ...grpc.DialOption) {
|
|
||||||
// d.opts = append(d.opts, opts...)
|
|
||||||
// }
|
|
@ -0,0 +1,25 @@
|
|||||||
|
package rpcclient
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||||
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||||
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/auth"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewAuth(discov discoveryregistry.SvcDiscoveryRegistry) *Auth {
|
||||||
|
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImAuthName)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
client := auth.NewAuthClient(conn)
|
||||||
|
return &Auth{discov: discov, conn: conn, Client: client}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Auth struct {
|
||||||
|
conn *grpc.ClientConn
|
||||||
|
Client auth.AuthClient
|
||||||
|
discov discoveryregistry.SvcDiscoveryRegistry
|
||||||
|
}
|
@ -1,31 +0,0 @@
|
|||||||
package rpcclient
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
)
|
|
||||||
|
|
||||||
type MetaClient struct {
|
|
||||||
// contains filtered or unexported fields
|
|
||||||
client discoveryregistry.SvcDiscoveryRegistry
|
|
||||||
rpcRegisterName string
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewMetaClient(client discoveryregistry.SvcDiscoveryRegistry, rpcRegisterName string, opts ...MetaClientOptions) *MetaClient {
|
|
||||||
c := &MetaClient{
|
|
||||||
client: client,
|
|
||||||
rpcRegisterName: rpcRegisterName,
|
|
||||||
}
|
|
||||||
for _, opt := range opts {
|
|
||||||
opt(c)
|
|
||||||
}
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
|
|
||||||
type MetaClientOptions func(*MetaClient)
|
|
||||||
|
|
||||||
func (m *MetaClient) getConn(ctx context.Context) (*grpc.ClientConn, error) {
|
|
||||||
return m.client.GetConn(ctx, m.rpcRegisterName)
|
|
||||||
}
|
|
@ -0,0 +1,25 @@
|
|||||||
|
package rpcclient
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||||
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||||
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/third"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Third struct {
|
||||||
|
conn *grpc.ClientConn
|
||||||
|
Client third.ThirdClient
|
||||||
|
discov discoveryregistry.SvcDiscoveryRegistry
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewThird(discov discoveryregistry.SvcDiscoveryRegistry) *Third {
|
||||||
|
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImThirdName)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
client := third.NewThirdClient(conn)
|
||||||
|
return &Third{discov: discov, Client: client, conn: conn}
|
||||||
|
}
|
Loading…
Reference in new issue