refactor(rpc): 重构 RPC 客户端并添加重连机制

- 更新了 RPC 客户端的初始化和重连逻辑
- 添加了重连函数和最大重试次数的配置
- 优化了与服务器的连接管理
- 调整了端口相关的数据类型
This commit is contained in:
2025-07-17 05:20:30 +08:00
parent b6231f6eb9
commit bf72b91fc6
18 changed files with 131 additions and 46 deletions

View File

@@ -3,10 +3,13 @@ package admin
import (
"context"
"blazing/common/data/share"
"blazing/cool"
"blazing/modules/base/service"
blazing_service "blazing/modules/blazing/service"
"github.com/gogf/gf/v2/frame/g"
)
@@ -30,9 +33,35 @@ type UserMoveReq struct {
g.Meta `path:"/move" method:"GET"`
Authorization string `json:"Authorization" in:"header"`
}
type SessionReq struct {
g.Meta `path:"/getSession" method:"GET"`
Authorization string `json:"Authorization" in:"header"`
}
func (c *BaseSysUserController) Move(ctx context.Context, req *UserMoveReq) (res *cool.BaseRes, err error) {
err = service.NewBaseSysUserService().Move(ctx)
res = cool.Ok(nil)
return
}
func (c *BaseSysUserController) GetSession(ctx context.Context, req *SessionReq) (res *cool.BaseRes, err error) {
t := cool.GetAdmin(ctx)
if t == nil || t.UserId == 0 {
return cool.Fail("未登录"), nil
}
retsid, sid, err := blazing_service.NewLoginServiceService().GetSessionId(t.UserId)
if err != nil {
return cool.Fail(err.Error()), nil
}
res = cool.Ok(nil)
res.Data = retsid
if err := share.ShareManager.SaveSession(sid, uint32(t.UserId)); err != nil {
return cool.Fail(err.Error()), nil
}
return
}