|
|
@ -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,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|