makelint internal/ (#1951)

Signed-off-by: xuan <146319162+wxuanF@users.noreply.github.com>
pull/1956/head
xuan 9 months ago committed by GitHub
parent 3c1d096e99
commit b13f2614b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -78,16 +78,17 @@ type Client struct {
token string token string
} }
func newClient(ctx *UserConnContext, conn LongConn, isCompress bool) *Client { // function not used
return &Client{ // func newClient(ctx *UserConnContext, conn LongConn, isCompress bool) *Client {
w: new(sync.Mutex), // return &Client{
conn: conn, // w: new(sync.Mutex),
PlatformID: utils.StringToInt(ctx.GetPlatformID()), // conn: conn,
IsCompress: isCompress, // PlatformID: utils.StringToInt(ctx.GetPlatformID()),
UserID: ctx.GetUserID(), // IsCompress: isCompress,
ctx: ctx, // UserID: ctx.GetUserID(),
} // ctx: ctx,
} // }
// }
// ResetClient updates the client's state with new connection and context information. // ResetClient updates the client's state with new connection and context information.
func (c *Client) ResetClient( func (c *Client) ResetClient(

@ -108,10 +108,12 @@ func (d *GWebSocket) Dial(urlStr string, requestHeader http.Header) (*http.Respo
} }
func (d *GWebSocket) IsNil() bool { func (d *GWebSocket) IsNil() bool {
if d.conn != nil { return d.conn == nil
return false //
} // if d.conn != nil {
return true // return false
// }
// return true
} }
func (d *GWebSocket) SetConnNil() { func (d *GWebSocket) SetConnNil() {

@ -61,11 +61,12 @@ type LongConnServer interface {
MessageHandler MessageHandler
} }
var bufferPool = sync.Pool{ // bufferPool is unused
New: func() any { // var bufferPool = sync.Pool{
return make([]byte, 1024) // New: func() any {
}, // return make([]byte, 1024)
} // },
// }
type WsServer struct { type WsServer struct {
port int port int

@ -58,12 +58,12 @@ func (u *UserMap) Get(key string, platformID int) ([]*Client, bool, bool) {
func (u *UserMap) Set(key string, v *Client) { func (u *UserMap) Set(key string, v *Client) {
allClients, existed := u.m.Load(key) allClients, existed := u.m.Load(key)
if existed { if existed {
log.ZDebug(context.Background(), "Set existed", "user_id", key, "client", *v) log.ZDebug(context.Background(), "Set existed", "user_id", key, "client_user_id", v.UserID)
oldClients := allClients.([]*Client) oldClients := allClients.([]*Client)
oldClients = append(oldClients, v) oldClients = append(oldClients, v)
u.m.Store(key, oldClients) u.m.Store(key, oldClients)
} else { } else {
log.ZDebug(context.Background(), "Set not existed", "user_id", key, "client", *v) log.ZDebug(context.Background(), "Set not existed", "user_id", key, "client_user_id", v.UserID)
var clients []*Client var clients []*Client
clients = append(clients, v) clients = append(clients, v)
u.m.Store(key, clients) u.m.Store(key, clients)

@ -71,7 +71,7 @@ func StartTransfer(prometheusPort int) error {
return err return err
} }
if err := client.CreateRpcRootNodes(config.Config.GetServiceNames()); err != nil { if err2 := client.CreateRpcRootNodes(config.Config.GetServiceNames()); err2 != nil {
return err return err
} }
client.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, "round_robin"))) client.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, "round_robin")))

@ -74,10 +74,10 @@ type OnlineHistoryRedisConsumerHandler struct {
chArrays [ChannelNum]chan Cmd2Value chArrays [ChannelNum]chan Cmd2Value
msgDistributionCh chan Cmd2Value msgDistributionCh chan Cmd2Value
singleMsgSuccessCount uint64 // singleMsgSuccessCount uint64
singleMsgFailedCount uint64 // singleMsgFailedCount uint64
singleMsgSuccessCountMutex sync.Mutex // singleMsgSuccessCountMutex sync.Mutex
singleMsgFailedCountMutex sync.Mutex // singleMsgFailedCountMutex sync.Mutex
msgDatabase controller.CommonMsgDatabase msgDatabase controller.CommonMsgDatabase
conversationRpcClient *rpcclient.ConversationRpcClient conversationRpcClient *rpcclient.ConversationRpcClient
@ -111,62 +111,59 @@ func NewOnlineHistoryRedisConsumerHandler(
} }
func (och *OnlineHistoryRedisConsumerHandler) Run(channelID int) { func (och *OnlineHistoryRedisConsumerHandler) Run(channelID int) {
for { for cmd := range och.chArrays[channelID] {
select { switch cmd.Cmd {
case cmd := <-och.chArrays[channelID]: case SourceMessages:
switch cmd.Cmd { msgChannelValue := cmd.Value.(MsgChannelValue)
case SourceMessages: ctxMsgList := msgChannelValue.ctxMsgList
msgChannelValue := cmd.Value.(MsgChannelValue) ctx := msgChannelValue.ctx
ctxMsgList := msgChannelValue.ctxMsgList log.ZDebug(
ctx := msgChannelValue.ctx ctx,
log.ZDebug( "msg arrived channel",
"channel id",
channelID,
"msgList length",
len(ctxMsgList),
"uniqueKey",
msgChannelValue.uniqueKey,
)
storageMsgList, notStorageMsgList, storageNotificationList, notStorageNotificationList, modifyMsgList := och.getPushStorageMsgList(
ctxMsgList,
)
log.ZDebug(
ctx,
"msg lens",
"storageMsgList",
len(storageMsgList),
"notStorageMsgList",
len(notStorageMsgList),
"storageNotificationList",
len(storageNotificationList),
"notStorageNotificationList",
len(notStorageNotificationList),
"modifyMsgList",
len(modifyMsgList),
)
conversationIDMsg := msgprocessor.GetChatConversationIDByMsg(ctxMsgList[0].message)
conversationIDNotification := msgprocessor.GetNotificationConversationIDByMsg(ctxMsgList[0].message)
och.handleMsg(ctx, msgChannelValue.uniqueKey, conversationIDMsg, storageMsgList, notStorageMsgList)
och.handleNotification(
ctx,
msgChannelValue.uniqueKey,
conversationIDNotification,
storageNotificationList,
notStorageNotificationList,
)
if err := och.msgDatabase.MsgToModifyMQ(ctx, msgChannelValue.uniqueKey, conversationIDNotification, modifyMsgList); err != nil {
log.ZError(
ctx, ctx,
"msg arrived channel", "msg to modify mq error",
"channel id", err,
channelID,
"msgList length",
len(ctxMsgList),
"uniqueKey", "uniqueKey",
msgChannelValue.uniqueKey, msgChannelValue.uniqueKey,
)
storageMsgList, notStorageMsgList, storageNotificationList, notStorageNotificationList, modifyMsgList := och.getPushStorageMsgList(
ctxMsgList,
)
log.ZDebug(
ctx,
"msg lens",
"storageMsgList",
len(storageMsgList),
"notStorageMsgList",
len(notStorageMsgList),
"storageNotificationList",
len(storageNotificationList),
"notStorageNotificationList",
len(notStorageNotificationList),
"modifyMsgList", "modifyMsgList",
len(modifyMsgList), modifyMsgList,
) )
conversationIDMsg := msgprocessor.GetChatConversationIDByMsg(ctxMsgList[0].message)
conversationIDNotification := msgprocessor.GetNotificationConversationIDByMsg(ctxMsgList[0].message)
och.handleMsg(ctx, msgChannelValue.uniqueKey, conversationIDMsg, storageMsgList, notStorageMsgList)
och.handleNotification(
ctx,
msgChannelValue.uniqueKey,
conversationIDNotification,
storageNotificationList,
notStorageNotificationList,
)
if err := och.msgDatabase.MsgToModifyMQ(ctx, msgChannelValue.uniqueKey, conversationIDNotification, modifyMsgList); err != nil {
log.ZError(
ctx,
"msg to modify mq error",
err,
"uniqueKey",
msgChannelValue.uniqueKey,
"modifyMsgList",
modifyMsgList,
)
}
} }
} }
} }

Loading…
Cancel
Save