mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-08 02:55:58 +08:00
feat: Optimizing RPC call (#2993)
* 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
This commit is contained in:
+18
-18
@@ -16,14 +16,13 @@ package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"google.golang.org/grpc"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/openimsdk/protocol/third"
|
||||
"github.com/openimsdk/tools/a2r"
|
||||
@@ -33,18 +32,19 @@ import (
|
||||
|
||||
type ThirdApi struct {
|
||||
GrafanaUrl string
|
||||
Client third.ThirdClient
|
||||
}
|
||||
|
||||
func NewThirdApi(grafanaUrl string) ThirdApi {
|
||||
return ThirdApi{GrafanaUrl: grafanaUrl}
|
||||
func NewThirdApi(client third.ThirdClient, grafanaUrl string) ThirdApi {
|
||||
return ThirdApi{Client: client, GrafanaUrl: grafanaUrl}
|
||||
}
|
||||
|
||||
func (o *ThirdApi) FcmUpdateToken(c *gin.Context) {
|
||||
a2r.CallV2(c, third.FcmUpdateTokenCaller.Invoke)
|
||||
a2r.Call(c, third.ThirdClient.FcmUpdateToken, o.Client)
|
||||
}
|
||||
|
||||
func (o *ThirdApi) SetAppBadge(c *gin.Context) {
|
||||
a2r.CallV2(c, third.SetAppBadgeCaller.Invoke)
|
||||
a2r.Call(c, third.ThirdClient.SetAppBadge, o.Client)
|
||||
}
|
||||
|
||||
// #################### s3 ####################
|
||||
@@ -79,44 +79,44 @@ func setURLPrefix(c *gin.Context, urlPrefix *string) error {
|
||||
}
|
||||
|
||||
func (o *ThirdApi) PartLimit(c *gin.Context) {
|
||||
a2r.CallV2(c, third.PartLimitCaller.Invoke)
|
||||
a2r.Call(c, third.ThirdClient.PartLimit, o.Client)
|
||||
}
|
||||
|
||||
func (o *ThirdApi) PartSize(c *gin.Context) {
|
||||
a2r.CallV2(c, third.PartSizeCaller.Invoke)
|
||||
a2r.Call(c, third.ThirdClient.PartSize, o.Client)
|
||||
}
|
||||
|
||||
func (o *ThirdApi) InitiateMultipartUpload(c *gin.Context) {
|
||||
opt := setURLPrefixOption(third.ThirdClient.InitiateMultipartUpload, func(req *third.InitiateMultipartUploadReq) error {
|
||||
return setURLPrefix(c, &req.UrlPrefix)
|
||||
})
|
||||
a2r.CallV2(c, third.InitiateMultipartUploadCaller.Invoke, opt)
|
||||
a2r.Call(c, third.ThirdClient.InitiateMultipartUpload, o.Client, opt)
|
||||
}
|
||||
|
||||
func (o *ThirdApi) AuthSign(c *gin.Context) {
|
||||
a2r.CallV2(c, third.AuthSignCaller.Invoke)
|
||||
a2r.Call(c, third.ThirdClient.AuthSign, o.Client)
|
||||
}
|
||||
|
||||
func (o *ThirdApi) CompleteMultipartUpload(c *gin.Context) {
|
||||
opt := setURLPrefixOption(third.ThirdClient.CompleteMultipartUpload, func(req *third.CompleteMultipartUploadReq) error {
|
||||
return setURLPrefix(c, &req.UrlPrefix)
|
||||
})
|
||||
a2r.CallV2(c, third.CompleteMultipartUploadCaller.Invoke, opt)
|
||||
a2r.Call(c, third.ThirdClient.CompleteMultipartUpload, o.Client, opt)
|
||||
}
|
||||
|
||||
func (o *ThirdApi) AccessURL(c *gin.Context) {
|
||||
a2r.CallV2(c, third.AccessURLCaller.Invoke)
|
||||
a2r.Call(c, third.ThirdClient.AccessURL, o.Client)
|
||||
}
|
||||
|
||||
func (o *ThirdApi) InitiateFormData(c *gin.Context) {
|
||||
a2r.CallV2(c, third.InitiateFormDataCaller.Invoke)
|
||||
a2r.Call(c, third.ThirdClient.InitiateFormData, o.Client)
|
||||
}
|
||||
|
||||
func (o *ThirdApi) CompleteFormData(c *gin.Context) {
|
||||
opt := setURLPrefixOption(third.ThirdClient.CompleteFormData, func(req *third.CompleteFormDataReq) error {
|
||||
return setURLPrefix(c, &req.UrlPrefix)
|
||||
})
|
||||
a2r.CallV2(c, third.CompleteFormDataCaller.Invoke, opt)
|
||||
a2r.Call(c, third.ThirdClient.CompleteFormData, o.Client, opt)
|
||||
}
|
||||
|
||||
func (o *ThirdApi) ObjectRedirect(c *gin.Context) {
|
||||
@@ -140,7 +140,7 @@ func (o *ThirdApi) ObjectRedirect(c *gin.Context) {
|
||||
}
|
||||
query[key] = values[0]
|
||||
}
|
||||
resp, err := third.AccessURLCaller.Invoke(ctx, &third.AccessURLReq{Name: name, Query: query})
|
||||
resp, err := o.Client.AccessURL(ctx, &third.AccessURLReq{Name: name, Query: query})
|
||||
if err != nil {
|
||||
if errs.ErrArgs.Is(err) {
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
@@ -158,15 +158,15 @@ func (o *ThirdApi) ObjectRedirect(c *gin.Context) {
|
||||
|
||||
// #################### logs ####################.
|
||||
func (o *ThirdApi) UploadLogs(c *gin.Context) {
|
||||
a2r.CallV2(c, third.UploadLogsCaller.Invoke)
|
||||
a2r.Call(c, third.ThirdClient.UploadLogs, o.Client)
|
||||
}
|
||||
|
||||
func (o *ThirdApi) DeleteLogs(c *gin.Context) {
|
||||
a2r.CallV2(c, third.DeleteLogsCaller.Invoke)
|
||||
a2r.Call(c, third.ThirdClient.DeleteLogs, o.Client)
|
||||
}
|
||||
|
||||
func (o *ThirdApi) SearchLogs(c *gin.Context) {
|
||||
a2r.CallV2(c, third.SearchLogsCaller.Invoke)
|
||||
a2r.Call(c, third.ThirdClient.SearchLogs, o.Client)
|
||||
}
|
||||
|
||||
func (o *ThirdApi) GetPrometheus(c *gin.Context) {
|
||||
|
||||
Reference in New Issue
Block a user