Skip to content

Commit

Permalink
feat: Optimizing RPC call (openimsdk#2993)
Browse files Browse the repository at this point in the history
* pb

* fix: Modifying other fields while setting IsPrivateChat does not take effect

* fix: quote message error revoke

* refactoring scheduled tasks

* refactoring scheduled tasks

* refactoring scheduled tasks

* refactoring scheduled tasks

* refactoring scheduled tasks

* refactoring scheduled tasks

* rpc client

* rpc client

* rpc client

* rpc client

* rpc client

* rpc client

* rpc client

* rpc client
  • Loading branch information
withchao authored Dec 24, 2024
1 parent e989506 commit e3f609b
Show file tree
Hide file tree
Showing 67 changed files with 1,287 additions and 1,092 deletions.
6 changes: 2 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ module github.com/openimsdk/open-im-server/v3

go 1.22.7

toolchain go1.23.2

require (
firebase.google.com/go/v4 v4.14.1
github.com/dtm-labs/rockscache v0.1.1
Expand All @@ -14,8 +12,8 @@ require (
github.com/gorilla/websocket v1.5.1
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/mitchellh/mapstructure v1.5.0
github.com/openimsdk/protocol v0.0.72-alpha.67
github.com/openimsdk/tools v0.0.50-alpha.58
github.com/openimsdk/protocol v0.0.72-alpha.68
github.com/openimsdk/tools v0.0.50-alpha.60
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.18.0
github.com/stretchr/testify v1.9.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,10 @@ github.com/onsi/gomega v1.25.0 h1:Vw7br2PCDYijJHSfBOWhov+8cAnUf8MfMaIOV323l6Y=
github.com/onsi/gomega v1.25.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM=
github.com/openimsdk/gomake v0.0.15-alpha.2 h1:5Q8yl8ezy2yx+q8/ucU/t4kJnDfCzNOrkXcDACCqtyM=
github.com/openimsdk/gomake v0.0.15-alpha.2/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI=
github.com/openimsdk/protocol v0.0.72-alpha.67 h1:zlLbVkoT0OYsjO2RCutQuDFllcfNvZfdYchvlR6UIe0=
github.com/openimsdk/protocol v0.0.72-alpha.67/go.mod h1:Iet+piS/jaS+kWWyj6EEr36mk4ISzIRYjoMSVA4dq2M=
github.com/openimsdk/tools v0.0.50-alpha.58 h1:hkFL02Bzzp/l5x+tb7kJ9zes7hilh65EQ4qEIthsQX4=
github.com/openimsdk/tools v0.0.50-alpha.58/go.mod h1:muCtxguNJv8lFwLei27UASu2Nvg4ERSeN0R4K5tivk0=
github.com/openimsdk/protocol v0.0.72-alpha.68 h1:Ekn6S9Ftt12Xs/p9kJ39RDr2gSwIczz+MmSHQE4lAek=
github.com/openimsdk/protocol v0.0.72-alpha.68/go.mod h1:Iet+piS/jaS+kWWyj6EEr36mk4ISzIRYjoMSVA4dq2M=
github.com/openimsdk/tools v0.0.50-alpha.60 h1:dYqYpSdSN5o6CxlEjua2USfwfUiG0tUWFBpqghTjbWE=
github.com/openimsdk/tools v0.0.50-alpha.60/go.mod h1:muCtxguNJv8lFwLei27UASu2Nvg4ERSeN0R4K5tivk0=
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
Expand Down
16 changes: 9 additions & 7 deletions internal/api/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,26 @@ import (
"github.com/openimsdk/tools/a2r"
)

type AuthApi struct{}
type AuthApi struct {
Client auth.AuthClient
}

func NewAuthApi() AuthApi {
return AuthApi{}
func NewAuthApi(client auth.AuthClient) AuthApi {
return AuthApi{client}
}

func (o *AuthApi) GetAdminToken(c *gin.Context) {
a2r.CallV2(c, auth.GetAdminTokenCaller.Invoke)
a2r.Call(c, auth.AuthClient.GetAdminToken, o.Client)
}

func (o *AuthApi) GetUserToken(c *gin.Context) {
a2r.CallV2(c, auth.GetUserTokenCaller.Invoke)
a2r.Call(c, auth.AuthClient.GetUserToken, o.Client)
}

func (o *AuthApi) ParseToken(c *gin.Context) {
a2r.CallV2(c, auth.ParseTokenCaller.Invoke)
a2r.Call(c, auth.AuthClient.ParseToken, o.Client)
}

func (o *AuthApi) ForceLogout(c *gin.Context) {
a2r.CallV2(c, auth.ForceLogoutCaller.Invoke)
a2r.Call(c, auth.AuthClient.ForceLogout, o.Client)
}
30 changes: 16 additions & 14 deletions internal/api/conversation.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,52 +20,54 @@ import (
"github.com/openimsdk/tools/a2r"
)

type ConversationApi struct{}
type ConversationApi struct {
Client conversation.ConversationClient
}

func NewConversationApi() ConversationApi {
return ConversationApi{}
func NewConversationApi(client conversation.ConversationClient) ConversationApi {
return ConversationApi{client}
}

func (o *ConversationApi) GetAllConversations(c *gin.Context) {
a2r.CallV2(c, conversation.GetAllConversationsCaller.Invoke)
a2r.Call(c, conversation.ConversationClient.GetAllConversations, o.Client)
}

func (o *ConversationApi) GetSortedConversationList(c *gin.Context) {
a2r.CallV2(c, conversation.GetSortedConversationListCaller.Invoke)
a2r.Call(c, conversation.ConversationClient.GetSortedConversationList, o.Client)
}

func (o *ConversationApi) GetConversation(c *gin.Context) {
a2r.CallV2(c, conversation.GetConversationCaller.Invoke)
a2r.Call(c, conversation.ConversationClient.GetConversation, o.Client)
}

func (o *ConversationApi) GetConversations(c *gin.Context) {
a2r.CallV2(c, conversation.GetConversationsCaller.Invoke)
a2r.Call(c, conversation.ConversationClient.GetConversations, o.Client)
}

func (o *ConversationApi) SetConversations(c *gin.Context) {
a2r.CallV2(c, conversation.SetConversationsCaller.Invoke)
a2r.Call(c, conversation.ConversationClient.SetConversations, o.Client)
}

func (o *ConversationApi) GetConversationOfflinePushUserIDs(c *gin.Context) {
a2r.CallV2(c, conversation.GetConversationOfflinePushUserIDsCaller.Invoke)
a2r.Call(c, conversation.ConversationClient.GetConversationOfflinePushUserIDs, o.Client)
}

func (o *ConversationApi) GetFullOwnerConversationIDs(c *gin.Context) {
a2r.CallV2(c, conversation.GetFullOwnerConversationIDsCaller.Invoke)
a2r.Call(c, conversation.ConversationClient.GetFullOwnerConversationIDs, o.Client)
}

func (o *ConversationApi) GetIncrementalConversation(c *gin.Context) {
a2r.CallV2(c, conversation.GetIncrementalConversationCaller.Invoke)
a2r.Call(c, conversation.ConversationClient.GetIncrementalConversation, o.Client)
}

func (o *ConversationApi) GetOwnerConversation(c *gin.Context) {
a2r.CallV2(c, conversation.GetOwnerConversationCaller.Invoke)
a2r.Call(c, conversation.ConversationClient.GetOwnerConversation, o.Client)
}

func (o *ConversationApi) GetNotNotifyConversationIDs(c *gin.Context) {
a2r.CallV2(c, conversation.GetNotNotifyConversationIDsCaller.Invoke)
a2r.Call(c, conversation.ConversationClient.GetNotNotifyConversationIDs, o.Client)
}

func (o *ConversationApi) GetPinnedConversationIDs(c *gin.Context) {
a2r.CallV2(c, conversation.GetPinnedConversationIDsCaller.Invoke)
a2r.Call(c, conversation.ConversationClient.GetPinnedConversationIDs, o.Client)
}
50 changes: 26 additions & 24 deletions internal/api/friend.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,94 +21,96 @@ import (
"github.com/openimsdk/tools/a2r"
)

type FriendApi struct{}
type FriendApi struct {
Client relation.FriendClient
}

func NewFriendApi() FriendApi {
return FriendApi{}
func NewFriendApi(client relation.FriendClient) FriendApi {
return FriendApi{client}
}

func (o *FriendApi) ApplyToAddFriend(c *gin.Context) {
a2r.CallV2(c, relation.ApplyToAddFriendCaller.Invoke)
a2r.Call(c, relation.FriendClient.ApplyToAddFriend, o.Client)
}

func (o *FriendApi) RespondFriendApply(c *gin.Context) {
a2r.CallV2(c, relation.RespondFriendApplyCaller.Invoke)
a2r.Call(c, relation.FriendClient.RespondFriendApply, o.Client)
}

func (o *FriendApi) DeleteFriend(c *gin.Context) {
a2r.CallV2(c, relation.DeleteFriendCaller.Invoke)
a2r.Call(c, relation.FriendClient.DeleteFriend, o.Client)
}

func (o *FriendApi) GetFriendApplyList(c *gin.Context) {
a2r.CallV2(c, relation.GetPaginationFriendsApplyToCaller.Invoke)
a2r.Call(c, relation.FriendClient.GetPaginationFriendsApplyTo, o.Client)
}

func (o *FriendApi) GetDesignatedFriendsApply(c *gin.Context) {
a2r.CallV2(c, relation.GetDesignatedFriendsApplyCaller.Invoke)
a2r.Call(c, relation.FriendClient.GetDesignatedFriendsApply, o.Client)
}

func (o *FriendApi) GetSelfApplyList(c *gin.Context) {
a2r.CallV2(c, relation.GetPaginationFriendsApplyFromCaller.Invoke)
a2r.Call(c, relation.FriendClient.GetPaginationFriendsApplyFrom, o.Client)
}

func (o *FriendApi) GetFriendList(c *gin.Context) {
a2r.CallV2(c, relation.GetPaginationFriendsCaller.Invoke)
a2r.Call(c, relation.FriendClient.GetPaginationFriends, o.Client)
}

func (o *FriendApi) GetDesignatedFriends(c *gin.Context) {
a2r.CallV2(c, relation.GetDesignatedFriendsCaller.Invoke)
a2r.Call(c, relation.FriendClient.GetDesignatedFriends, o.Client)
}

func (o *FriendApi) SetFriendRemark(c *gin.Context) {
a2r.CallV2(c, relation.SetFriendRemarkCaller.Invoke)
a2r.Call(c, relation.FriendClient.SetFriendRemark, o.Client)
}

func (o *FriendApi) AddBlack(c *gin.Context) {
a2r.CallV2(c, relation.AddBlackCaller.Invoke)
a2r.Call(c, relation.FriendClient.AddBlack, o.Client)
}

func (o *FriendApi) GetPaginationBlacks(c *gin.Context) {
a2r.CallV2(c, relation.GetPaginationBlacksCaller.Invoke)
a2r.Call(c, relation.FriendClient.GetPaginationBlacks, o.Client)
}

func (o *FriendApi) GetSpecifiedBlacks(c *gin.Context) {
a2r.CallV2(c, relation.GetSpecifiedBlacksCaller.Invoke)
a2r.Call(c, relation.FriendClient.GetSpecifiedBlacks, o.Client)
}

func (o *FriendApi) RemoveBlack(c *gin.Context) {
a2r.CallV2(c, relation.RemoveBlackCaller.Invoke)
a2r.Call(c, relation.FriendClient.RemoveBlack, o.Client)
}

func (o *FriendApi) ImportFriends(c *gin.Context) {
a2r.CallV2(c, relation.ImportFriendsCaller.Invoke)
a2r.Call(c, relation.FriendClient.ImportFriends, o.Client)
}

func (o *FriendApi) IsFriend(c *gin.Context) {
a2r.CallV2(c, relation.IsFriendCaller.Invoke)
a2r.Call(c, relation.FriendClient.IsFriend, o.Client)
}

func (o *FriendApi) GetFriendIDs(c *gin.Context) {
a2r.CallV2(c, relation.GetFriendIDsCaller.Invoke)
a2r.Call(c, relation.FriendClient.GetFriendIDs, o.Client)
}

func (o *FriendApi) GetSpecifiedFriendsInfo(c *gin.Context) {
a2r.CallV2(c, relation.GetSpecifiedFriendsInfoCaller.Invoke)
a2r.Call(c, relation.FriendClient.GetSpecifiedFriendsInfo, o.Client)
}

func (o *FriendApi) UpdateFriends(c *gin.Context) {
a2r.CallV2(c, relation.UpdateFriendsCaller.Invoke)
a2r.Call(c, relation.FriendClient.UpdateFriends, o.Client)
}

func (o *FriendApi) GetIncrementalFriends(c *gin.Context) {
a2r.CallV2(c, relation.GetIncrementalFriendsCaller.Invoke)
a2r.Call(c, relation.FriendClient.GetIncrementalFriends, o.Client)
}

// GetIncrementalBlacks is temporarily unused.
// Deprecated: This function is currently unused and may be removed in future versions.
func (o *FriendApi) GetIncrementalBlacks(c *gin.Context) {
a2r.CallV2(c, relation.GetIncrementalBlacksCaller.Invoke)
a2r.Call(c, relation.FriendClient.GetIncrementalBlacks, o.Client)
}

func (o *FriendApi) GetFullFriendUserIDs(c *gin.Context) {
a2r.CallV2(c, relation.GetFullFriendUserIDsCaller.Invoke)
a2r.Call(c, relation.FriendClient.GetFullFriendUserIDs, o.Client)
}
Loading

0 comments on commit e3f609b

Please sign in to comment.