Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new features merged #2409

Merged
merged 187 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
187 commits
Select commit Hold shift + click to select a range
4c3c455
fix: GroupApplicationAcceptedNotification
withchao Jan 11, 2024
f5f2cf4
Merge remote-tracking branch 'origin/main'
withchao Jan 11, 2024
ad979d4
Merge branch 'openimsdk:main' into main
withchao Jan 11, 2024
a00d77a
fix: GroupApplicationAcceptedNotification
withchao Jan 11, 2024
48ff03f
fix: NotificationUserInfoUpdate
withchao Jan 12, 2024
45859d9
Merge branch 'openimsdk:main' into main
withchao Jan 16, 2024
e3d78de
Merge branch 'openimsdk:main' into main
withchao Jan 18, 2024
c81e199
Merge branch 'openimsdk:main' into main
withchao Jan 22, 2024
4266fed
cicd: robot automated Change
withchao Jan 22, 2024
1a14191
Merge remote-tracking branch 'upstream/main'
withchao Jan 26, 2024
86d3a66
Merge branch 'openimsdk:main' into main
withchao Jan 28, 2024
1964a4b
Merge branch 'openimsdk:main' into main
withchao Jan 31, 2024
d91cde9
Merge branch 'openimsdk:main' into main
withchao Feb 5, 2024
6a05e64
Merge branch 'openimsdk:main' into main
withchao Feb 20, 2024
39a6141
Merge branch 'openimsdk:main' into main
withchao Mar 6, 2024
c2009ce
Merge branch 'openimsdk:main' into main
withchao Mar 7, 2024
34c7f22
Merge branch 'openimsdk:main' into main
withchao Mar 8, 2024
ea9c75b
Merge branch 'openimsdk:main' into main
withchao Mar 13, 2024
7b5279a
fix: component
withchao Mar 13, 2024
34daf13
fix: getConversationInfo
withchao Mar 13, 2024
65d58ae
Merge branch 'openimsdk:main' into main
withchao Mar 13, 2024
e601b5f
Merge remote-tracking branch 'upstream/main'
withchao Mar 20, 2024
5f72b1e
Merge remote-tracking branch 'origin/main'
withchao Mar 20, 2024
20dfafd
Merge branch 'openimsdk:main' into main
withchao Apr 24, 2024
dc57d38
feat: cron task
withchao Apr 25, 2024
2f13149
feat: cron task
withchao Apr 25, 2024
2e43950
feat: cron task
withchao Apr 25, 2024
7a29a85
feat: cron task
withchao Apr 26, 2024
3920c06
feat: cron task
withchao Apr 26, 2024
bed7a60
Merge branch 'openimsdk:main' into main
withchao Apr 26, 2024
f2fbf19
Merge remote-tracking branch 'refs/remotes/origin/main' into corn37
withchao Apr 26, 2024
01851df
Merge remote-tracking branch 'upstream/main'
withchao Apr 28, 2024
480ccc7
fix: minio config url recognition error
withchao Apr 28, 2024
1046323
Merge branch 'openimsdk:main' into main
withchao May 8, 2024
76c6fe8
Merge branch 'openimsdk:main' into main
withchao May 10, 2024
6b119bd
Merge branch 'openimsdk:main' into main
withchao May 17, 2024
5528e8e
new mongo
withchao May 22, 2024
c6942f0
new mongo
withchao May 22, 2024
82c6b00
new mongo
withchao May 23, 2024
a2bfc90
new mongo
withchao May 23, 2024
05cec1b
new mongo
withchao May 24, 2024
1184002
new mongo
withchao May 24, 2024
e99eaf9
new mongo
withchao May 24, 2024
2f97933
new mongo
withchao May 24, 2024
1f02bdc
friend incr sync
withchao May 27, 2024
8e37a41
friend incr sync
withchao May 27, 2024
f6131c4
friend incr sync
withchao May 29, 2024
0d57f28
friend incr sync
withchao May 29, 2024
9ba22f3
friend incr sync
withchao May 30, 2024
61740d4
Merge branch 'openimsdk:main' into main
withchao May 30, 2024
10315e9
Merge branch 'main' into list
withchao May 30, 2024
eb362da
mage
withchao May 30, 2024
0aaf8b9
optimization version log
withchao May 30, 2024
0f72de8
optimization version log
withchao May 30, 2024
cfc01bb
sync
withchao May 31, 2024
e9f4627
sync
withchao Jun 3, 2024
6363358
sync
withchao Jun 3, 2024
1b5621b
group sync
withchao Jun 3, 2024
6939352
sync option
withchao Jun 4, 2024
7e13faa
sync option
withchao Jun 4, 2024
1796c3a
refactor: replace `friend` package with `realtion`.
mo3et Jun 5, 2024
cfd07b1
Merge branch 'openimsdk:main' into list
mo3et Jun 5, 2024
7821f5f
Merge branch 'list' into list
mo3et Jun 5, 2024
e11807c
refactor: update lastest commit to relation.
mo3et Jun 5, 2024
9362169
Merge pull request #1 from mo3et/list
FGadvancer Jun 5, 2024
6285b68
sync option
withchao Jun 6, 2024
8e1d0c5
Merge remote-tracking branch 'origin/list' into list
withchao Jun 6, 2024
c5f565f
sync option
withchao Jun 6, 2024
a1523f4
sync option
withchao Jun 6, 2024
58c4c13
sync
withchao Jun 7, 2024
caebdf3
sync
withchao Jun 11, 2024
17dad5c
Merge branch 'openimsdk:main' into main
withchao Jun 12, 2024
1b10271
go.mod
withchao Jun 13, 2024
ef71d0c
seq
withchao Jun 14, 2024
904842b
update: go mod
icey-yu Jun 14, 2024
c5fa596
refactor: change incremental to full
icey-yu Jun 14, 2024
f19f6f9
feat: get full friend user ids
icey-yu Jun 14, 2024
cee1a49
feat: api and config
icey-yu Jun 14, 2024
fe4842b
seq
withchao Jun 14, 2024
1aa610c
Merge pull request #2 from icey-yu/friend-increamental
withchao Jun 14, 2024
a41c8c6
group version
withchao Jun 17, 2024
5156795
Merge branch 'openimsdk:main' into main
withchao Jun 17, 2024
c161330
Merge remote-tracking branch 'origin/list' into list
withchao Jun 17, 2024
bd4fb8a
merge
withchao Jun 17, 2024
ec40d82
Merge remote-tracking branch 'origin/main' into list
withchao Jun 17, 2024
d55d416
seq
withchao Jun 17, 2024
a2a28b4
seq
withchao Jun 18, 2024
cce382d
seq
withchao Jun 18, 2024
aff8322
fix: sort by id avoid unstable sort friends.
FGadvancer Jun 18, 2024
08cb4a9
group
withchao Jun 19, 2024
f613c6d
group
withchao Jun 19, 2024
7182298
Merge remote-tracking branch 'origin/list' into seq38
withchao Jun 19, 2024
1ee33f3
group
withchao Jun 19, 2024
924888d
fix: sort by id avoid unstable sort friends.
FGadvancer Jun 19, 2024
5006af5
fix: sort by id avoid unstable sort friends.
FGadvancer Jun 19, 2024
4f359b7
fix: sort by id avoid unstable sort friends.
FGadvancer Jun 19, 2024
4074f81
Merge branch 'refs/heads/list' into seq38
withchao Jun 19, 2024
03d4564
user version
withchao Jun 20, 2024
88c1510
Merge remote-tracking branch 'origin/list' into list
withchao Jun 20, 2024
ac9f4f6
Merge remote-tracking branch 'origin/list' into seq38
withchao Jun 20, 2024
425008a
Merge remote-tracking branch 'origin/seq38' into seq38
withchao Jun 20, 2024
2d2941a
seq
withchao Jun 20, 2024
8e3890e
seq
withchao Jun 21, 2024
9b043fe
seq user
withchao Jun 24, 2024
8f0403e
user online
withchao Jun 26, 2024
2b2a75f
implement minio expire delete.
mo3et Jun 28, 2024
8f86049
user online
withchao Jun 28, 2024
3960d28
config
withchao Jun 28, 2024
affa909
fix
withchao Jun 28, 2024
3ef62d4
fix
withchao Jun 28, 2024
dac8fba
implement minio expire delete logic.
mo3et Jun 28, 2024
3167780
online cache
withchao Jul 1, 2024
d06c323
online cache
withchao Jul 1, 2024
bf2cf42
Merge pull request #6 from mo3et/minio-cron-del
withchao Jul 1, 2024
4781cf4
Merge branch 'openimsdk:main' into main
withchao Jul 1, 2024
45b07bc
online cache
withchao Jul 1, 2024
32c5f65
online cache
withchao Jul 2, 2024
9388cb6
online cache
withchao Jul 2, 2024
28c8b78
online cache
withchao Jul 2, 2024
6e2659c
online cache
withchao Jul 2, 2024
f87ee44
online cache
withchao Jul 2, 2024
1bfaf3e
online cache
withchao Jul 2, 2024
dcd8749
online cache
withchao Jul 2, 2024
14aba3b
online cache
withchao Jul 2, 2024
3df39a8
online cache
withchao Jul 2, 2024
3306117
feat: implement scheduled delete outdated object in minio.
mo3et Jul 2, 2024
bfbfb78
Merge branch 'openimsdk:main' into main
withchao Jul 3, 2024
8d4737c
update gomake version
withchao Jul 3, 2024
0b4c802
update gomake version
withchao Jul 3, 2024
7897044
implement FindExpires pagination.
mo3et Jul 3, 2024
686ccae
remove unnesseary incr.
mo3et Jul 3, 2024
a421bd1
fix uncorrect args call.
mo3et Jul 3, 2024
c117ef8
Merge pull request #8 from mo3et/minio-cron-del
withchao Jul 3, 2024
e791cbd
online push
withchao Jul 3, 2024
006766c
online push
withchao Jul 3, 2024
fcda73f
online push
withchao Jul 4, 2024
a464750
Merge branch 'openimsdk:main' into main
withchao Jul 4, 2024
73a9265
Merge remote-tracking branch 'origin/main' into seq38
withchao Jul 4, 2024
c5cf078
resolving conflicts
withchao Jul 4, 2024
f315177
Merge branch 'seq38' into online
withchao Jul 4, 2024
a9ab9ba
resolving conflicts
withchao Jul 4, 2024
97636c4
test
withchao Jul 4, 2024
1336b83
api prommetrics
withchao Jul 4, 2024
6713986
api prommetrics
withchao Jul 4, 2024
9151b56
api prommetrics
withchao Jul 4, 2024
c1d66fa
api prommetrics
withchao Jul 4, 2024
e3ee24d
api prommetrics
withchao Jul 4, 2024
0a9b53b
rpc prommetrics
withchao Jul 5, 2024
ab84d77
Merge branch 'openimsdk:main' into main
withchao Jul 5, 2024
181107d
Merge branch 'main' into count
withchao Jul 5, 2024
2052e1c
rpc prommetrics
withchao Jul 5, 2024
c1967a6
online status
withchao Jul 5, 2024
b53a26d
online status
withchao Jul 8, 2024
daaf993
Merge remote-tracking branch 'upstream/main' into online
withchao Jul 8, 2024
fd2b0b3
online status
withchao Jul 8, 2024
67d17c8
online status
withchao Jul 8, 2024
9a4f5f7
sub
withchao Jul 9, 2024
df9bbeb
Merge branch 'openimsdk:main' into main
withchao Jul 9, 2024
e17f0c9
conversation version incremental
withchao Jul 10, 2024
fdb6ea7
Merge branch 'openimsdk:main' into main
withchao Jul 10, 2024
df80865
Merge branch 'seq38' into allmerge
withchao Jul 10, 2024
92d70ec
merge seq
withchao Jul 10, 2024
65d4fc7
Merge branch 'online' into allmerge
withchao Jul 10, 2024
c5519ed
merge online
withchao Jul 10, 2024
c3729d1
merge online
withchao Jul 10, 2024
98b3846
Merge remote-tracking branch 'origin/count' into allmerge
withchao Jul 10, 2024
e1e3bb8
merge online
withchao Jul 10, 2024
4875a34
Merge branch 'convincr' into allmerge
withchao Jul 10, 2024
1d54c61
merge seq
withchao Jul 10, 2024
18cc83c
Merge branch 'openimsdk:main' into main
withchao Jul 11, 2024
ec7bebf
GetOwnerConversation
withchao Jul 11, 2024
29837c9
fix: change incremental syncer router name.
FGadvancer Jul 11, 2024
326dc38
rockscache batch get
withchao Jul 11, 2024
a7d1a53
rockscache seq batch get
withchao Jul 12, 2024
3d7090e
fix: GetMsgDocModelByIndex bug
withchao Jul 15, 2024
aca631f
Merge remote-tracking branch 'origin/convincr' into convincr
withchao Jul 15, 2024
33de30b
Merge branch 'openimsdk:main' into main
withchao Jul 15, 2024
1e5e87b
Merge remote-tracking branch 'origin/main' into convincr
withchao Jul 15, 2024
e4fb5ba
update go.mod
withchao Jul 15, 2024
0e7687c
Merge remote-tracking branch 'origin/convincr' into allmerge
withchao Jul 15, 2024
68c41ba
update go.mod
withchao Jul 15, 2024
71ba69b
Merge branch 'openimsdk:main' into main
withchao Jul 15, 2024
4ca7d2f
Merge remote-tracking branch 'origin/main' into allmerge
withchao Jul 15, 2024
6a6c712
merge
withchao Jul 15, 2024
7f4d6de
feat: prometheus
icey-yu Jul 15, 2024
4738d17
feat: prometheus
icey-yu Jul 15, 2024
14c486b
Merge pull request #9 from icey-yu/prometheus
withchao Jul 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ ZOOKEEPER_IMAGE=bitnami/zookeeper:3.8
KAFKA_IMAGE=bitnami/kafka:3.5.1
MINIO_IMAGE=minio/minio:RELEASE.2024-01-11T07-46-16Z
ETCD_IMAGE=quay.io/coreos/etcd:v3.5.13
PROMETHEUS_IMAGE=prom/prometheus:v2.45.6
ALERTMANAGER_IMAGE=prom/alertmanager:v0.27.0
GRAFANA_IMAGE=grafana/grafana:11.0.1

