grpc conn reuse

This commit is contained in:
wangchuxiao
2023-05-30 16:15:11 +08:00
parent 1b109964ff
commit 85bf1f44e0
20 changed files with 160 additions and 267 deletions
+15
View File
@@ -0,0 +1,15 @@
package notification
type CommonUser interface {
GetNickname() string
GetFaceURL() string
GetUserID() string
GetEx() string
}
type CommonGroup interface {
GetNickname() string
GetFaceURL() string
GetGroupID() string
GetEx() string
}
+3 -3
View File
@@ -16,7 +16,7 @@ import (
type FriendNotificationSender struct {
*rpcclient.NotificationSender
// 找不到报错
getUsersInfo func(ctx context.Context, userIDs []string) ([]rpcclient.CommonUser, error)
getUsersInfo func(ctx context.Context, userIDs []string) ([]CommonUser, error)
// db controller
db controller.FriendDatabase
}
@@ -31,7 +31,7 @@ func WithFriendDB(db controller.FriendDatabase) friendNotificationSenderOptions
func WithDBFunc(fn func(ctx context.Context, userIDs []string) (users []*relationTb.UserModel, err error)) friendNotificationSenderOptions {
return func(s *FriendNotificationSender) {
f := func(ctx context.Context, userIDs []string) (result []rpcclient.CommonUser, err error) {
f := func(ctx context.Context, userIDs []string) (result []CommonUser, err error) {
users, err := fn(ctx, userIDs)
if err != nil {
return nil, err
@@ -47,7 +47,7 @@ func WithDBFunc(fn func(ctx context.Context, userIDs []string) (users []*relatio
func WithRpcFunc(fn func(ctx context.Context, userIDs []string) ([]*sdkws.UserInfo, error)) friendNotificationSenderOptions {
return func(s *FriendNotificationSender) {
f := func(ctx context.Context, userIDs []string) (result []rpcclient.CommonUser, err error) {
f := func(ctx context.Context, userIDs []string) (result []CommonUser, err error) {
users, err := fn(ctx, userIDs)
if err != nil {
return nil, err
+2 -2
View File
@@ -17,7 +17,7 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
)
func NewGroupNotificationSender(db controller.GroupDatabase, sdr discoveryregistry.SvcDiscoveryRegistry, fn func(ctx context.Context, userIDs []string) ([]rpcclient.CommonUser, error)) *GroupNotificationSender {
func NewGroupNotificationSender(db controller.GroupDatabase, sdr discoveryregistry.SvcDiscoveryRegistry, fn func(ctx context.Context, userIDs []string) ([]CommonUser, error)) *GroupNotificationSender {
return &GroupNotificationSender{
NotificationSender: rpcclient.NewNotificationSender(rpcclient.WithDiscov(sdr)),
getUsersInfo: fn,
@@ -27,7 +27,7 @@ func NewGroupNotificationSender(db controller.GroupDatabase, sdr discoveryregist
type GroupNotificationSender struct {
*rpcclient.NotificationSender
getUsersInfo func(ctx context.Context, userIDs []string) ([]rpcclient.CommonUser, error)
getUsersInfo func(ctx context.Context, userIDs []string) ([]CommonUser, error)
db controller.GroupDatabase
}