Skip to content

Commit

Permalink
refactor: rpcclient
Browse files Browse the repository at this point in the history
  • Loading branch information
icey-yu committed Dec 16, 2024
1 parent 7c7a99f commit 77386cd
Show file tree
Hide file tree
Showing 59 changed files with 707 additions and 1,481 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,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.63
github.com/openimsdk/tools v0.0.50-alpha.51
github.com/openimsdk/protocol v0.0.72-alpha.65
github.com/openimsdk/tools v0.0.50-alpha.54
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.63 h1:IyPBibEvwBtTmD8DSrlqcekfEXe74k4+KeeHsgdhGh0=
github.com/openimsdk/protocol v0.0.72-alpha.63/go.mod h1:Iet+piS/jaS+kWWyj6EEr36mk4ISzIRYjoMSVA4dq2M=
github.com/openimsdk/tools v0.0.50-alpha.51 h1:M3dMUoHjggx5Ry6XSkK0FTSJmRQjjkSBpuzXiFzKtC4=
github.com/openimsdk/tools v0.0.50-alpha.51/go.mod h1:muCtxguNJv8lFwLei27UASu2Nvg4ERSeN0R4K5tivk0=
github.com/openimsdk/protocol v0.0.72-alpha.65 h1:XounEpI5acVtMIsCe3A9X9YNsvaADJd4KckapO4xRWQ=
github.com/openimsdk/protocol v0.0.72-alpha.65/go.mod h1:Iet+piS/jaS+kWWyj6EEr36mk4ISzIRYjoMSVA4dq2M=
github.com/openimsdk/tools v0.0.50-alpha.54 h1:SwHzd1R4aB0HSBuxjXorW87reeA1yLTZxjssuGJ1g1c=
github.com/openimsdk/tools v0.0.50-alpha.54/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
15 changes: 7 additions & 8 deletions internal/api/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,28 @@ package api

import (
"github.com/gin-gonic/gin"
"github.com/openimsdk/open-im-server/v3/pkg/rpcclient"
"github.com/openimsdk/protocol/auth"
"github.com/openimsdk/tools/a2r"
)

type AuthApi rpcclient.Auth
type AuthApi struct{}

func NewAuthApi(client rpcclient.Auth) AuthApi {
return AuthApi(client)
func NewAuthApi() AuthApi {
return AuthApi{}
}

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

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

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

func (o *AuthApi) ForceLogout(c *gin.Context) {
a2r.Call(auth.AuthClient.ForceLogout, o.Client, c)
a2r.CallV2(auth.ForceLogoutCaller.Invoke, c)
}
29 changes: 14 additions & 15 deletions internal/api/conversation.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,57 +16,56 @@ package api

import (
"github.com/gin-gonic/gin"
"github.com/openimsdk/open-im-server/v3/pkg/rpcclient"
"github.com/openimsdk/protocol/conversation"
"github.com/openimsdk/tools/a2r"
)

type ConversationApi rpcclient.Conversation
type ConversationApi struct{}

func NewConversationApi(client rpcclient.Conversation) ConversationApi {
return ConversationApi(client)
func NewConversationApi() ConversationApi {
return ConversationApi{}
}

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

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

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

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

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

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

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

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

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

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

func (o *ConversationApi) GetPinnedConversationIDs(c *gin.Context) {
a2r.Call(conversation.ConversationClient.GetPinnedConversationIDs, o.Client, c)
a2r.CallV2(conversation.GetPinnedConversationIDsCaller.Invoke, c)
}
49 changes: 24 additions & 25 deletions internal/api/friend.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,99 +17,98 @@ package api
import (
"github.com/gin-gonic/gin"

"github.com/openimsdk/open-im-server/v3/pkg/rpcclient"
"github.com/openimsdk/protocol/relation"
"github.com/openimsdk/tools/a2r"
)

type FriendApi rpcclient.Friend
type FriendApi struct{}

func NewFriendApi(client rpcclient.Friend) FriendApi {
return FriendApi(client)
func NewFriendApi() FriendApi {
return FriendApi{}
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// 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.Call(relation.FriendClient.GetIncrementalBlacks, o.Client, c)
a2r.CallV2(relation.GetIncrementalBlacksCaller.Invoke, c)
}

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

0 comments on commit 77386cd

Please sign in to comment.