OPENIM_WEB_FRONT_IMAGE=openim/openim-web-front:release-v3.5.1
OPENIM_ADMIN_FRONT_IMAGE=openim/openim-admin-front:release-v1.7
Expand Down
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ deployments/charts/generated-configs/
### OpenIM Config ###
.env
config/config.yaml
config/alertmanager.yml
config/prometheus.yml
config/email.tmpl
config/notification.yaml
config/instance-down-rules.yml

### OpenIM deploy ###
deployments/openim-server/charts
Expand Down
1 change: 0 additions & 1 deletion cmd/openim-api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ func main() {
if err := cmd.NewApiCmd().Exec(); err != nil {
program.ExitWithError(err)
}

}
25 changes: 25 additions & 0 deletions config/alertmanager.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
global:
resolve_timeout: 5m
smtp_from: alert@openim.io
smtp_smarthost: smtp.163.com:465
smtp_auth_username: alert@openim.io
smtp_auth_password: YOURAUTHPASSWORD
smtp_require_tls: false
smtp_hello: xxx

templates:
- /etc/alertmanager/email.tmpl

route:
group_by: ['alertname']
group_wait: 5s
group_interval: 5s
repeat_interval: 5m
receiver: email
receivers:
- name: email
email_configs:
- to: 'alert@example.com'
html: '{{ template "email.to.html" . }}'
headers: { Subject: "[OPENIM-SERVER]Alarm" }
send_resolved: true
16 changes: 16 additions & 0 deletions config/email.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{ define "email.to.html" }}
{{ range .Alerts }}
<!-- Begin of OpenIM Alert -->
<div style="border:1px solid #ccc; padding:10px; margin-bottom:10px;">
<h3>OpenIM Alert</h3>
<p><strong>Alert Program:</strong> Prometheus Alert</p>
<p><strong>Severity Level:</strong> {{ .Labels.severity }}</p>
<p><strong>Alert Type:</strong> {{ .Labels.alertname }}</p>
<p><strong>Affected Host:</strong> {{ .Labels.instance }}</p>
<p><strong>Affected Service:</strong> {{ .Labels.job }}</p>
<p><strong>Alert Subject:</strong> {{ .Annotations.summary }}</p>
<p><strong>Trigger Time:</strong> {{ .StartsAt.Format "2006-01-02 15:04:05" }}</p>
</div>
<!-- End of OpenIM Alert -->
{{ end }}
{{ end }}
22 changes: 22 additions & 0 deletions config/instance-down-rules.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
groups:
- name: instance_down
rules:
- alert: InstanceDown
expr: up == 0
for: 1m
labels:
severity: critical
annotations:
summary: "Instance {{ $labels.instance }} down"
description: "{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 1 minutes."

