Skip to content

Commit

Permalink
Merge branch 'openimsdk:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
withchao authored Dec 18, 2024
2 parents 2c6f974 + 9929bd3 commit 3753b81
Show file tree
Hide file tree
Showing 77 changed files with 855 additions and 1,568 deletions.
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions .github/workflows/go-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
6 changes: 2 additions & 4 deletions config/notification.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion config/openim-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
54 changes: 27 additions & 27 deletions config/prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
10 changes: 0 additions & 10 deletions config/share.yml
Original file line number Diff line number Diff line change
@@ -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 ]

Expand Down
26 changes: 14 additions & 12 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,44 +151,46 @@ 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
- ${DATA_DIR}/components/prometheus/data:/prometheus
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
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ require (
github.com/gorilla/websocket v1.5.1
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/mitchellh/mapstructure v1.5.0
github.com/openimsdk/protocol v0.0.72-alpha.63
github.com/openimsdk/tools v0.0.50-alpha.52
github.com/openimsdk/protocol v0.0.72-alpha.66
github.com/openimsdk/tools v0.0.50-alpha.57
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.18.0
github.com/stretchr/testify v1.9.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,10 @@ github.com/onsi/gomega v1.25.0 h1:Vw7br2PCDYijJHSfBOWhov+8cAnUf8MfMaIOV323l6Y=
github.com/onsi/gomega v1.25.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM=
github.com/openimsdk/gomake v0.0.15-alpha.2 h1:5Q8yl8ezy2yx+q8/ucU/t4kJnDfCzNOrkXcDACCqtyM=
github.com/openimsdk/gomake v0.0.15-alpha.2/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI=
github.com/openimsdk/protocol v0.0.72-alpha.63 h1:IyPBibEvwBtTmD8DSrlqcekfEXe74k4+KeeHsgdhGh0=
github.com/openimsdk/protocol v0.0.72-alpha.63/go.mod h1:Iet+piS/jaS+kWWyj6EEr36mk4ISzIRYjoMSVA4dq2M=
github.com/openimsdk/tools v0.0.50-alpha.52 h1:SAxnn6xgHPcEBHTebNLFgvUqmxd4d2XpBBh9jHpUEvs=
github.com/openimsdk/tools v0.0.50-alpha.52/go.mod h1:muCtxguNJv8lFwLei27UASu2Nvg4ERSeN0R4K5tivk0=
github.com/openimsdk/protocol v0.0.72-alpha.66 h1:5KoDY6M4T+pXg449ScF6hqeQ+WenBwNyUJn/t8W0oBQ=
github.com/openimsdk/protocol v0.0.72-alpha.66/go.mod h1:Iet+piS/jaS+kWWyj6EEr36mk4ISzIRYjoMSVA4dq2M=
github.com/openimsdk/tools v0.0.50-alpha.57 h1:oIKV6vYhqp7TRmZ6Pe+r9RNl1D5s7aB/kE9yQVEWcSY=
github.com/openimsdk/tools v0.0.50-alpha.57/go.mod h1:muCtxguNJv8lFwLei27UASu2Nvg4ERSeN0R4K5tivk0=
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
Expand Down
15 changes: 7 additions & 8 deletions internal/api/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,28 @@ package api

import (
"github.com/gin-gonic/gin"
"github.com/openimsdk/open-im-server/v3/pkg/rpcclient"
"github.com/openimsdk/protocol/auth"
"github.com/openimsdk/tools/a2r"
)

type AuthApi rpcclient.Auth
type AuthApi struct{}

func NewAuthApi(client rpcclient.Auth) AuthApi {
return AuthApi(client)
func NewAuthApi() AuthApi {
return AuthApi{}
}

func (o *AuthApi) GetAdminToken(c *gin.Context) {
a2r.Call(auth.AuthClient.GetAdminToken, o.Client, c)
a2r.CallV2(c, auth.GetAdminTokenCaller.Invoke)
}

func (o *AuthApi) GetUserToken(c *gin.Context) {
a2r.Call(auth.AuthClient.GetUserToken, o.Client, c)
a2r.CallV2(c, auth.GetUserTokenCaller.Invoke)
}

func (o *AuthApi) ParseToken(c *gin.Context) {
a2r.Call(auth.AuthClient.ParseToken, o.Client, c)
a2r.CallV2(c, auth.ParseTokenCaller.Invoke)
}

func (o *AuthApi) ForceLogout(c *gin.Context) {
a2r.Call(auth.AuthClient.ForceLogout, o.Client, c)
a2r.CallV2(c, auth.ForceLogoutCaller.Invoke)
}
29 changes: 14 additions & 15 deletions internal/api/conversation.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,57 +16,56 @@ package api

import (
"github.com/gin-gonic/gin"
"github.com/openimsdk/open-im-server/v3/pkg/rpcclient"
"github.com/openimsdk/protocol/conversation"
"github.com/openimsdk/tools/a2r"
)

type ConversationApi rpcclient.Conversation
type ConversationApi struct{}

func NewConversationApi(client rpcclient.Conversation) ConversationApi {
return ConversationApi(client)
func NewConversationApi() ConversationApi {
return ConversationApi{}
}

func (o *ConversationApi) GetAllConversations(c *gin.Context) {
a2r.Call(conversation.ConversationClient.GetAllConversations, o.Client, c)
a2r.CallV2(c, conversation.GetAllConversationsCaller.Invoke)
}

func (o *ConversationApi) GetSortedConversationList(c *gin.Context) {
a2r.Call(conversation.ConversationClient.GetSortedConversationList, o.Client, c)
a2r.CallV2(c, conversation.GetSortedConversationListCaller.Invoke)
}

func (o *ConversationApi) GetConversation(c *gin.Context) {
a2r.Call(conversation.ConversationClient.GetConversation, o.Client, c)
a2r.CallV2(c, conversation.GetConversationCaller.Invoke)
}

func (o *ConversationApi) GetConversations(c *gin.Context) {
a2r.Call(conversation.ConversationClient.GetConversations, o.Client, c)
a2r.CallV2(c, conversation.GetConversationsCaller.Invoke)
}

func (o *ConversationApi) SetConversations(c *gin.Context) {
a2r.Call(conversation.ConversationClient.SetConversations, o.Client, c)
a2r.CallV2(c, conversation.SetConversationsCaller.Invoke)
}

func (o *ConversationApi) GetConversationOfflinePushUserIDs(c *gin.Context) {
a2r.Call(conversation.ConversationClient.GetConversationOfflinePushUserIDs, o.Client, c)
a2r.CallV2(c, conversation.GetConversationOfflinePushUserIDsCaller.Invoke)
}

func (o *ConversationApi) GetFullOwnerConversationIDs(c *gin.Context) {
a2r.Call(conversation.ConversationClient.GetFullOwnerConversationIDs, o.Client, c)
a2r.CallV2(c, conversation.GetFullOwnerConversationIDsCaller.Invoke)
}

func (o *ConversationApi) GetIncrementalConversation(c *gin.Context) {
a2r.Call(conversation.ConversationClient.GetIncrementalConversation, o.Client, c)
a2r.CallV2(c, conversation.GetIncrementalConversationCaller.Invoke)
}

func (o *ConversationApi) GetOwnerConversation(c *gin.Context) {
a2r.Call(conversation.ConversationClient.GetOwnerConversation, o.Client, c)
a2r.CallV2(c, conversation.GetOwnerConversationCaller.Invoke)
}

func (o *ConversationApi) GetNotNotifyConversationIDs(c *gin.Context) {
a2r.Call(conversation.ConversationClient.GetNotNotifyConversationIDs, o.Client, c)
a2r.CallV2(c, conversation.GetNotNotifyConversationIDsCaller.Invoke)
}

func (o *ConversationApi) GetPinnedConversationIDs(c *gin.Context) {
a2r.Call(conversation.ConversationClient.GetPinnedConversationIDs, o.Client, c)
a2r.CallV2(c, conversation.GetPinnedConversationIDsCaller.Invoke)
}
Loading

0 comments on commit 3753b81

Please sign in to comment.