Skip to content

Commit

Permalink
rpc client
Browse files Browse the repository at this point in the history
  • Loading branch information
withchao committed Dec 24, 2024
1 parent d9566e9 commit cf78df3
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 241 deletions.
9 changes: 4 additions & 5 deletions internal/rpc/group/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@ import (

type groupServer struct {
pbgroup.UnimplementedGroupServer
db controller.GroupDatabase
notification *NotificationSender
config *Config
webhookClient *webhook.Client
// todo
db controller.GroupDatabase
notification *NotificationSender
config *Config
webhookClient *webhook.Client
userClient *rpcli.UserClient
msgClient *rpcli.MsgClient
conversationClient *rpcli.ConversationClient
Expand Down
15 changes: 0 additions & 15 deletions internal/rpc/relation/friend.go
Original file line number Diff line number Diff line change
Expand Up @@ -530,18 +530,3 @@ func (s *friendServer) UpdateFriends(
s.notificationSender.FriendsInfoUpdateNotification(ctx, req.OwnerUserID, req.FriendUserIDs)
return resp, nil
}

func (s *friendServer) GetIncrementalFriendsApplyTo(ctx context.Context, req *relation.GetIncrementalFriendsApplyToReq) (*relation.GetIncrementalFriendsApplyToResp, error) {
// TODO implement me
return nil, nil
}

func (s *friendServer) GetIncrementalFriendsApplyFrom(ctx context.Context, req *relation.GetIncrementalFriendsApplyFromReq) (*relation.GetIncrementalFriendsApplyFromResp, error) {
// TODO implement me
return nil, nil
}

func (s *friendServer) GetIncrementalBlacks(ctx context.Context, req *relation.GetIncrementalBlacksReq) (*relation.GetIncrementalBlacksResp, error) {
// TODO implement me
return nil, nil
}
16 changes: 13 additions & 3 deletions internal/rpc/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ type userServer struct {
RegisterCenter registry.SvcDiscoveryRegistry
config *Config
webhookClient *webhook.Client
// todo
groupClient *rpcli.GroupClient
relationClient *rpcli.RelationClient
groupClient *rpcli.GroupClient
relationClient *rpcli.RelationClient
}

type Config struct {
Expand Down Expand Up @@ -99,6 +98,14 @@ func Start(ctx context.Context, config *Config, client registry.SvcDiscoveryRegi
if err != nil {
return err
}
groupConn, err := client.GetConn(ctx, config.Discovery.RpcService.Group)
if err != nil {
return err
}
friendConn, err := client.GetConn(ctx, config.Discovery.RpcService.Friend)
if err != nil {
return err
}
msgClient := rpcli.NewMsgClient(msgConn)
userCache := redis.NewUserCacheRedis(rdb, &config.LocalCacheConfig, userDB, redis.GetRocksCacheOptions())
database := controller.NewUserDatabase(userDB, userCache, mgocli.GetTx())
Expand All @@ -111,6 +118,9 @@ func Start(ctx context.Context, config *Config, client registry.SvcDiscoveryRegi
userNotificationSender: NewUserNotificationSender(config, msgClient, WithUserFunc(database.FindWithError)),
config: config,
webhookClient: webhook.NewWebhookClient(config.WebhooksConfig.URL),

groupClient: rpcli.NewGroupClient(groupConn),
relationClient: rpcli.NewRelationClient(friendConn),
}
pbuser.RegisterUserServer(server, u)
return u.db.InitOnce(context.Background(), users)
Expand Down
File renamed without changes.
3 changes: 0 additions & 3 deletions pkg/rpcclient/msg.go → pkg/notification/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package rpcclient
import (
"context"
"encoding/json"
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
"time"

"google.golang.org/protobuf/proto"
Expand Down Expand Up @@ -133,8 +132,6 @@ type NotificationSender struct {
sendMsg func(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error)
getUserInfo func(ctx context.Context, userID string) (*sdkws.UserInfo, error)
queue *memamq.MemoryQueue
// todo
msgClient *rpcli.MsgClient
}

func WithQueue(queue *memamq.MemoryQueue) NotificationSenderOptions {
Expand Down
File renamed without changes.
15 changes: 0 additions & 15 deletions pkg/rpcclient/doc.go

This file was deleted.

15 changes: 0 additions & 15 deletions pkg/rpcclient/grouphash/doc.go

This file was deleted.

60 changes: 0 additions & 60 deletions pkg/rpcclient/init.go

This file was deleted.

15 changes: 0 additions & 15 deletions pkg/rpcclient/notification/doc.go

This file was deleted.

110 changes: 0 additions & 110 deletions pkg/rpcclient/user.go

This file was deleted.

0 comments on commit cf78df3

Please sign in to comment.