- name: database_insert_failure_alerts
rules:
- alert: DatabaseInsertFailed
expr: (increase(msg_insert_redis_failed_total[5m]) > 0) or (increase(msg_insert_mongo_failed_total[5m]) > 0)
for: 1m
labels:
severity: critical
annotations:
summary: "Increase in MsgInsertRedisFailedCounter or MsgInsertMongoFailedCounter detected"
description: "Either MsgInsertRedisFailedCounter or MsgInsertMongoFailedCounter has increased in the last 5 minutes, indicating failures in message insert operations to Redis or MongoDB,maybe the redis or mongodb is crash."
3 changes: 2 additions & 1 deletion config/openim-crontask.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
chatRecordsClearTime: "0 2 * * *"
cronExecuteTime: "0 2 * * *"
retainChatRecords: 365
fileExpireTime: 90
83 changes: 83 additions & 0 deletions config/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets: ['192.168.2.22:19093']

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
- "instance-down-rules.yml"
# - "first_rules.yml"
# - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label "job='job_name'"" to any timeseries scraped from this config.
# Monitored information captured by prometheus

# prometheus fetches application services
- job_name: 'node_exporter'
static_configs:
- targets: [ '192.168.2.22:20114' ]
- job_name: 'openimserver-openim-api'
static_configs:
- targets: [ '192.168.2.22:20113' ]
labels:
namespace: 'default'
- job_name: 'openimserver-openim-msggateway'
static_configs:
- targets: [ '192.168.2.22:20112' ]
labels:
namespace: 'default'
- job_name: 'openimserver-openim-msgtransfer'
static_configs:
- targets: [ 192.168.2.22:20111, 192.168.2.22:20110, 192.168.2.22:20109, 192.168.2.22:20108 ]
labels:
namespace: 'default'
- job_name: 'openimserver-openim-push'
static_configs:
- targets: [ '192.168.2.22:20107' ]
labels:
namespace: 'default'
- job_name: 'openimserver-openim-rpc-auth'
static_configs:
- targets: [ '192.168.2.22:20106' ]
labels:
namespace: 'default'
- job_name: 'openimserver-openim-rpc-conversation'
static_configs:
- targets: [ '192.168.2.22:20105' ]
labels:
namespace: 'default'
- job_name: 'openimserver-openim-rpc-friend'
static_configs:
- targets: [ '192.168.2.22:20104' ]
labels:
namespace: 'default'
- job_name: 'openimserver-openim-rpc-group'
static_configs:
- targets: [ '192.168.2.22:20103' ]
labels:
namespace: 'default'
- job_name: 'openimserver-openim-rpc-msg'
static_configs:
- targets: [ '192.168.2.22:20102' ]
labels:
namespace: 'default'
- job_name: 'openimserver-openim-rpc-third'
static_configs:
- targets: [ '192.168.2.22:20101' ]
labels:
namespace: 'default'
- job_name: 'openimserver-openim-rpc-user'
static_configs:
- targets: [ '192.168.2.22:20100' ]
labels:
namespace: 'default'
45 changes: 45 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,50 @@ services:
networks:
- openim

