From 92dc36f480acde7aaf12490e890504dfd7fc4a66 Mon Sep 17 00:00:00 2001 From: x-shadow-man <1494445739@qq.com> Date: Fri, 22 Jul 2022 09:40:54 +0800 Subject: [PATCH 01/15] config perf --- config/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.yaml b/config/config.yaml index c552a954d..145cccb62 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -72,7 +72,7 @@ kafka: serverip: 0.0.0.0 #作为rpc时,注册到etcd的地址,单机默认即可,如果是集群部署,需要修改(具体使用内网地址还是外网地址,要依情况而定,目的是api/gateway能访问到) -rpcRegisterIP: 127.0.0.1 +rpcRegisterIP: #默认即可 listenIP: 0.0.0.0 From 456e2f569306a6834ae857b9ab2f8cd196ee6d47 Mon Sep 17 00:00:00 2001 From: x-shadow-man <1494445739@qq.com> Date: Mon, 25 Jul 2022 10:24:21 +0800 Subject: [PATCH 02/15] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E8=A7=A3=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.yaml b/config/config.yaml index 145cccb62..b96bbaa2a 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -71,7 +71,7 @@ kafka: #如果是单机模式,用0.0.0.0或者不填,默认即可 serverip: 0.0.0.0 -#作为rpc时,注册到etcd的地址,单机默认即可,如果是集群部署,需要修改(具体使用内网地址还是外网地址,要依情况而定,目的是api/gateway能访问到) +#作为rpc时,注册到etcd的地址,单机或内网集群调用默认为空即可(会默认注册本机ip),如果需要注册外网ip,需要修改(目的是api/gateway能访问到) rpcRegisterIP: #默认即可 listenIP: 0.0.0.0 From 5e09e3e07284be4d4aaf24b97fb73dd38d9fb45c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AC=A7=E9=98=B3=E6=B0=8F?= Date: Thu, 11 Aug 2022 17:34:57 +0800 Subject: [PATCH 03/15] =?UTF-8?q?=E4=BF=AE=E5=A4=8Daws=20s3=20=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config.yaml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index d92f6c9ea..c2b033599 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -130,15 +130,14 @@ credential: #腾讯cos,发送图片、视频、文件时需要,请自行申 stsDurationSeconds: 3600 OssRoleArn: "acs:ram::xxx:role/xxx" aws: - accessKeyID: ******************** #AssumeRole用户关联的accessKeyID - accessKeySecret: **************************************** #AssumeRole用户关联的accessKeySecrect - region: ap-southeast-1 #分区 - bucket: ouyang #桶 - finalHost: ouyang.s3.ap-southeast-1.amazonaws.com #对外Host - roleArn: arn:aws:iam::192209831083:role/AWS_S3_FOR_OUYANG #RoleArn - externalId: AssumeRoleExtend #角色扩展Id - roleSessionName: Required-AWS-ID-OPENIM #角色SESSION名称 - + accessKeyID: AKIASZQEZISVRBN4UEWJ #AssumeRole用户关联的accessKeyID + accessKeySecret: eBS3RyCRD8yUa7I7EGPbxjyBlKtdzN5a6tDnY/wZ #AssumeRole用户关联的accessKeySecrect + region: ap-southeast-1 #分区 + bucket: ouyang #桶 + finalHost: ouyang.s3.ap-southeast-1.amazonaws.com #对外Host + roleArn: arn:aws:iam::192209831083:role/AWS_S3_FOR_OUYANG #RoleArn + externalId: AssumeRoleExtend #角色扩展Id + roleSessionName: Required-AWS-ID-OPENIM #角色SESSION名称 dtm: serverURL: 127.0.0.1:10007 From 5cb3b8cfbf2f64cfa510cd6281a64e3e90c785e3 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Thu, 11 Aug 2022 17:49:22 +0800 Subject: [PATCH 04/15] submodule update --- cmd/Open-IM-SDK-Core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/Open-IM-SDK-Core b/cmd/Open-IM-SDK-Core index 5e8d3f536..7ce9f1484 160000 --- a/cmd/Open-IM-SDK-Core +++ b/cmd/Open-IM-SDK-Core @@ -1 +1 @@ -Subproject commit 5e8d3f5366700f00db7db2905da27189b9353630 +Subproject commit 7ce9f14846f90b42777577774feb869f149da067 From 73118ce447b7e9934d9fe2c59c7176076749c66b Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Fri, 12 Aug 2022 21:49:54 +0800 Subject: [PATCH 05/15] config recover --- config/config.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index 7192bf255..998a486c5 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -46,9 +46,9 @@ kafka: ws2mschat: addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可 topic: "ws2ms_chat" #用于mongo和mysql保存消息 -# ws2mschatoffline: -# addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可 -# topic: "ws2ms_chat_offline" #原为离线用户消息处理,目前暂时弃用 + ws2mschatoffline: + addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可 + topic: "ws2ms_chat_offline" #原为离线用户消息处理,目前暂时弃用 msgtomongo: addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可 topic: "msg_to_mongo" @@ -63,6 +63,7 @@ kafka: + #---------------Internal service configuration---------------------# # The service ip default is empty, From 8cf7282f468f229046bcee3ad7a9889b1b14e969 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Wed, 24 Aug 2022 18:12:00 +0800 Subject: [PATCH 06/15] add version --- config/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.yaml b/config/config.yaml index 7236c9c32..5fbfe7492 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -2,7 +2,7 @@ # The class cannot be named by Pascal or camel case. # If it is not used, the corresponding structure will not be set, # and it will not be read naturally. -serverversion: 2.3.0 +serverversion: 2.3.1 #---------------Infrastructure configuration---------------------# etcd: etcdSchema: openim #默认即可 From 4001897338d4a1423330f5fb8c1ee331c27371c2 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Thu, 25 Aug 2022 14:02:18 +0800 Subject: [PATCH 07/15] compose file update --- docker-compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index aeac41995..115c49f9e 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -126,7 +126,7 @@ services: # STORE_PORT: 3306 open_im_server: - image: openim/open_im_server:v2.3.0 + image: openim/open_im_server:v2.3.1 container_name: open_im_server volumes: - ./logs:/Open-IM-Server/logs From 912da395c9bcf63ebf8821c4963fe461d0b116e1 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Fri, 9 Sep 2022 15:29:22 +0800 Subject: [PATCH 08/15] merge --- internal/msg_transfer/logic/persistent_msg_handler.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/msg_transfer/logic/persistent_msg_handler.go b/internal/msg_transfer/logic/persistent_msg_handler.go index 817b3edb9..61172128e 100644 --- a/internal/msg_transfer/logic/persistent_msg_handler.go +++ b/internal/msg_transfer/logic/persistent_msg_handler.go @@ -23,7 +23,11 @@ import ( ) var ( - msgInsertMysqlProcessed prometheus.Counter + // msgInsertMysqlProcessed perometheus.Countr + msgInsertMysqlProcessed = promauto.NewCounter(prometheus.CounterOpts{ + Name: "insert_mysql_msg_total", + Help: "The total number of msg insert mysql events", + }) ) type PersistentConsumerHandler struct { @@ -42,7 +46,6 @@ func (pc *PersistentConsumerHandler) Init() { Name: "insert_mysql_msg_total", Help: "The total number of msg insert mysql events", }) - prometheus.MustRegister(msgInsertMysqlProcessed) } } From 74c2bafc9b3ab5a4c62990b6b46a11a2353dbd87 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Fri, 9 Sep 2022 15:33:50 +0800 Subject: [PATCH 09/15] merge --- .../msg_transfer/logic/persistent_msg_handler.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/msg_transfer/logic/persistent_msg_handler.go b/internal/msg_transfer/logic/persistent_msg_handler.go index 61172128e..d40ee497b 100644 --- a/internal/msg_transfer/logic/persistent_msg_handler.go +++ b/internal/msg_transfer/logic/persistent_msg_handler.go @@ -41,12 +41,12 @@ func (pc *PersistentConsumerHandler) Init() { pc.persistentConsumerGroup = kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{KafkaVersion: sarama.V2_0_0_0, OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false}, []string{config.Config.Kafka.Ws2mschat.Topic}, config.Config.Kafka.Ws2mschat.Addr, config.Config.Kafka.ConsumerGroupID.MsgToMySql) - if config.Config.Prometheus.Enable { - msgInsertMysqlProcessed = promauto.NewCounter(prometheus.CounterOpts{ - Name: "insert_mysql_msg_total", - Help: "The total number of msg insert mysql events", - }) - } + // if config.Config.Prometheus.Enable { + // msgInsertMysqlProcessed = promauto.NewCounter(prometheus.CounterOpts{ + // Name: "insert_mysql_msg_total", + // Help: "The total number of msg insert mysql events", + // }) + // } } func (pc *PersistentConsumerHandler) handleChatWs2Mysql(cMsg *sarama.ConsumerMessage, msgKey string, _ sarama.ConsumerGroupSession) { From 98d7c7bb862b63f54ff83f665a9473d5cc795464 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Fri, 9 Sep 2022 15:52:47 +0800 Subject: [PATCH 10/15] Limit the number of group members for kick/create/invite --- cmd/open_im_api/main.go | 8 ++++---- internal/api/group/group.go | 15 ++++++++------- internal/api/user/user.go | 2 +- pkg/base_info/group_api_struct.go | 4 ++-- .../im_mysql_model/group_member_model.go | 2 -- pkg/utils/strings.go | 12 ++++++++++++ 6 files changed, 27 insertions(+), 16 deletions(-) diff --git a/cmd/open_im_api/main.go b/cmd/open_im_api/main.go index 1e3e0e1df..4edf037c4 100644 --- a/cmd/open_im_api/main.go +++ b/cmd/open_im_api/main.go @@ -54,7 +54,7 @@ func main() { { userRouterGroup.POST("/update_user_info", user.UpdateUserInfo) //1 userRouterGroup.POST("/set_global_msg_recv_opt", user.SetGlobalRecvMessageOpt) - userRouterGroup.POST("/get_users_info", user.GetUsersInfo) //1 + userRouterGroup.POST("/get_users_info", user.GetUsersPublicInfo) //1 userRouterGroup.POST("/get_self_user_info", user.GetSelfUserInfo) //1 userRouterGroup.POST("/get_users_online_status", user.GetUsersOnlineStatus) //1 userRouterGroup.POST("/get_users_info_from_cache", user.GetUsersInfoFromCache) @@ -95,9 +95,9 @@ func main() { groupRouterGroup.POST("/transfer_group", group.TransferGroupOwner) //1 groupRouterGroup.POST("/get_recv_group_applicationList", group.GetRecvGroupApplicationList) //1 groupRouterGroup.POST("/get_user_req_group_applicationList", group.GetUserReqGroupApplicationList) - groupRouterGroup.POST("/get_groups_info", group.GetGroupsInfo) //1 - groupRouterGroup.POST("/kick_group", group.KickGroupMember) //1 - groupRouterGroup.POST("/get_group_member_list", group.GetGroupMemberList) //no use + groupRouterGroup.POST("/get_groups_info", group.GetGroupsInfo) //1 + groupRouterGroup.POST("/kick_group", group.KickGroupMember) //1 + // groupRouterGroup.POST("/get_group_member_list", group.GetGroupMemberList) //no use groupRouterGroup.POST("/get_group_all_member_list", group.GetGroupAllMemberList) //1 groupRouterGroup.POST("/get_group_members_info", group.GetGroupMembersInfo) //1 groupRouterGroup.POST("/invite_user_to_group", group.InviteUserToGroup) //1 diff --git a/internal/api/group/group.go b/internal/api/group/group.go index ac8364d98..5c4427875 100644 --- a/internal/api/group/group.go +++ b/internal/api/group/group.go @@ -320,12 +320,7 @@ func InviteUserToGroup(c *gin.Context) { } req := &rpc.InviteUserToGroupReq{} utils.CopyStructFields(req, ¶ms) - if len(req.InvitedUserIDList) > constant.MaxNotificationNum { - errMsg := req.OperationID + " too many, Limit: " + utils.IntToString(constant.MaxNotificationNum) - log.NewError(req.OperationID, errMsg, len(req.InvitedUserIDList)) - c.JSON(http.StatusRequestEntityTooLarge, gin.H{"errCode": 400, "errMsg": errMsg}) - return - } + var ok bool var errInfo string ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID) @@ -385,7 +380,13 @@ func CreateGroup(c *gin.Context) { c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()}) return } - // + + if len(params.MemberList) > constant.MaxNotificationNum { + errMsg := params.OperationID + " too many members " + utils.Int32ToString(int32(len(params.MemberList))) + log.Error(params.OperationID, errMsg) + c.JSON(http.StatusOK, gin.H{"errCode": 400, "errMsg": errMsg}) + return + } req := &rpc.CreateGroupReq{GroupInfo: &open_im_sdk.GroupInfo{}} utils.CopyStructFields(req.GroupInfo, ¶ms) diff --git a/internal/api/user/user.go b/internal/api/user/user.go index 6876bda04..dff63db97 100644 --- a/internal/api/user/user.go +++ b/internal/api/user/user.go @@ -160,7 +160,7 @@ func GetBlackIDListFromCache(c *gin.Context) { // @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误" // @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等" // @Router /user/get_users_info [post] -func GetUsersInfo(c *gin.Context) { +func GetUsersPublicInfo(c *gin.Context) { params := api.GetUsersInfoReq{} if err := c.BindJSON(¶ms); err != nil { log.NewError("0", "BindJSON failed ", err.Error()) diff --git a/pkg/base_info/group_api_struct.go b/pkg/base_info/group_api_struct.go index 8f2eaccd4..f2703bba2 100644 --- a/pkg/base_info/group_api_struct.go +++ b/pkg/base_info/group_api_struct.go @@ -16,7 +16,7 @@ type CommDataResp struct { type KickGroupMemberReq struct { GroupID string `json:"groupID" binding:"required"` - KickedUserIDList []string `json:"kickedUserIDList" binding:"required"` + KickedUserIDList []string `json:"kickedUserIDList" binding:"required, min=1, max=100"` Reason string `json:"reason"` OperationID string `json:"operationID" binding:"required"` } @@ -38,7 +38,7 @@ type GetGroupMembersInfoResp struct { type InviteUserToGroupReq struct { GroupID string `json:"groupID" binding:"required"` - InvitedUserIDList []string `json:"invitedUserIDList" binding:"required"` + InvitedUserIDList []string `json:"invitedUserIDList" binding:"required, min=1, max=100"` Reason string `json:"reason"` OperationID string `json:"operationID" binding:"required"` } diff --git a/pkg/common/db/mysql_model/im_mysql_model/group_member_model.go b/pkg/common/db/mysql_model/im_mysql_model/group_member_model.go index 341094d5d..25131f6a5 100644 --- a/pkg/common/db/mysql_model/im_mysql_model/group_member_model.go +++ b/pkg/common/db/mysql_model/im_mysql_model/group_member_model.go @@ -35,8 +35,6 @@ func InsertIntoGroupMember(toInsertInfo db.GroupMember) error { } func BatchInsertIntoGroupMember(toInsertInfoList []*db.GroupMember) error { - //MessageList []*model_struct.LocalChatLog - //return utils.Wrap(d.conn.Create(MessageList).Error, "BatchInsertMessageList failed") for _, toInsertInfo := range toInsertInfoList { toInsertInfo.JoinTime = time.Now() if toInsertInfo.RoleLevel == 0 { diff --git a/pkg/utils/strings.go b/pkg/utils/strings.go index 5580f2838..203af2708 100644 --- a/pkg/utils/strings.go +++ b/pkg/utils/strings.go @@ -107,3 +107,15 @@ func int64ToString(i int64) string { func Int64ToString(i int64) string { return strconv.FormatInt(i, 10) } + +func RemoveDuplicateElement(idList []string) []string { + result := make([]string, 0, len(idList)) + temp := map[string]struct{}{} + for _, item := range idList { + if _, ok := temp[item]; !ok { + temp[item] = struct{}{} + result = append(result, item) + } + } + return result +} From 98dde67f65dba1613ef95dce706a54e2a6636f7a Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Fri, 9 Sep 2022 16:26:57 +0800 Subject: [PATCH 11/15] v2.3.2 --- docker-compose.yaml | 2 +- internal/msg_transfer/logic/init.go | 5 ++--- .../logic/persistent_msg_handler.go | 18 +++++++----------- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 5b2c15712..81697ebb6 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -115,7 +115,7 @@ services: open_im_server: - image: openim/open_im_server:v2.3.1 + image: openim/open_im_server:v2.3.2 container_name: open_im_server volumes: - ./logs:/Open-IM-Server/logs diff --git a/internal/msg_transfer/logic/init.go b/internal/msg_transfer/logic/init.go index e5ad296ff..6b26ade63 100644 --- a/internal/msg_transfer/logic/init.go +++ b/internal/msg_transfer/logic/init.go @@ -40,9 +40,8 @@ var ( func Init() { cmdCh = make(chan Cmd2Value, 10000) w = new(sync.Mutex) - persistentCH.Init() // 订阅ws2mschat 消费到 mysql - historyCH.Init(cmdCh) // 订阅ws2mschat 如果可靠性存储 消费到 incrseq 再存入mongo 再push || 非可靠性 直接incr再push 初始化ws2mschat - historyMongoCH.Init() + persistentCH.Init() // ws2mschat save mysql + historyCH.Init(cmdCh) // onlineTopicStatus = OnlineTopicVacancy //offlineHistoryCH.Init(cmdCh) statistics.NewStatistics(&singleMsgSuccessCount, config.Config.ModuleName.MsgTransferName, fmt.Sprintf("%d second singleMsgCount insert to mongo", constant.StatisticsTimeInterval), constant.StatisticsTimeInterval) diff --git a/internal/msg_transfer/logic/persistent_msg_handler.go b/internal/msg_transfer/logic/persistent_msg_handler.go index d40ee497b..c02c02739 100644 --- a/internal/msg_transfer/logic/persistent_msg_handler.go +++ b/internal/msg_transfer/logic/persistent_msg_handler.go @@ -23,11 +23,7 @@ import ( ) var ( - // msgInsertMysqlProcessed perometheus.Countr - msgInsertMysqlProcessed = promauto.NewCounter(prometheus.CounterOpts{ - Name: "insert_mysql_msg_total", - Help: "The total number of msg insert mysql events", - }) + msgInsertMysqlProcessed prometheus.Counter ) type PersistentConsumerHandler struct { @@ -41,12 +37,12 @@ func (pc *PersistentConsumerHandler) Init() { pc.persistentConsumerGroup = kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{KafkaVersion: sarama.V2_0_0_0, OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false}, []string{config.Config.Kafka.Ws2mschat.Topic}, config.Config.Kafka.Ws2mschat.Addr, config.Config.Kafka.ConsumerGroupID.MsgToMySql) - // if config.Config.Prometheus.Enable { - // msgInsertMysqlProcessed = promauto.NewCounter(prometheus.CounterOpts{ - // Name: "insert_mysql_msg_total", - // Help: "The total number of msg insert mysql events", - // }) - // } + if config.Config.Prometheus.Enable { + msgInsertMysqlProcessed = promauto.NewCounter(prometheus.CounterOpts{ + Name: "insert_mysql_msg_total", + Help: "The total number of msg insert mysql events", + }) + } } func (pc *PersistentConsumerHandler) handleChatWs2Mysql(cMsg *sarama.ConsumerMessage, msgKey string, _ sarama.ConsumerGroupSession) { From 9130881875a15594563b9ed1c0cf253a8e470e83 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Fri, 9 Sep 2022 16:53:07 +0800 Subject: [PATCH 12/15] promethues --- internal/msg_transfer/logic/persistent_msg_handler.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/msg_transfer/logic/persistent_msg_handler.go b/internal/msg_transfer/logic/persistent_msg_handler.go index c02c02739..2f61b88cf 100644 --- a/internal/msg_transfer/logic/persistent_msg_handler.go +++ b/internal/msg_transfer/logic/persistent_msg_handler.go @@ -78,8 +78,9 @@ func (pc *PersistentConsumerHandler) handleChatWs2Mysql(cMsg *sarama.ConsumerMes log.NewError(msgFromMQ.OperationID, "Message insert failed", "err", err.Error(), "msg", msgFromMQ.String()) return } + msgInsertMysqlProcessed.Add(1) if config.Config.Prometheus.Enable { - log.NewDebug(msgFromMQ.OperationID, utils.GetSelfFuncName(), "inc msgInsertMysqlProcessed") + log.NewDebug(msgFromMQ.OperationID, utils.GetSelfFuncName(), "inc msgInsertMysqlProcessed", msgInsertMysqlProcessed.Desc()) msgInsertMysqlProcessed.Inc() } } From ea38953b475183b0ecbab1a8538a1516a8773166 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Fri, 9 Sep 2022 17:00:07 +0800 Subject: [PATCH 13/15] promethues --- internal/msg_transfer/logic/persistent_msg_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/msg_transfer/logic/persistent_msg_handler.go b/internal/msg_transfer/logic/persistent_msg_handler.go index 2f61b88cf..d67c62c41 100644 --- a/internal/msg_transfer/logic/persistent_msg_handler.go +++ b/internal/msg_transfer/logic/persistent_msg_handler.go @@ -78,7 +78,7 @@ func (pc *PersistentConsumerHandler) handleChatWs2Mysql(cMsg *sarama.ConsumerMes log.NewError(msgFromMQ.OperationID, "Message insert failed", "err", err.Error(), "msg", msgFromMQ.String()) return } - msgInsertMysqlProcessed.Add(1) + msgInsertMysqlProcessed.Inc() if config.Config.Prometheus.Enable { log.NewDebug(msgFromMQ.OperationID, utils.GetSelfFuncName(), "inc msgInsertMysqlProcessed", msgInsertMysqlProcessed.Desc()) msgInsertMysqlProcessed.Inc() From 189d5aed698ae957b5d3a4fe8ba185418701c49d Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Fri, 9 Sep 2022 17:02:23 +0800 Subject: [PATCH 14/15] promethues --- internal/msg_transfer/logic/persistent_msg_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/msg_transfer/logic/persistent_msg_handler.go b/internal/msg_transfer/logic/persistent_msg_handler.go index d67c62c41..9c7fd38ad 100644 --- a/internal/msg_transfer/logic/persistent_msg_handler.go +++ b/internal/msg_transfer/logic/persistent_msg_handler.go @@ -80,7 +80,7 @@ func (pc *PersistentConsumerHandler) handleChatWs2Mysql(cMsg *sarama.ConsumerMes } msgInsertMysqlProcessed.Inc() if config.Config.Prometheus.Enable { - log.NewDebug(msgFromMQ.OperationID, utils.GetSelfFuncName(), "inc msgInsertMysqlProcessed", msgInsertMysqlProcessed.Desc()) + log.NewDebug(msgFromMQ.OperationID, utils.GetSelfFuncName(), "inc msgInsertMysqlProcessed") msgInsertMysqlProcessed.Inc() } } From 692cebe6598e4bbbebf346b2652cf095ac069343 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Fri, 9 Sep 2022 17:17:10 +0800 Subject: [PATCH 15/15] rpome --- internal/msg_transfer/logic/init.go | 1 + internal/msg_transfer/logic/persistent_msg_handler.go | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/msg_transfer/logic/init.go b/internal/msg_transfer/logic/init.go index 6b26ade63..0a80d155c 100644 --- a/internal/msg_transfer/logic/init.go +++ b/internal/msg_transfer/logic/init.go @@ -42,6 +42,7 @@ func Init() { w = new(sync.Mutex) persistentCH.Init() // ws2mschat save mysql historyCH.Init(cmdCh) // + historyMongoCH.Init() onlineTopicStatus = OnlineTopicVacancy //offlineHistoryCH.Init(cmdCh) statistics.NewStatistics(&singleMsgSuccessCount, config.Config.ModuleName.MsgTransferName, fmt.Sprintf("%d second singleMsgCount insert to mongo", constant.StatisticsTimeInterval), constant.StatisticsTimeInterval) diff --git a/internal/msg_transfer/logic/persistent_msg_handler.go b/internal/msg_transfer/logic/persistent_msg_handler.go index 9c7fd38ad..7b45e9234 100644 --- a/internal/msg_transfer/logic/persistent_msg_handler.go +++ b/internal/msg_transfer/logic/persistent_msg_handler.go @@ -79,8 +79,9 @@ func (pc *PersistentConsumerHandler) handleChatWs2Mysql(cMsg *sarama.ConsumerMes return } msgInsertMysqlProcessed.Inc() + msgInsertMysqlProcessed.Add(1) if config.Config.Prometheus.Enable { - log.NewDebug(msgFromMQ.OperationID, utils.GetSelfFuncName(), "inc msgInsertMysqlProcessed") + log.NewDebug(msgFromMQ.OperationID, utils.GetSelfFuncName(), "inc msgInsertMysqlProcessed", msgInsertMysqlProcessed.Desc()) msgInsertMysqlProcessed.Inc() } }