mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-10-25 20:52:11 +08:00
feat: optmise to get etcd connection
This commit is contained in:
parent
cdeca794ab
commit
cd76ccb06d
@ -7,7 +7,6 @@ import (
|
||||
pbAuth "Open_IM/pkg/proto/auth"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -60,7 +59,7 @@ func newUserRegisterReq(params *paramsUserRegister) *pbAuth.UserRegisterReq {
|
||||
// @Router /auth/user_register [post]
|
||||
func UserRegister(c *gin.Context) {
|
||||
log.Info("", "", "api user_register init ....")
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName)
|
||||
etcdConn := getcdv3.GetAuthConn()
|
||||
client := pbAuth.NewAuthClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
|
||||
@ -7,7 +7,6 @@ import (
|
||||
pbAuth "Open_IM/pkg/proto/auth"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -40,7 +39,7 @@ func newUserTokenReq(params *paramsUserToken) *pbAuth.UserTokenReq {
|
||||
// @Router /auth/user_token [post]
|
||||
func UserToken(c *gin.Context) {
|
||||
log.Info("", "", "api user_token init ....")
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName)
|
||||
etcdConn := getcdv3.GetAuthConn()
|
||||
client := pbAuth.NewAuthClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
package apiChat
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbMsg "Open_IM/pkg/proto/chat"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -60,7 +58,7 @@ func UserGetSeq(c *gin.Context) {
|
||||
pbData := pbMsg.GetMaxAndMinSeqReq{}
|
||||
pbData.UserID = params.SendID
|
||||
pbData.OperationID = params.OperationID
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
grpcConn := getcdv3.GetOfflineMessageConn()
|
||||
|
||||
if grpcConn == nil {
|
||||
log.ErrorByKv("get grpcConn err", pbData.OperationID, "args", params)
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
package apiChat
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -53,7 +51,7 @@ func UserPullMsg(c *gin.Context) {
|
||||
pbData.OperationID = params.OperationID
|
||||
pbData.SeqBegin = *params.Data.SeqBegin
|
||||
pbData.SeqEnd = *params.Data.SeqEnd
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
grpcConn := getcdv3.GetOfflineMessageConn()
|
||||
msgClient := pbChat.NewChatClient(grpcConn)
|
||||
reply, err := msgClient.PullMessage(context.Background(), &pbData)
|
||||
if err != nil {
|
||||
@ -122,7 +120,7 @@ func UserPullMsgBySeqList(c *gin.Context) {
|
||||
pbData.OperationID = params.OperationID
|
||||
pbData.SeqList = params.SeqList
|
||||
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
grpcConn := getcdv3.GetOfflineMessageConn()
|
||||
msgClient := pbChat.NewChatClient(grpcConn)
|
||||
reply, err := msgClient.PullMessageBySeqList(context.Background(), &pbData)
|
||||
if err != nil {
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package apiChat
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
"Open_IM/pkg/utils"
|
||||
@ -9,7 +8,6 @@ import (
|
||||
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -92,7 +90,7 @@ func UserSendMsg(c *gin.Context) {
|
||||
pbData := newUserSendMsgReq(token, ¶ms)
|
||||
log.Info("", "", "api UserSendMsg call start..., [data: %s]", pbData.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
etcdConn := getcdv3.GetOfflineMessageConn()
|
||||
client := pbChat.NewChatClient(etcdConn)
|
||||
|
||||
log.Info("", "", "api UserSendMsg call, api call rpc...")
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -27,7 +25,7 @@ import (
|
||||
func AddBlacklist(c *gin.Context) {
|
||||
log.Info("", "", "api add blacklist init ....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
etcdConn := getcdv3.GetFriendConn()
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -48,7 +46,7 @@ type paramsAddFriend struct {
|
||||
func ImportFriend(c *gin.Context) {
|
||||
log.Info("", "", "ImportFriend init ....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
etcdConn := getcdv3.GetFriendConn()
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
|
||||
params := paramsImportFriendReq{}
|
||||
@ -89,7 +87,7 @@ func ImportFriend(c *gin.Context) {
|
||||
func AddFriend(c *gin.Context) {
|
||||
log.Info("", "", "api add friend init ....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
etcdConn := getcdv3.GetFriendConn()
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
|
||||
params := paramsAddFriend{}
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -35,7 +33,7 @@ type paramsAddFriendResponse struct {
|
||||
func AddFriendResponse(c *gin.Context) {
|
||||
log.Info("", "", fmt.Sprintf("api add friend response init ...."))
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
etcdConn := getcdv3.GetFriendConn()
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -34,7 +32,7 @@ type paramsDeleteFriend struct {
|
||||
func DeleteFriend(c *gin.Context) {
|
||||
log.Info("", "", fmt.Sprintf("api delete_friend init ...."))
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
etcdConn := getcdv3.GetFriendConn()
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -45,7 +43,7 @@ type blackListUserInfo struct {
|
||||
func GetBlacklist(c *gin.Context) {
|
||||
log.Info("", "", "api get blacklist init ....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
etcdConn := getcdv3.GetFriendConn()
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -47,7 +45,7 @@ type UserInfo struct {
|
||||
func GetFriendApplyList(c *gin.Context) {
|
||||
log.Info("", "", "api get_friend_apply_list init ....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
etcdConn := getcdv3.GetFriendConn()
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
@ -109,7 +107,7 @@ func GetFriendApplyList(c *gin.Context) {
|
||||
func GetSelfApplyList(c *gin.Context) {
|
||||
log.Info("", "", "api get self friend apply list init ....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
etcdConn := getcdv3.GetFriendConn()
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -47,7 +45,7 @@ type friendInfo struct {
|
||||
func GetFriendList(c *gin.Context) {
|
||||
log.Info("", "", fmt.Sprintf("api get_friendlist init ...."))
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
etcdConn := getcdv3.GetFriendConn()
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -46,7 +44,7 @@ type resultFriendInfo struct {
|
||||
// @Router /friend/get_friends_info [post]
|
||||
func GetFriendsInfo(c *gin.Context) {
|
||||
log.Info("", "", fmt.Sprintf("api search friend init ...."))
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
etcdConn := getcdv3.GetFriendConn()
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -33,7 +31,7 @@ type paramsIsFriend struct {
|
||||
func IsFriend(c *gin.Context) {
|
||||
log.Info("", "", "api is friend init....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
etcdConn := getcdv3.GetFriendConn()
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -33,7 +31,7 @@ type paramsRemoveBlackList struct {
|
||||
func RemoveBlacklist(c *gin.Context) {
|
||||
log.Info("", "", "api remove_blacklist init ....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
etcdConn := getcdv3.GetFriendConn()
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -34,7 +32,7 @@ type paramsSetFriendComment struct {
|
||||
func SetFriendComment(c *gin.Context) {
|
||||
log.Info("", "", "api set friend comment init ....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
etcdConn := getcdv3.GetFriendConn()
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/pkg/proto/group"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -50,7 +48,7 @@ type paramsCreateGroupStruct struct {
|
||||
func CreateGroup(c *gin.Context) {
|
||||
log.Info("", "", "api create group init ....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
etcdConn := getcdv3.GetGroupConn()
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/pkg/proto/group"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -65,7 +63,7 @@ type resultGroupApplication struct {
|
||||
// @Router /group/get_group_applicationList [post]
|
||||
func GetGroupApplicationList(c *gin.Context) {
|
||||
log.Info("", "", "api GetGroupApplicationList init ....")
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
etcdConn := getcdv3.GetGroupConn()
|
||||
client := group.NewGroupClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/pkg/proto/group"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -32,7 +30,7 @@ type paramsGetGroupInfo struct {
|
||||
func GetGroupsInfo(c *gin.Context) {
|
||||
log.Info("", "", "api get groups info init ....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
etcdConn := getcdv3.GetGroupConn()
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
|
||||
@ -62,7 +62,7 @@ type KickGroupMemberReq struct {
|
||||
func KickGroupMember(c *gin.Context) {
|
||||
log.Info("", "", "KickGroupMember start....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
etcdConn := getcdv3.GetGroupConn()
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
|
||||
params := KickGroupMemberReq{}
|
||||
@ -134,7 +134,7 @@ type GetGroupMembersInfoResp struct {
|
||||
func GetGroupMembersInfo(c *gin.Context) {
|
||||
log.Info("", "", "GetGroupMembersInfo start....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
etcdConn := getcdv3.GetGroupConn()
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
|
||||
params := GetGroupMembersInfoReq{}
|
||||
@ -212,7 +212,7 @@ type MemberResult struct {
|
||||
func GetGroupMemberList(c *gin.Context) {
|
||||
log.Info("", "", "GetGroupMemberList start....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
etcdConn := getcdv3.GetGroupConn()
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
|
||||
params := GetGroupMemberListReq{}
|
||||
@ -275,7 +275,7 @@ func GetGroupMemberList(c *gin.Context) {
|
||||
func GetGroupAllMember(c *gin.Context) {
|
||||
log.Info("", "", "GetGroupAllMember start....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
etcdConn := getcdv3.GetGroupConn()
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
|
||||
params := getGroupAllMemberReq{}
|
||||
@ -345,7 +345,7 @@ type groupResult struct {
|
||||
func GetJoinedGroupList(c *gin.Context) {
|
||||
log.Info("", "", "GetJoinedGroupList start....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
etcdConn := getcdv3.GetGroupConn()
|
||||
fmt.Println("config: ", etcdConn, config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
|
||||
@ -411,7 +411,7 @@ type Id2Result struct {
|
||||
// @Router /group/invite_user_to_group [post]
|
||||
func InviteUserToGroup(c *gin.Context) {
|
||||
log.Info("", "", "InviteUserToGroup start....")
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
etcdConn := getcdv3.GetGroupConn()
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
|
||||
params := InviteUserToGroupReq{}
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/pkg/proto/group"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -65,7 +63,7 @@ func newGroupApplicationResponse(params *paramsGroupApplicationResponse) *group.
|
||||
// @Router /group/group_application_response [post]
|
||||
func ApplicationGroupResponse(c *gin.Context) {
|
||||
log.Info("", "", "api GroupApplicationResponse init ....")
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
etcdConn := getcdv3.GetGroupConn()
|
||||
client := group.NewGroupClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/pkg/proto/group"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -34,7 +32,7 @@ type paramsJoinGroup struct {
|
||||
func JoinGroup(c *gin.Context) {
|
||||
log.Info("", "", "api join group init....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
etcdConn := getcdv3.GetGroupConn()
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/pkg/proto/group"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -33,7 +31,7 @@ type paramsQuitGroup struct {
|
||||
func QuitGroup(c *gin.Context) {
|
||||
log.Info("", "", "api quit group init ....")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
etcdConn := getcdv3.GetGroupConn()
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pb "Open_IM/pkg/proto/group"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -37,7 +35,7 @@ type paramsSetGroupInfo struct {
|
||||
func SetGroupInfo(c *gin.Context) {
|
||||
log.Info("", "", "api set group info init...")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
etcdConn := getcdv3.GetGroupConn()
|
||||
client := pb.NewGroupClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/pkg/proto/group"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -43,7 +41,7 @@ func newTransferGroupOwnerReq(params *paramsTransferGroupOwner) *group.TransferG
|
||||
// @Router /group/transfer_group [post]
|
||||
func TransferGroupOwner(c *gin.Context) {
|
||||
log.Info("", "", "api TransferGroupOwner init ....")
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
etcdConn := getcdv3.GetGroupConn()
|
||||
client := group.NewGroupClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
|
||||
@ -15,7 +15,6 @@ import (
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-playground/validator/v10"
|
||||
@ -140,7 +139,7 @@ func ManagementSendMsg(c *gin.Context) {
|
||||
pbData := newUserSendMsgReq(¶ms)
|
||||
log.Info("", "", "api ManagementSendMsg call start..., [data: %s]", pbData.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
etcdConn := getcdv3.GetOfflineMessageConn()
|
||||
client := pbChat.NewChatClient(etcdConn)
|
||||
|
||||
log.Info("", "", "api ManagementSendMsg call, api call rpc...")
|
||||
|
||||
@ -7,13 +7,11 @@
|
||||
package manage
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbUser "Open_IM/pkg/proto/user"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -62,7 +60,7 @@ func DeleteUser(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.InfoByKv("DeleteUser req come here", params.OperationID, "DeleteUidList", params.DeleteUidList)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
etcdConn := getcdv3.GetUserConn()
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
@ -100,7 +98,7 @@ func GetAllUsersUid(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.InfoByKv("GetAllUsersUid req come here", params.OperationID)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
etcdConn := getcdv3.GetUserConn()
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbUser "Open_IM/pkg/proto/user"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -50,7 +48,7 @@ type queryUserInfoParam struct {
|
||||
func GetUserInfo(c *gin.Context) {
|
||||
log.InfoByKv("api get userinfo init...", "")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
etcdConn := getcdv3.GetUserConn()
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbUser "Open_IM/pkg/proto/user"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -38,7 +36,7 @@ type updateUserInfoParam struct {
|
||||
func UpdateUserInfo(c *gin.Context) {
|
||||
log.InfoByKv("api update userinfo init...", "")
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
etcdConn := getcdv3.GetUserConn()
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
//defer etcdConn.Close()
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package gate
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
@ -12,10 +11,10 @@ import (
|
||||
"context"
|
||||
"encoding/gob"
|
||||
"encoding/json"
|
||||
"runtime"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/gorilla/websocket"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
|
||||
@ -69,7 +68,7 @@ func (ws *WServer) getSeqReq(conn *UserConn, m *Req) {
|
||||
nReply := new(pbChat.GetMaxAndMinSeqResp)
|
||||
pbData.UserID = m.SendID
|
||||
pbData.OperationID = m.OperationID
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
grpcConn := getcdv3.GetOfflineMessageConn()
|
||||
if grpcConn == nil {
|
||||
log.ErrorByKv("get grpcConn err", pbData.OperationID, "args", m)
|
||||
}
|
||||
@ -110,7 +109,7 @@ func (ws *WServer) pullMsgReq(conn *UserConn, m *Req) {
|
||||
pbData.OperationID = m.OperationID
|
||||
pbData.SeqBegin = data.(SeqData).SeqBegin
|
||||
pbData.SeqEnd = data.(SeqData).SeqEnd
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
grpcConn := getcdv3.GetOfflineMessageConn()
|
||||
msgClient := pbChat.NewChatClient(grpcConn)
|
||||
reply, err := msgClient.PullMessage(context.Background(), &pbData)
|
||||
if err != nil {
|
||||
@ -176,7 +175,7 @@ func (ws *WServer) pullMsgBySeqListReq(conn *UserConn, m *Req) {
|
||||
pbData.SeqList = data.(open_im_sdk.PullMessageBySeqListReq).SeqList
|
||||
pbData.UserID = m.SendID
|
||||
pbData.OperationID = m.OperationID
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
grpcConn := getcdv3.GetOfflineMessageConn()
|
||||
msgClient := pbChat.NewChatClient(grpcConn)
|
||||
reply, err := msgClient.PullMessageBySeqList(context.Background(), &pbData)
|
||||
if err != nil {
|
||||
@ -219,7 +218,7 @@ func (ws *WServer) sendMsgReq(conn *UserConn, m *Req, sendTime int64) {
|
||||
SendTime: sendTime,
|
||||
}
|
||||
log.NewInfo(m.OperationID, "Ws call success to sendMsgReq middle", m.ReqIdentifier, m.SendID, m.MsgIncr, data)
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
etcdConn := getcdv3.GetOfflineMessageConn()
|
||||
client := pbChat.NewChatClient(etcdConn)
|
||||
reply, err := client.UserSendMsg(context.Background(), &pbData)
|
||||
if err != nil {
|
||||
|
||||
@ -10,9 +10,10 @@ import (
|
||||
pbPush "Open_IM/pkg/proto/push"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/Shopify/sarama"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type fcb func(msg []byte, msgKey string)
|
||||
@ -138,7 +139,7 @@ func sendMessageToPush(message *pbMsg.MsgSvrToPushSvrChatMsg) {
|
||||
msg.SendTime = message.SendTime
|
||||
msg.MsgID = message.MsgID
|
||||
msg.OfflineInfo = message.OfflineInfo
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImPushName)
|
||||
grpcConn := getcdv3.GetPushConn()
|
||||
if grpcConn == nil {
|
||||
log.ErrorByKv("rpc dial failed", msg.OperationID, "push data", msg.String())
|
||||
pid, offset, err := producer.SendMessage(message)
|
||||
|
||||
@ -19,7 +19,6 @@ import (
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type OpenIMContent struct {
|
||||
@ -40,7 +39,7 @@ func MsgToUser(sendPbData *pbRelay.MsgToUserReq, OfflineInfo, Options string) {
|
||||
//isSenderSync := utils.GetSwitchFromOptions(MOptions, "senderSync")
|
||||
isOfflinePush := utils.GetSwitchFromOptions(MOptions, "offlinePush")
|
||||
log.InfoByKv("Get chat from msg_transfer And push chat", sendPbData.OperationID, "PushData", sendPbData)
|
||||
grpcCons := getcdv3.GetConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOnlineMessageRelayName)
|
||||
grpcCons := getcdv3.GetOnlineMessageConn()
|
||||
//Online push message
|
||||
log.InfoByKv("test", sendPbData.OperationID, "len grpc", len(grpcCons), "data", sendPbData)
|
||||
for _, v := range grpcCons {
|
||||
@ -120,7 +119,7 @@ func SendMsgByWS(m *pbChat.WSToMsgSvrChatMsg) {
|
||||
sendMsgToKafka(m, m.SendID, "msgKey--sendID")
|
||||
sendMsgToKafka(m, m.RecvID, "msgKey--recvID")
|
||||
case constant.GroupChatType:
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
etcdConn := getcdv3.GetGroupConn()
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
req := &pbGroup.GetGroupAllMemberReq{
|
||||
GroupID: m.RecvID,
|
||||
|
||||
@ -16,7 +16,6 @@ import (
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -103,7 +102,7 @@ func (rpc *rpcChat) UserSendMsg(_ context.Context, pb *pbChat.UserSendMsgReq) (*
|
||||
}
|
||||
return returnMsg(&replay, pb, 0, "", serverMsgID, pbData.SendTime)
|
||||
case constant.GroupChatType:
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
etcdConn := getcdv3.GetGroupConn()
|
||||
client := pbGroup.NewGroupClient(etcdConn)
|
||||
req := &pbGroup.GetGroupAllMemberReq{
|
||||
GroupID: pbData.RecvID,
|
||||
|
||||
@ -1,15 +1,13 @@
|
||||
package internal_service
|
||||
|
||||
import (
|
||||
pbUser "Open_IM/pkg/proto/user"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbUser "Open_IM/pkg/proto/user"
|
||||
"context"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func GetUserInfoClient(req *pbUser.GetUserInfoReq) (*pbUser.GetUserInfoResp, error) {
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
etcdConn := getcdv3.GetUserConn()
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
RpcResp, err := client.GetUserInfo(context.Background(), req)
|
||||
return RpcResp, err
|
||||
|
||||
@ -12,7 +12,6 @@ import (
|
||||
pbUser "Open_IM/pkg/proto/user"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbUser.UpdateUserInfoReq) (*pbUser.CommonResp, error) {
|
||||
@ -36,7 +35,7 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbUser.UpdateUserI
|
||||
log.Error(req.Token, req.OperationID, "update user some attribute failed,err=%s", err.Error())
|
||||
return &pbUser.CommonResp{ErrorCode: config.ErrModifyUserInfo.ErrCode, ErrorMsg: config.ErrModifyUserInfo.ErrMsg}, nil
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
etcdConn := getcdv3.GetFriendConn()
|
||||
client := pbFriend.NewFriendClient(etcdConn)
|
||||
newReq := &pbFriend.GetFriendListReq{
|
||||
OperationID: req.OperationID,
|
||||
|
||||
@ -1,17 +1,21 @@
|
||||
package getcdv3
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"go.etcd.io/etcd/clientv3"
|
||||
"go.etcd.io/etcd/mvcc/mvccpb"
|
||||
|
||||
//"google.golang.org/genproto/googleapis/ads/googleads/v1/services"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/balancer/roundrobin"
|
||||
"google.golang.org/grpc/resolver"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/balancer/roundrobin"
|
||||
"google.golang.org/grpc/resolver"
|
||||
)
|
||||
|
||||
type Resolver struct {
|
||||
@ -88,6 +92,34 @@ func GetConn(schema, etcdaddr, serviceName string) *grpc.ClientConn {
|
||||
return r.grpcClientConn
|
||||
}
|
||||
|
||||
func GetAuthConn() *grpc.ClientConn {
|
||||
return GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName)
|
||||
}
|
||||
|
||||
func GetOfflineMessageConn() *grpc.ClientConn {
|
||||
return GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
}
|
||||
|
||||
func GetFriendConn() *grpc.ClientConn {
|
||||
return GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
}
|
||||
|
||||
func GetGroupConn() *grpc.ClientConn {
|
||||
return GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
}
|
||||
|
||||
func GetUserConn() *grpc.ClientConn {
|
||||
return GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
}
|
||||
|
||||
func GetPushConn() *grpc.ClientConn {
|
||||
return GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImPushName)
|
||||
}
|
||||
|
||||
func GetOnlineMessageConn() []*grpc.ClientConn {
|
||||
return GetConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOnlineMessageRelayName)
|
||||
}
|
||||
|
||||
func (r *Resolver) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOptions) (resolver.Resolver, error) {
|
||||
if r.cli == nil {
|
||||
return nil, fmt.Errorf("etcd clientv3 client failed, etcd:%s", target)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user