prometheus:
image: ${PROMETHEUS_IMAGE}
container_name: prometheus
restart: always
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

alertmanager:
image: ${ALERTMANAGER_IMAGE}
container_name: alertmanager
restart: always
volumes:
- ./config/alertmanager.yml:/etc/alertmanager/alertmanager.yml
- ./config/email.tmpl:/etc/alertmanager/email.tmpl
ports:
- "19093:9093"
networks:
- openim

grafana:
image: ${GRAFANA_IMAGE}
container_name: grafana
user: root
restart: always
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"
volumes:
- ${DATA_DIR:-./}/components/grafana:/var/lib/grafana
networks:
- openim


4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/mitchellh/mapstructure v1.5.0
github.com/openimsdk/protocol v0.0.69-alpha.30
github.com/openimsdk/tools v0.0.49-alpha.49
github.com/openimsdk/tools v0.0.49-alpha.50
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 Expand Up @@ -194,5 +194,3 @@ require (
golang.org/x/crypto v0.21.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
)

//replace github.com/openimsdk/protocol => /Users/chao/Desktop/project/protocol
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ github.com/openimsdk/gomake v0.0.14-alpha.5 h1:VY9c5x515lTfmdhhPjMvR3BBRrRquAUCF
github.com/openimsdk/gomake v0.0.14-alpha.5/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI=
github.com/openimsdk/protocol v0.0.69-alpha.30 h1:OXzCIpDpIY/GI6h1SDYWN51OS9Xv/BcHaOwq8whPKqI=
github.com/openimsdk/protocol v0.0.69-alpha.30/go.mod h1:OZQA9FR55lseYoN2Ql1XAHYKHJGu7OMNkUbuekrKCM8=
github.com/openimsdk/tools v0.0.49-alpha.49 h1:bkVxlEDM9rJxo5a98mk2ETR0xbEv+5mjeVVVFQfARAQ=
github.com/openimsdk/tools v0.0.49-alpha.49/go.mod h1:HtSRjPTL8PsuZ+PhR5noqzrYBF0sdwW3/O/sWVucWg8=
github.com/openimsdk/tools v0.0.49-alpha.50 h1:7CaYLVtsBU5kyiTetUOuOkO5FFFmMvSzBEfh2tfCn90=
github.com/openimsdk/tools v0.0.49-alpha.50/go.mod h1:HtSRjPTL8PsuZ+PhR5noqzrYBF0sdwW3/O/sWVucWg8=
github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4=
github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
Expand Down
1 change: 0 additions & 1 deletion internal/api/friend.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func (o *FriendApi) GetFriendList(c *gin.Context) {

func (o *FriendApi) GetDesignatedFriends(c *gin.Context) {
a2r.Call(relation.FriendClient.GetDesignatedFriends, o.Client, c)
//a2r.Call(relation.FriendClient.GetDesignatedFriends, o.Client, c, a2r.NewNilReplaceOption(relation.FriendClient.GetDesignatedFriends))
}

func (o *FriendApi) SetFriendRemark(c *gin.Context) {
Expand Down
7 changes: 2 additions & 5 deletions internal/api/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"time"

kdisc "github.com/openimsdk/open-im-server/v3/pkg/common/discoveryregister"
ginprom "github.com/openimsdk/open-im-server/v3/pkg/common/ginprometheus"
"github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics"
"github.com/openimsdk/tools/discovery"
"github.com/openimsdk/tools/errs"
Expand Down Expand Up @@ -72,10 +71,8 @@ func Start(ctx context.Context, index int, config *Config) error {
netDone <- struct{}{}
return
}
p := ginprom.NewPrometheus("app", prommetrics.GetGinCusMetrics("Api"))
p.SetListenAddress(fmt.Sprintf(":%d", prometheusPort))
if err = p.Use(router); err != nil && err != http.ErrServerClosed {
netErr = errs.WrapMsg(err, fmt.Sprintf("prometheus start err: %d", prometheusPort))
if err := prommetrics.ApiInit(prometheusPort); err != nil && err != http.ErrServerClosed {
netErr = errs.WrapMsg(err, fmt.Sprintf("api prometheus start err: %d", prometheusPort))
netDone <- struct{}{}
}
}()
Expand Down
23 changes: 19 additions & 4 deletions internal/api/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,39 @@ package api

import (
"fmt"
"net/http"
"strings"

"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
"github.com/go-playground/validator/v10"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

"github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics"
"github.com/openimsdk/open-im-server/v3/pkg/common/servererrs"
"github.com/openimsdk/open-im-server/v3/pkg/rpcclient"
"github.com/openimsdk/protocol/constant"
"github.com/openimsdk/tools/apiresp"
"github.com/openimsdk/tools/discovery"
"github.com/openimsdk/tools/log"
"github.com/openimsdk/tools/mw"
"net/http"
"strings"
)

func prommetricsGin() gin.HandlerFunc {
return func(c *gin.Context) {
c.Next()
path := c.FullPath()
if c.Writer.Status() == http.StatusNotFound {
prommetrics.HttpCall("<404>", c.Request.Method, c.Writer.Status())
} else {
prommetrics.HttpCall(path, c.Request.Method, c.Writer.Status())
}
if resp := apiresp.GetGinApiResponse(c); resp != nil {
prommetrics.APICall(path, c.Request.Method, resp.ErrCode)
}
}
}

func newGinRouter(disCov discovery.SvcDiscoveryRegistry, config *Config) *gin.Engine {
disCov.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, "round_robin")))
Expand All @@ -38,7 +53,7 @@ func newGinRouter(disCov discovery.SvcDiscoveryRegistry, config *Config) *gin.En
authRpc := rpcclient.NewAuth(disCov, config.Share.RpcRegisterName.Auth)
thirdRpc := rpcclient.NewThird(disCov, config.Share.RpcRegisterName.Third, config.API.Prometheus.GrafanaURL)

