From 9929bd3ce5b93c6669114e3468d602a61d3d21d0 Mon Sep 17 00:00:00 2001 From: icey-yu <119291641+icey-yu@users.noreply.github.com> Date: Wed, 18 Dec 2024 10:45:45 +0800 Subject: [PATCH] feat: Group Monitoring Components, Enable Host Mode && Deprecate reliabilityLevel and unreadCount in notification.yml (#2975) * chore: docker config * chore: docker config * feat: Group Monitoring Components, Enable Host Mode && Deprecate reliabilityLevel and unreadCount in notification.yml * feat: Group Monitoring Components, Enable Host Mode && Deprecate reliabilityLevel and unreadCount in notification.yml * feat: Group Monitoring Components, Enable Host Mode && Deprecate reliabilityLevel and unreadCount in notification.yml * feat: cicd --- .env | 4 ++ .github/workflows/go-build-test.yml | 4 +- config/notification.yml | 6 +-- config/openim-api.yml | 2 +- config/prometheus.yml | 54 +++++++++++----------- config/share.yml | 10 ----- docker-compose.yml | 26 ++++++----- internal/msggateway/hub_server.go | 2 +- pkg/common/cmd/auth.go | 2 +- pkg/common/cmd/conversation.go | 2 +- pkg/common/cmd/friend.go | 2 +- pkg/common/cmd/group.go | 2 +- pkg/common/cmd/msg.go | 2 +- pkg/common/cmd/push.go | 2 +- pkg/common/cmd/third.go | 2 +- pkg/common/cmd/user.go | 2 +- pkg/common/config/config.go | 69 +++++++++++++++++++++++++++++ pkg/common/config/parse.go | 2 +- pkg/common/startrpc/start.go | 9 +++- 19 files changed, 136 insertions(+), 68 deletions(-) diff --git a/.env b/.env index 87f4badbac..4a39255b80 100644 --- a/.env +++ b/.env @@ -15,3 +15,7 @@ OPENIM_ADMIN_FRONT_IMAGE=openim/openim-admin-front:release-v1.8.3 #OPENIM_ADMIN_FRONT_IMAGE=registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-admin-front:release-v1.8.3 DATA_DIR=./ + +PROMETHEUS_PORT=19091 +ALERTMANAGER_PORT=19093 +GRAFANA_PORT=13000 \ No newline at end of file diff --git a/.github/workflows/go-build-test.yml b/.github/workflows/go-build-test.yml index 2ca960cc9b..10a4154d61 100644 --- a/.github/workflows/go-build-test.yml +++ b/.github/workflows/go-build-test.yml @@ -126,8 +126,8 @@ jobs: - name: Modify Server Configuration run: | - yq e '.groupCreated.unreadCount = true' -i ${{ env.CONFIG_PATH }} - yq e '.friendApplicationApproved.unreadCount = true' -i ${{ env.CONFIG_PATH }} + yq e '.groupCreated.isSendMsg = true' -i ${{ env.CONFIG_PATH }} + yq e '.friendApplicationApproved.isSendMsg = true' -i ${{ env.CONFIG_PATH }} - name: Start Server Services run: | diff --git a/config/notification.yml b/config/notification.yml index ba5ca1c21a..c3ae015390 100644 --- a/config/notification.yml +++ b/config/notification.yml @@ -1,10 +1,8 @@ groupCreated: isSendMsg: true -# Reliability level of the message sending. -# Set to 1 to send only when online, 2 for guaranteed delivery. +# Deprecated. Fixed as 1. reliabilityLevel: 1 -# This setting is effective only when 'isSendMsg' is true. -# It controls whether to count unread messages. +# Deprecated. Fixed as false. unreadCount: false # Configuration for offline push notifications. offlinePush: diff --git a/config/openim-api.yml b/config/openim-api.yml index a23b5fb314..f063005ec5 100644 --- a/config/openim-api.yml +++ b/config/openim-api.yml @@ -16,4 +16,4 @@ prometheus: # It will only take effect when autoSetPorts is set to false. ports: [ 12002 ] # This address can be accessed via a browser - grafanaURL: http://127.0.0.1:13000/ + grafanaURL: diff --git a/config/prometheus.yml b/config/prometheus.yml index 6fb1128249..d176bfcbd8 100644 --- a/config/prometheus.yml +++ b/config/prometheus.yml @@ -8,7 +8,7 @@ global: alerting: alertmanagers: - static_configs: - - targets: [internal_ip:19093] + - targets: [127.0.0.1:19093] # Load rules once and periodically evaluate them according to the global evaluation_interval. rule_files: @@ -25,95 +25,95 @@ scrape_configs: # prometheus fetches application services - job_name: node_exporter static_configs: - - targets: [ internal_ip:20500 ] + - targets: [ 127.0.0.1:20500 ] - job_name: openimserver-openim-api http_sd_configs: - - url: "http://internal_ip:10002/prometheus_discovery/api" + - url: "http://127.0.0.1:10002/prometheus_discovery/api" # static_configs: -# - targets: [ internal_ip:12002 ] +# - targets: [ 127.0.0.1:12002 ] # labels: # namespace: default - job_name: openimserver-openim-msggateway http_sd_configs: - - url: "http://internal_ip:10002/prometheus_discovery/msg_gateway" + - url: "http://127.0.0.1:10002/prometheus_discovery/msg_gateway" # static_configs: -# - targets: [ internal_ip:12140 ] -# # - targets: [ internal_ip:12140, internal_ip:12141, internal_ip:12142, internal_ip:12143, internal_ip:12144, internal_ip:12145, internal_ip:12146, internal_ip:12147, internal_ip:12148, internal_ip:12149, internal_ip:12150, internal_ip:12151, internal_ip:12152, internal_ip:12153, internal_ip:12154, internal_ip:12155 ] +# - targets: [ 127.0.0.1:12140 ] +# # - targets: [ 127.0.0.1:12140, 127.0.0.1:12141, 127.0.0.1:12142, 127.0.0.1:12143, 127.0.0.1:12144, 127.0.0.1:12145, 127.0.0.1:12146, 127.0.0.1:12147, 127.0.0.1:12148, 127.0.0.1:12149, 127.0.0.1:12150, 127.0.0.1:12151, 127.0.0.1:12152, 127.0.0.1:12153, 127.0.0.1:12154, 127.0.0.1:12155 ] # labels: # namespace: default - job_name: openimserver-openim-msgtransfer http_sd_configs: - - url: "http://internal_ip:10002/prometheus_discovery/msg_transfer" + - url: "http://127.0.0.1:10002/prometheus_discovery/msg_transfer" # static_configs: -# - targets: [ internal_ip:12020, internal_ip:12021, internal_ip:12022, internal_ip:12023, internal_ip:12024, internal_ip:12025, internal_ip:12026, internal_ip:12027 ] -# # - targets: [ internal_ip:12020, internal_ip:12021, internal_ip:12022, internal_ip:12023, internal_ip:12024, internal_ip:12025, internal_ip:12026, internal_ip:12027, internal_ip:12028, internal_ip:12029, internal_ip:12030, internal_ip:12031, internal_ip:12032, internal_ip:12033, internal_ip:12034, internal_ip:12035 ] +# - targets: [ 127.0.0.1:12020, 127.0.0.1:12021, 127.0.0.1:12022, 127.0.0.1:12023, 127.0.0.1:12024, 127.0.0.1:12025, 127.0.0.1:12026, 127.0.0.1:12027 ] +# # - targets: [ 127.0.0.1:12020, 127.0.0.1:12021, 127.0.0.1:12022, 127.0.0.1:12023, 127.0.0.1:12024, 127.0.0.1:12025, 127.0.0.1:12026, 127.0.0.1:12027, 127.0.0.1:12028, 127.0.0.1:12029, 127.0.0.1:12030, 127.0.0.1:12031, 127.0.0.1:12032, 127.0.0.1:12033, 127.0.0.1:12034, 127.0.0.1:12035 ] # labels: # namespace: default - job_name: openimserver-openim-push http_sd_configs: - - url: "http://internal_ip:10002/prometheus_discovery/push" + - url: "http://127.0.0.1:10002/prometheus_discovery/push" # static_configs: -# - targets: [ internal_ip:12170, internal_ip:12171, internal_ip:12172, internal_ip:12173, internal_ip:12174, internal_ip:12175, internal_ip:12176, internal_ip:12177 ] -## - targets: [ internal_ip:12170, internal_ip:12171, internal_ip:12172, internal_ip:12173, internal_ip:12174, internal_ip:12175, internal_ip:12176, internal_ip:12177, internal_ip:12178, internal_ip:12179, internal_ip:12180, internal_ip:12182, internal_ip:12183, internal_ip:12184, internal_ip:12185, internal_ip:12186 ] +# - targets: [ 127.0.0.1:12170, 127.0.0.1:12171, 127.0.0.1:12172, 127.0.0.1:12173, 127.0.0.1:12174, 127.0.0.1:12175, 127.0.0.1:12176, 127.0.0.1:12177 ] +## - targets: [ 127.0.0.1:12170, 127.0.0.1:12171, 127.0.0.1:12172, 127.0.0.1:12173, 127.0.0.1:12174, 127.0.0.1:12175, 127.0.0.1:12176, 127.0.0.1:12177, 127.0.0.1:12178, 127.0.0.1:12179, 127.0.0.1:12180, 127.0.0.1:12182, 127.0.0.1:12183, 127.0.0.1:12184, 127.0.0.1:12185, 127.0.0.1:12186 ] # labels: # namespace: default - job_name: openimserver-openim-rpc-auth http_sd_configs: - - url: "http://internal_ip:10002/prometheus_discovery/auth" + - url: "http://127.0.0.1:10002/prometheus_discovery/auth" # static_configs: -# - targets: [ internal_ip:12200 ] +# - targets: [ 127.0.0.1:12200 ] # labels: # namespace: default - job_name: openimserver-openim-rpc-conversation http_sd_configs: - - url: "http://internal_ip:10002/prometheus_discovery/conversation" + - url: "http://127.0.0.1:10002/prometheus_discovery/conversation" # static_configs: -# - targets: [ internal_ip:12220 ] +# - targets: [ 127.0.0.1:12220 ] # labels: # namespace: default - job_name: openimserver-openim-rpc-friend http_sd_configs: - - url: "http://internal_ip:10002/prometheus_discovery/friend" + - url: "http://127.0.0.1:10002/prometheus_discovery/friend" # static_configs: -# - targets: [ internal_ip:12240 ] +# - targets: [ 127.0.0.1:12240 ] # labels: # namespace: default - job_name: openimserver-openim-rpc-group http_sd_configs: - - url: "http://internal_ip:10002/prometheus_discovery/group" + - url: "http://127.0.0.1:10002/prometheus_discovery/group" # static_configs: -# - targets: [ internal_ip:12260 ] +# - targets: [ 127.0.0.1:12260 ] # labels: # namespace: default. - job_name: openimserver-openim-rpc-msg http_sd_configs: - - url: "http://internal_ip:10002/prometheus_discovery/msg" + - url: "http://127.0.0.1:10002/prometheus_discovery/msg" # static_configs: -# - targets: [ internal_ip:12280 ] +# - targets: [ 127.0.0.1:12280 ] # labels: # namespace: default - job_name: openimserver-openim-rpc-third http_sd_configs: - - url: "http://internal_ip:10002/prometheus_discovery/third" + - url: "http://127.0.0.1:10002/prometheus_discovery/third" # static_configs: -# - targets: [ internal_ip:12300 ] +# - targets: [ 127.0.0.1:12300 ] # labels: # namespace: default - job_name: openimserver-openim-rpc-user http_sd_configs: - - url: "http://internal_ip:10002/prometheus_discovery/user" + - url: "http://127.0.0.1:10002/prometheus_discovery/user" # static_configs: -# - targets: [ internal_ip:12320 ] +# - targets: [ 127.0.0.1:12320 ] # labels: # namespace: default \ No newline at end of file diff --git a/config/share.yml b/config/share.yml index 1726af2dc8..0ed59f2cde 100644 --- a/config/share.yml +++ b/config/share.yml @@ -1,14 +1,4 @@ secret: openIM123 -rpcRegisterName: - user: user - friend: friend - msg: msg - push: push - messageGateway: messageGateway - group: group - auth: auth - conversation: conversation - third: third imAdminUserID: [ imAdmin ] diff --git a/docker-compose.yml b/docker-compose.yml index 57e6542082..4334790e19 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -151,6 +151,8 @@ services: container_name: prometheus restart: always user: root + profiles: + - m volumes: - ./config/prometheus.yml:/etc/prometheus/prometheus.yml - ./config/instance-down-rules.yml:/etc/prometheus/instance-down-rules.yml @@ -158,37 +160,37 @@ services: command: - '--config.file=/etc/prometheus/prometheus.yml' - '--storage.tsdb.path=/prometheus' - ports: - - "19091:9090" - networks: - - openim + - '--web.listen-address=:${PROMETHEUS_PORT}' + network_mode: host alertmanager: image: ${ALERTMANAGER_IMAGE} container_name: alertmanager restart: always + profiles: + - m volumes: - ./config/alertmanager.yml:/etc/alertmanager/alertmanager.yml - ./config/email.tmpl:/etc/alertmanager/email.tmpl - ports: - - "19093:9093" - networks: - - openim + command: + - '--config.file=/etc/alertmanager/alertmanager.yml' + - '--web.listen-address=:${ALERTMANAGER_PORT}' + network_mode: host grafana: image: ${GRAFANA_IMAGE} container_name: grafana user: root restart: always + profiles: + - m environment: - GF_SECURITY_ALLOW_EMBEDDING=true - GF_SESSION_COOKIE_SAMESITE=none - GF_SESSION_COOKIE_SECURE=true - GF_AUTH_ANONYMOUS_ENABLED=true - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin - ports: - - "13000:3000" + - GF_SERVER_HTTP_PORT=${GRAFANA_PORT} volumes: - ${DATA_DIR:-./}/components/grafana:/var/lib/grafana - networks: - - openim + network_mode: host diff --git a/internal/msggateway/hub_server.go b/internal/msggateway/hub_server.go index 5c9237ed14..f6c12350c9 100644 --- a/internal/msggateway/hub_server.go +++ b/internal/msggateway/hub_server.go @@ -47,7 +47,7 @@ func (s *Server) Start(ctx context.Context, index int, conf *Config) error { conf.MsgGateway.RPC.RegisterIP, conf.MsgGateway.RPC.AutoSetPorts, conf.MsgGateway.RPC.Ports, index, conf.Discovery.RpcService.MessageGateway, - &conf.Share, + nil, conf, s.InitServer, ) diff --git a/pkg/common/cmd/auth.go b/pkg/common/cmd/auth.go index 80a675ace5..bf51a2cf3c 100644 --- a/pkg/common/cmd/auth.go +++ b/pkg/common/cmd/auth.go @@ -56,5 +56,5 @@ func (a *AuthRpcCmd) Exec() error { func (a *AuthRpcCmd) runE() error { return startrpc.Start(a.ctx, &a.authConfig.Discovery, &a.authConfig.RpcConfig.Prometheus, a.authConfig.RpcConfig.RPC.ListenIP, a.authConfig.RpcConfig.RPC.RegisterIP, a.authConfig.RpcConfig.RPC.AutoSetPorts, a.authConfig.RpcConfig.RPC.Ports, - a.Index(), a.authConfig.Discovery.RpcService.Auth, &a.authConfig.Share, a.authConfig, auth.Start) + a.Index(), a.authConfig.Discovery.RpcService.Auth, nil, a.authConfig, auth.Start) } diff --git a/pkg/common/cmd/conversation.go b/pkg/common/cmd/conversation.go index 72fa694ed7..4d38f7fd47 100644 --- a/pkg/common/cmd/conversation.go +++ b/pkg/common/cmd/conversation.go @@ -58,5 +58,5 @@ func (a *ConversationRpcCmd) Exec() error { func (a *ConversationRpcCmd) runE() error { return startrpc.Start(a.ctx, &a.conversationConfig.Discovery, &a.conversationConfig.RpcConfig.Prometheus, a.conversationConfig.RpcConfig.RPC.ListenIP, a.conversationConfig.RpcConfig.RPC.RegisterIP, a.conversationConfig.RpcConfig.RPC.AutoSetPorts, a.conversationConfig.RpcConfig.RPC.Ports, - a.Index(), a.conversationConfig.Discovery.RpcService.Conversation, &a.conversationConfig.Share, a.conversationConfig, conversation.Start) + a.Index(), a.conversationConfig.Discovery.RpcService.Conversation, &a.conversationConfig.NotificationConfig, a.conversationConfig, conversation.Start) } diff --git a/pkg/common/cmd/friend.go b/pkg/common/cmd/friend.go index b40449b2b9..8001165318 100644 --- a/pkg/common/cmd/friend.go +++ b/pkg/common/cmd/friend.go @@ -59,5 +59,5 @@ func (a *FriendRpcCmd) Exec() error { func (a *FriendRpcCmd) runE() error { return startrpc.Start(a.ctx, &a.relationConfig.Discovery, &a.relationConfig.RpcConfig.Prometheus, a.relationConfig.RpcConfig.RPC.ListenIP, a.relationConfig.RpcConfig.RPC.RegisterIP, a.relationConfig.RpcConfig.RPC.AutoSetPorts, a.relationConfig.RpcConfig.RPC.Ports, - a.Index(), a.relationConfig.Discovery.RpcService.Friend, &a.relationConfig.Share, a.relationConfig, relation.Start) + a.Index(), a.relationConfig.Discovery.RpcService.Friend, &a.relationConfig.NotificationConfig, a.relationConfig, relation.Start) } diff --git a/pkg/common/cmd/group.go b/pkg/common/cmd/group.go index faed56233f..4f8d17516a 100644 --- a/pkg/common/cmd/group.go +++ b/pkg/common/cmd/group.go @@ -60,5 +60,5 @@ func (a *GroupRpcCmd) Exec() error { func (a *GroupRpcCmd) runE() error { return startrpc.Start(a.ctx, &a.groupConfig.Discovery, &a.groupConfig.RpcConfig.Prometheus, a.groupConfig.RpcConfig.RPC.ListenIP, a.groupConfig.RpcConfig.RPC.RegisterIP, a.groupConfig.RpcConfig.RPC.AutoSetPorts, a.groupConfig.RpcConfig.RPC.Ports, - a.Index(), a.groupConfig.Discovery.RpcService.Group, &a.groupConfig.Share, a.groupConfig, group.Start, versionctx.EnableVersionCtx()) + a.Index(), a.groupConfig.Discovery.RpcService.Group, &a.groupConfig.NotificationConfig, a.groupConfig, group.Start, versionctx.EnableVersionCtx()) } diff --git a/pkg/common/cmd/msg.go b/pkg/common/cmd/msg.go index 962d1468ad..b6647f9c10 100644 --- a/pkg/common/cmd/msg.go +++ b/pkg/common/cmd/msg.go @@ -60,5 +60,5 @@ func (a *MsgRpcCmd) Exec() error { func (a *MsgRpcCmd) runE() error { return startrpc.Start(a.ctx, &a.msgConfig.Discovery, &a.msgConfig.RpcConfig.Prometheus, a.msgConfig.RpcConfig.RPC.ListenIP, a.msgConfig.RpcConfig.RPC.RegisterIP, a.msgConfig.RpcConfig.RPC.AutoSetPorts, a.msgConfig.RpcConfig.RPC.Ports, - a.Index(), a.msgConfig.Discovery.RpcService.Msg, &a.msgConfig.Share, a.msgConfig, msg.Start) + a.Index(), a.msgConfig.Discovery.RpcService.Msg, &a.msgConfig.NotificationConfig, a.msgConfig, msg.Start) } diff --git a/pkg/common/cmd/push.go b/pkg/common/cmd/push.go index 09883fc34a..93b502cd84 100644 --- a/pkg/common/cmd/push.go +++ b/pkg/common/cmd/push.go @@ -60,5 +60,5 @@ func (a *PushRpcCmd) Exec() error { func (a *PushRpcCmd) runE() error { return startrpc.Start(a.ctx, &a.pushConfig.Discovery, &a.pushConfig.RpcConfig.Prometheus, a.pushConfig.RpcConfig.RPC.ListenIP, a.pushConfig.RpcConfig.RPC.RegisterIP, a.pushConfig.RpcConfig.RPC.AutoSetPorts, a.pushConfig.RpcConfig.RPC.Ports, - a.Index(), a.pushConfig.Discovery.RpcService.Push, &a.pushConfig.Share, a.pushConfig, push.Start) + a.Index(), a.pushConfig.Discovery.RpcService.Push, &a.pushConfig.NotificationConfig, a.pushConfig, push.Start) } diff --git a/pkg/common/cmd/third.go b/pkg/common/cmd/third.go index 8e9ffb9bdf..e43f61732b 100644 --- a/pkg/common/cmd/third.go +++ b/pkg/common/cmd/third.go @@ -59,5 +59,5 @@ func (a *ThirdRpcCmd) Exec() error { func (a *ThirdRpcCmd) runE() error { return startrpc.Start(a.ctx, &a.thirdConfig.Discovery, &a.thirdConfig.RpcConfig.Prometheus, a.thirdConfig.RpcConfig.RPC.ListenIP, a.thirdConfig.RpcConfig.RPC.RegisterIP, a.thirdConfig.RpcConfig.RPC.AutoSetPorts, a.thirdConfig.RpcConfig.RPC.Ports, - a.Index(), a.thirdConfig.Discovery.RpcService.Third, &a.thirdConfig.Share, a.thirdConfig, third.Start) + a.Index(), a.thirdConfig.Discovery.RpcService.Third, &a.thirdConfig.NotificationConfig, a.thirdConfig, third.Start) } diff --git a/pkg/common/cmd/user.go b/pkg/common/cmd/user.go index 40f372770c..dc848a7758 100644 --- a/pkg/common/cmd/user.go +++ b/pkg/common/cmd/user.go @@ -60,5 +60,5 @@ func (a *UserRpcCmd) Exec() error { func (a *UserRpcCmd) runE() error { return startrpc.Start(a.ctx, &a.userConfig.Discovery, &a.userConfig.RpcConfig.Prometheus, a.userConfig.RpcConfig.RPC.ListenIP, a.userConfig.RpcConfig.RPC.RegisterIP, a.userConfig.RpcConfig.RPC.AutoSetPorts, a.userConfig.RpcConfig.RPC.Ports, - a.Index(), a.userConfig.Discovery.RpcService.User, &a.userConfig.Share, a.userConfig, user.Start) + a.Index(), a.userConfig.Discovery.RpcService.User, &a.userConfig.NotificationConfig, a.userConfig, user.Start) } diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go index 25748a6187..da11a20e72 100644 --- a/pkg/common/config/config.go +++ b/pkg/common/config/config.go @@ -610,3 +610,72 @@ func (l *CacheConfig) Success() time.Duration { func (l *CacheConfig) Enable() bool { return l.Topic != "" && l.SlotNum > 0 && l.SlotSize > 0 } + +func InitNotification(notification *Notification) { + notification.GroupCreated.UnreadCount = false + notification.GroupCreated.ReliabilityLevel = 1 + notification.GroupInfoSet.UnreadCount = false + notification.GroupInfoSet.ReliabilityLevel = 1 + notification.JoinGroupApplication.UnreadCount = false + notification.JoinGroupApplication.ReliabilityLevel = 1 + notification.MemberQuit.UnreadCount = false + notification.MemberQuit.ReliabilityLevel = 1 + notification.GroupApplicationAccepted.UnreadCount = false + notification.GroupApplicationAccepted.ReliabilityLevel = 1 + notification.GroupApplicationRejected.UnreadCount = false + notification.GroupApplicationRejected.ReliabilityLevel = 1 + notification.GroupOwnerTransferred.UnreadCount = false + notification.GroupOwnerTransferred.ReliabilityLevel = 1 + notification.MemberKicked.UnreadCount = false + notification.MemberKicked.ReliabilityLevel = 1 + notification.MemberInvited.UnreadCount = false + notification.MemberInvited.ReliabilityLevel = 1 + notification.MemberEnter.UnreadCount = false + notification.MemberEnter.ReliabilityLevel = 1 + notification.GroupDismissed.UnreadCount = false + notification.GroupDismissed.ReliabilityLevel = 1 + notification.GroupMuted.UnreadCount = false + notification.GroupMuted.ReliabilityLevel = 1 + notification.GroupCancelMuted.UnreadCount = false + notification.GroupCancelMuted.ReliabilityLevel = 1 + notification.GroupMemberMuted.UnreadCount = false + notification.GroupMemberMuted.ReliabilityLevel = 1 + notification.GroupMemberCancelMuted.UnreadCount = false + notification.GroupMemberCancelMuted.ReliabilityLevel = 1 + notification.GroupMemberInfoSet.UnreadCount = false + notification.GroupMemberInfoSet.ReliabilityLevel = 1 + notification.GroupMemberSetToAdmin.UnreadCount = false + notification.GroupMemberSetToAdmin.ReliabilityLevel = 1 + notification.GroupMemberSetToOrdinary.UnreadCount = false + notification.GroupMemberSetToOrdinary.ReliabilityLevel = 1 + notification.GroupInfoSetAnnouncement.UnreadCount = false + notification.GroupInfoSetAnnouncement.ReliabilityLevel = 1 + notification.GroupInfoSetName.UnreadCount = false + notification.GroupInfoSetName.ReliabilityLevel = 1 + notification.FriendApplicationAdded.UnreadCount = false + notification.FriendApplicationAdded.ReliabilityLevel = 1 + notification.FriendApplicationApproved.UnreadCount = false + notification.FriendApplicationApproved.ReliabilityLevel = 1 + notification.FriendApplicationRejected.UnreadCount = false + notification.FriendApplicationRejected.ReliabilityLevel = 1 + notification.FriendAdded.UnreadCount = false + notification.FriendAdded.ReliabilityLevel = 1 + notification.FriendDeleted.UnreadCount = false + notification.FriendDeleted.ReliabilityLevel = 1 + notification.FriendRemarkSet.UnreadCount = false + notification.FriendRemarkSet.ReliabilityLevel = 1 + notification.BlackAdded.UnreadCount = false + notification.BlackAdded.ReliabilityLevel = 1 + notification.BlackDeleted.UnreadCount = false + notification.BlackDeleted.ReliabilityLevel = 1 + notification.FriendInfoUpdated.UnreadCount = false + notification.FriendInfoUpdated.ReliabilityLevel = 1 + notification.UserInfoUpdated.UnreadCount = false + notification.UserInfoUpdated.ReliabilityLevel = 1 + notification.UserStatusChanged.UnreadCount = false + notification.UserStatusChanged.ReliabilityLevel = 1 + notification.ConversationChanged.UnreadCount = false + notification.ConversationChanged.ReliabilityLevel = 1 + notification.ConversationSetPrivate.UnreadCount = false + notification.ConversationSetPrivate.ReliabilityLevel = 1 +} diff --git a/pkg/common/config/parse.go b/pkg/common/config/parse.go index 08f82ac7d3..ea62c1de0c 100644 --- a/pkg/common/config/parse.go +++ b/pkg/common/config/parse.go @@ -61,7 +61,7 @@ func GetProjectRoot() (string, error) { func GetOptionsByNotification(cfg NotificationConfig) msgprocessor.Options { opts := msgprocessor.NewOptions() - if cfg.UnreadCount { + if cfg.IsSendMsg { opts = msgprocessor.WithOptions(opts, msgprocessor.WithUnreadCount(true)) } if cfg.OfflinePush.Enable { diff --git a/pkg/common/startrpc/start.go b/pkg/common/startrpc/start.go index c38ee27a14..089bc3d979 100644 --- a/pkg/common/startrpc/start.go +++ b/pkg/common/startrpc/start.go @@ -48,8 +48,9 @@ import ( // Start rpc server. func Start[T any](ctx context.Context, discovery *conf.Discovery, prometheusConfig *conf.Prometheus, listenIP, - registerIP string, autoSetPorts bool, rpcPorts []int, index int, rpcRegisterName string, share *conf.Share, config T, rpcFn func(ctx context.Context, - config T, client discovery.SvcDiscoveryRegistry, server *grpc.Server) error, options ...grpc.ServerOption) error { + registerIP string, autoSetPorts bool, rpcPorts []int, index int, rpcRegisterName string, notification *conf.Notification, config T, + rpcFn func(ctx context.Context, config T, client discovery.SvcDiscoveryRegistry, server *grpc.Server) error, + options ...grpc.ServerOption) error { var ( rpcTcpAddr string @@ -58,6 +59,10 @@ func Start[T any](ctx context.Context, discovery *conf.Discovery, prometheusConf prometheusPort int ) + if notification != nil { + conf.InitNotification(notification) + } + registerIP, err := network.GetRpcRegisterIP(registerIP) if err != nil { return err