From 1237549e25abe88642ab994c40ace3dc9d496f5e Mon Sep 17 00:00:00 2001 From: Monet Lee Date: Wed, 31 Jul 2024 18:02:58 +0800 Subject: [PATCH] refactor: rename friend module to relation. --- internal/rpc/{friend => relation}/black.go | 2 +- internal/rpc/{friend => relation}/callback.go | 2 +- internal/rpc/{friend => relation}/friend.go | 3 +- .../rpc/{friend => relation}/notification.go | 2 +- internal/rpc/{friend => relation}/sync.go | 2 +- internal/rpc/user/user.go | 6 ++-- pkg/common/cmd/friend.go | 34 +++++++++---------- 7 files changed, 26 insertions(+), 25 deletions(-) rename internal/rpc/{friend => relation}/black.go (99%) rename internal/rpc/{friend => relation}/callback.go (99%) rename internal/rpc/{friend => relation}/friend.go (99%) rename internal/rpc/{friend => relation}/notification.go (99%) rename internal/rpc/{friend => relation}/sync.go (99%) diff --git a/internal/rpc/friend/black.go b/internal/rpc/relation/black.go similarity index 99% rename from internal/rpc/friend/black.go rename to internal/rpc/relation/black.go index 218d1e7f85..e149e31653 100644 --- a/internal/rpc/friend/black.go +++ b/internal/rpc/relation/black.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package friend +package relation import ( "context" diff --git a/internal/rpc/friend/callback.go b/internal/rpc/relation/callback.go similarity index 99% rename from internal/rpc/friend/callback.go rename to internal/rpc/relation/callback.go index 746ad21fa1..69c4c9e0ec 100644 --- a/internal/rpc/friend/callback.go +++ b/internal/rpc/relation/callback.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package friend +package relation import ( "context" diff --git a/internal/rpc/friend/friend.go b/internal/rpc/relation/friend.go similarity index 99% rename from internal/rpc/friend/friend.go rename to internal/rpc/relation/friend.go index bdb786bca4..3d29ad3379 100644 --- a/internal/rpc/friend/friend.go +++ b/internal/rpc/relation/friend.go @@ -12,10 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -package friend +package relation import ( "context" + "github.com/openimsdk/tools/mq/memamq" "github.com/openimsdk/open-im-server/v3/pkg/common/config" diff --git a/internal/rpc/friend/notification.go b/internal/rpc/relation/notification.go similarity index 99% rename from internal/rpc/friend/notification.go rename to internal/rpc/relation/notification.go index 5fb34577fc..83c5d2ca9d 100644 --- a/internal/rpc/friend/notification.go +++ b/internal/rpc/relation/notification.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package friend +package relation import ( "context" diff --git a/internal/rpc/friend/sync.go b/internal/rpc/relation/sync.go similarity index 99% rename from internal/rpc/friend/sync.go rename to internal/rpc/relation/sync.go index 902cc73037..0ad94fe825 100644 --- a/internal/rpc/friend/sync.go +++ b/internal/rpc/relation/sync.go @@ -1,4 +1,4 @@ -package friend +package relation import ( "context" diff --git a/internal/rpc/user/user.go b/internal/rpc/user/user.go index 1e534437df..a6952bd6db 100644 --- a/internal/rpc/user/user.go +++ b/internal/rpc/user/user.go @@ -17,7 +17,7 @@ package user import ( "context" "errors" - "github.com/openimsdk/open-im-server/v3/internal/rpc/friend" + "github.com/openimsdk/open-im-server/v3/internal/rpc/relation" "github.com/openimsdk/open-im-server/v3/pkg/common/config" "github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics" "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache" @@ -54,7 +54,7 @@ import ( type userServer struct { online cache.OnlineCache db controller.UserDatabase - friendNotificationSender *friend.FriendNotificationSender + friendNotificationSender *relation.FriendNotificationSender userNotificationSender *UserNotificationSender friendRpcClient *rpcclient.FriendRpcClient groupRpcClient *rpcclient.GroupRpcClient @@ -105,7 +105,7 @@ func Start(ctx context.Context, config *Config, client registry.SvcDiscoveryRegi RegisterCenter: client, friendRpcClient: &friendRpcClient, groupRpcClient: &groupRpcClient, - friendNotificationSender: friend.NewFriendNotificationSender(&config.NotificationConfig, &msgRpcClient, friend.WithDBFunc(database.FindWithError)), + friendNotificationSender: relation.NewFriendNotificationSender(&config.NotificationConfig, &msgRpcClient, relation.WithDBFunc(database.FindWithError)), userNotificationSender: NewUserNotificationSender(config, &msgRpcClient, WithUserFunc(database.FindWithError)), config: config, webhookClient: webhook.NewWebhookClient(config.WebhooksConfig.URL), diff --git a/pkg/common/cmd/friend.go b/pkg/common/cmd/friend.go index 1bc9e6c543..a564facd06 100644 --- a/pkg/common/cmd/friend.go +++ b/pkg/common/cmd/friend.go @@ -17,7 +17,7 @@ package cmd import ( "context" - "github.com/openimsdk/open-im-server/v3/internal/rpc/friend" + "github.com/openimsdk/open-im-server/v3/internal/rpc/relation" "github.com/openimsdk/open-im-server/v3/pkg/common/startrpc" "github.com/openimsdk/open-im-server/v3/version" "github.com/openimsdk/tools/system/program" @@ -26,23 +26,23 @@ import ( type FriendRpcCmd struct { *RootCmd - ctx context.Context - configMap map[string]any - friendConfig *friend.Config + ctx context.Context + configMap map[string]any + relationConfig *relation.Config } func NewFriendRpcCmd() *FriendRpcCmd { - var friendConfig friend.Config - ret := &FriendRpcCmd{friendConfig: &friendConfig} + var relationConfig relation.Config + ret := &FriendRpcCmd{relationConfig: &relationConfig} ret.configMap = map[string]any{ - OpenIMRPCFriendCfgFileName: &friendConfig.RpcConfig, - RedisConfigFileName: &friendConfig.RedisConfig, - MongodbConfigFileName: &friendConfig.MongodbConfig, - ShareFileName: &friendConfig.Share, - NotificationFileName: &friendConfig.NotificationConfig, - WebhooksConfigFileName: &friendConfig.WebhooksConfig, - LocalCacheConfigFileName: &friendConfig.LocalCacheConfig, - DiscoveryConfigFilename: &friendConfig.Discovery, + OpenIMRPCFriendCfgFileName: &relationConfig.RpcConfig, + RedisConfigFileName: &relationConfig.RedisConfig, + MongodbConfigFileName: &relationConfig.MongodbConfig, + ShareFileName: &relationConfig.Share, + NotificationFileName: &relationConfig.NotificationConfig, + WebhooksConfigFileName: &relationConfig.WebhooksConfig, + LocalCacheConfigFileName: &relationConfig.LocalCacheConfig, + DiscoveryConfigFilename: &relationConfig.Discovery, } ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap)) ret.ctx = context.WithValue(context.Background(), "version", version.Version) @@ -57,7 +57,7 @@ func (a *FriendRpcCmd) Exec() error { } func (a *FriendRpcCmd) runE() error { - return startrpc.Start(a.ctx, &a.friendConfig.Discovery, &a.friendConfig.RpcConfig.Prometheus, a.friendConfig.RpcConfig.RPC.ListenIP, - a.friendConfig.RpcConfig.RPC.RegisterIP, a.friendConfig.RpcConfig.RPC.Ports, - a.Index(), a.friendConfig.Share.RpcRegisterName.Friend, &a.friendConfig.Share, a.friendConfig, friend.Start) + return startrpc.Start(a.ctx, &a.relationConfig.Discovery, &a.relationConfig.RpcConfig.Prometheus, a.relationConfig.RpcConfig.RPC.ListenIP, + a.relationConfig.RpcConfig.RPC.RegisterIP, a.relationConfig.RpcConfig.RPC.Ports, + a.Index(), a.relationConfig.Share.RpcRegisterName.Friend, &a.relationConfig.Share, a.relationConfig, relation.Start) }