r.Use(gin.Recovery(), mw.CorsHandler(), mw.GinParseOperationID(), GinParseToken(authRpc))
r.Use(prommetricsGin(), gin.Recovery(), mw.CorsHandler(), mw.GinParseOperationID(), GinParseToken(authRpc))
u := NewUserApi(*userRpc)
m := NewMessageApi(messageRpc, userRpc, config.Share.IMAdminUserID)
userRouterGroup := r.Group("/user")
Expand Down
4 changes: 4 additions & 0 deletions internal/msggateway/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ type Client struct {
token string
hbCtx context.Context
hbCancel context.CancelFunc
subLock sync.Mutex
subUserIDs map[string]struct{}
}

// ResetClient updates the client's state with new connection and context information.
Expand Down Expand Up @@ -216,6 +218,8 @@ func (c *Client) handleMessage(message []byte) error {
resp, messageErr = c.longConnServer.UserLogout(ctx, binaryReq)
case WsSetBackgroundStatus:
resp, messageErr = c.setAppBackgroundStatus(ctx, binaryReq)
case WsSubUserOnlineStatus:
resp, messageErr = c.longConnServer.SubUserOnlineStatus(ctx, c, binaryReq)
default:
return fmt.Errorf(
"ReqIdentifier failed,sendID:%s,msgIncr:%s,reqIdentifier:%d",
Expand Down
9 changes: 7 additions & 2 deletions internal/msggateway/compressor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ package msggateway

import (
"crypto/rand"
"github.com/stretchr/testify/assert"
"sync"
"testing"

"github.com/stretchr/testify/assert"
"unsafe"
)

func mockRandom() []byte {
Expand Down Expand Up @@ -132,3 +132,8 @@ func BenchmarkDecompressWithSyncPool(b *testing.B) {
assert.Equal(b, nil, err)
}
}

func TestName(t *testing.T) {
t.Log(unsafe.Sizeof(Client{}))

}
1 change: 1 addition & 0 deletions internal/msggateway/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const (
WSKickOnlineMsg = 2002
WsLogoutMsg = 2003
WsSetBackgroundStatus = 2004
WsSubUserOnlineStatus = 2005
WSDataError = 3001
)

Expand Down
Loading
Loading