mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-04-28 22:39:18 +08:00
Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5211d43d9d | |||
| 801ac740b7 | |||
| 5028624fa3 | |||
| 9b92b3c744 | |||
| f9989274f9 | |||
| 8b4ff0c55b | |||
| 7d5e4a2196 | |||
| 452e3b2bbb | |||
| 5f81f632f8 | |||
| 72c39e1dda | |||
| 98b9343501 | |||
| 1a053275f8 | |||
| 1a1391cf3d | |||
| 9fefa916c8 | |||
| 95ab761d8f | |||
| 1c5f876183 | |||
| 44457187be | |||
| f4171a2c30 | |||
| 59c6136ba8 | |||
| f485f92b00 | |||
| c40f979de6 | |||
| 2039f4b305 | |||
| 72b2dc92f2 | |||
| ad2b09b282 | |||
| 1679a85370 | |||
| 2a0df3a22e | |||
| 1954b70023 | |||
| 17a3105f41 |
@@ -92,12 +92,13 @@ jobs:
|
|||||||
contents: write
|
contents: write
|
||||||
env:
|
env:
|
||||||
SDK_DIR: openim-sdk-core
|
SDK_DIR: openim-sdk-core
|
||||||
CONFIG_PATH: config/notification.yml
|
NOTIFICATION_CONFIG_PATH: config/notification.yml
|
||||||
# pull-requests: write
|
SHARE_CONFIG_PATH: config/share.yml
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ ubuntu-latest ]
|
os: [ubuntu-latest]
|
||||||
go_version: [ "1.22.x" ]
|
go_version: ["1.22.x"]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Server repository
|
- name: Checkout Server repository
|
||||||
@@ -106,7 +107,8 @@ jobs:
|
|||||||
- name: Checkout SDK repository
|
- name: Checkout SDK repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
repository: 'openimsdk/openim-sdk-core'
|
repository: "openimsdk/openim-sdk-core"
|
||||||
|
ref: "main"
|
||||||
path: ${{ env.SDK_DIR }}
|
path: ${{ env.SDK_DIR }}
|
||||||
|
|
||||||
- name: Set up Go ${{ matrix.go_version }}
|
- name: Set up Go ${{ matrix.go_version }}
|
||||||
@@ -119,15 +121,11 @@ jobs:
|
|||||||
go install github.com/magefile/mage@latest
|
go install github.com/magefile/mage@latest
|
||||||
go mod download
|
go mod download
|
||||||
|
|
||||||
- name: Install yq
|
|
||||||
run: |
|
|
||||||
sudo wget https://github.com/mikefarah/yq/releases/download/v4.34.1/yq_linux_amd64 -O /usr/bin/yq
|
|
||||||
sudo chmod +x /usr/bin/yq
|
|
||||||
|
|
||||||
- name: Modify Server Configuration
|
- name: Modify Server Configuration
|
||||||
run: |
|
run: |
|
||||||
yq e '.groupCreated.unreadCount = true' -i ${{ env.CONFIG_PATH }}
|
yq e '.groupCreated.isSendMsg = true' -i ${{ env.NOTIFICATION_CONFIG_PATH }}
|
||||||
yq e '.friendApplicationApproved.unreadCount = true' -i ${{ env.CONFIG_PATH }}
|
yq e '.friendApplicationApproved.isSendMsg = true' -i ${{ env.NOTIFICATION_CONFIG_PATH }}
|
||||||
|
yq e '.secret = 123456' -i ${{ env.SHARE_CONFIG_PATH }}
|
||||||
|
|
||||||
- name: Start Server Services
|
- name: Start Server Services
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
+22
-20
@@ -1,34 +1,36 @@
|
|||||||
|
# Global Alertmanager runtime and SMTP settings.
|
||||||
global:
|
global:
|
||||||
resolve_timeout: 5m
|
resolve_timeout: 5m # Wait time before an alert is considered resolved when no further updates are received.
|
||||||
smtp_from: alert@openim.io
|
smtp_from: alert@openim.io # Sender address displayed in alert emails.
|
||||||
smtp_smarthost: smtp.163.com:465
|
smtp_smarthost: smtp.163.com:465 # SMTP relay endpoint in host:port format.
|
||||||
smtp_auth_username: alert@openim.io
|
smtp_auth_username: alert@openim.io # SMTP authentication username (commonly the same as smtp_from).
|
||||||
smtp_auth_password: YOURAUTHPASSWORD
|
smtp_auth_password: YOURAUTHPASSWORD # SMTP authorization token or app password.
|
||||||
smtp_require_tls: false
|
smtp_require_tls: false # Set to true when your SMTP provider requires STARTTLS.
|
||||||
smtp_hello: xxx
|
smtp_hello: xxx # HELO/EHLO identity presented to the SMTP server.
|
||||||
|
|
||||||
templates:
|
templates:
|
||||||
- /etc/alertmanager/email.tmpl
|
- /etc/alertmanager/email.tmpl # Go template file used to render HTML email content.
|
||||||
|
|
||||||
|
# Root routing tree for all incoming alerts.
|
||||||
route:
|
route:
|
||||||
group_by: [ 'alertname' ]
|
group_by: [ 'alertname' ] # Alerts sharing this label value are batched into one notification.
|
||||||
group_wait: 5s
|
group_wait: 5s # Initial delay before sending the first notification for a new alert group.
|
||||||
group_interval: 5s
|
group_interval: 5s # Minimum interval between notifications for the same alert group.
|
||||||
repeat_interval: 5m
|
repeat_interval: 5m # Reminder interval while an alert group remains firing.
|
||||||
receiver: email
|
receiver: email # Default receiver when no child route matches.
|
||||||
routes:
|
routes:
|
||||||
- matchers:
|
- matchers:
|
||||||
- alertname = "XXX"
|
- alertname = "XXX" # Example matcher; replace with a real alert name or remove this route.
|
||||||
group_by: [ 'instance' ]
|
group_by: [ 'instance' ] # Override grouping for this specific route.
|
||||||
group_wait: 5s
|
group_wait: 5s
|
||||||
group_interval: 5s
|
group_interval: 5s
|
||||||
repeat_interval: 5m
|
repeat_interval: 5m
|
||||||
receiver: email
|
receiver: email
|
||||||
|
|
||||||
receivers:
|
receivers:
|
||||||
- name: email
|
- name: email # Receiver name referenced by route.receiver.
|
||||||
email_configs:
|
email_configs:
|
||||||
- to: 'alert@example.com'
|
- to: 'alert@example.com' # Recipient mailbox for alert notifications.
|
||||||
html: '{{ template "email.to.html" . }}'
|
html: '{{ template "email.to.html" . }}' # Rendered with the template declared in email.tmpl.
|
||||||
headers: { Subject: "[OPENIM-SERVER]Alarm" }
|
headers: { Subject: "[OPENIM-SERVER]Alarm" } # Custom email subject line.
|
||||||
send_resolved: true
|
send_resolved: true # Also send a notification when the alert recovers.
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
{{/* OpenIM Alertmanager email template.
|
||||||
|
This template renders both firing and resolved alerts.
|
||||||
|
Each alert entry reads labels and annotations from Prometheus rule definitions. */}}
|
||||||
{{ define "email.to.html" }}
|
{{ define "email.to.html" }}
|
||||||
{{ if eq .Status "firing" }}
|
{{ if eq .Status "firing" }}
|
||||||
{{ range .Alerts }}
|
{{ range .Alerts }}
|
||||||
|
|||||||
@@ -1,30 +1,31 @@
|
|||||||
|
# Default Prometheus alert groups for OpenIM.
|
||||||
groups:
|
groups:
|
||||||
- name: instance_down
|
- name: instance_down # Fires when a monitored target remains unreachable.
|
||||||
rules:
|
rules:
|
||||||
- alert: InstanceDown
|
- alert: InstanceDown
|
||||||
expr: up == 0
|
expr: up == 0 # The built-in "up" metric is 0 when the latest scrape fails.
|
||||||
for: 1m
|
for: 1m # Trigger only if the condition remains true for more than 1 minute.
|
||||||
labels:
|
labels:
|
||||||
severity: critical
|
severity: critical # Used by Alertmanager for routing and notification priority.
|
||||||
annotations:
|
annotations:
|
||||||
summary: "Instance {{ $labels.instance }} down"
|
summary: "Instance {{ $labels.instance }} down"
|
||||||
description: "{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 1 minutes."
|
description: "{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 1 minute."
|
||||||
|
|
||||||
- name: database_insert_failure_alerts
|
- name: database_insert_failure_alerts # Detects failures when persisting messages to Redis or MongoDB.
|
||||||
rules:
|
rules:
|
||||||
- alert: DatabaseInsertFailed
|
- alert: DatabaseInsertFailed
|
||||||
expr: (increase(msg_insert_redis_failed_total[5m]) > 0) or (increase(msg_insert_mongo_failed_total[5m]) > 0)
|
expr: (increase(msg_insert_redis_failed_total[5m]) > 0) or (increase(msg_insert_mongo_failed_total[5m]) > 0) # Any positive increase indicates write failures occurred in the last 5 minutes.
|
||||||
for: 1m
|
for: 1m # Avoid firing on very short spikes.
|
||||||
labels:
|
labels:
|
||||||
severity: critical
|
severity: critical
|
||||||
annotations:
|
annotations:
|
||||||
summary: "Increase in MsgInsertRedisFailedCounter or MsgInsertMongoFailedCounter detected"
|
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."
|
description: "Either MsgInsertRedisFailedCounter or MsgInsertMongoFailedCounter increased in the last 5 minutes, indicating message insert failures to Redis or MongoDB and a possible backend outage."
|
||||||
|
|
||||||
- name: registrations_few
|
- name: registrations_few # Operational early-warning rule for unusually low login/registration activity.
|
||||||
rules:
|
rules:
|
||||||
- alert: RegistrationsFew
|
- alert: RegistrationsFew
|
||||||
expr: increase(user_login_total[1h]) == 0
|
expr: increase(user_login_total[1h]) == 0 # No successful login/registration events observed in 1 hour.
|
||||||
for: 1m
|
for: 1m
|
||||||
labels:
|
labels:
|
||||||
severity: info
|
severity: info
|
||||||
@@ -32,10 +33,10 @@ groups:
|
|||||||
summary: "Too few registrations within the time frame"
|
summary: "Too few registrations within the time frame"
|
||||||
description: "The number of registrations in the last hour is 0. There might be some issues."
|
description: "The number of registrations in the last hour is 0. There might be some issues."
|
||||||
|
|
||||||
- name: messages_few
|
- name: messages_few # Operational early-warning rule for unusually low messaging activity.
|
||||||
rules:
|
rules:
|
||||||
- alert: MessagesFew
|
- alert: MessagesFew
|
||||||
expr: (increase(single_chat_msg_process_success_total[1h])+increase(group_chat_msg_process_success_total[1h])) == 0
|
expr: (increase(single_chat_msg_process_success_total[1h])+increase(group_chat_msg_process_success_total[1h])) == 0 # No successful single or group messages observed in 1 hour.
|
||||||
for: 1m
|
for: 1m
|
||||||
labels:
|
labels:
|
||||||
severity: info
|
severity: info
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ api:
|
|||||||
|
|
||||||
|
|
||||||
prometheus:
|
prometheus:
|
||||||
# Whether to enable prometheus
|
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
|
||||||
enable: true
|
enable: true
|
||||||
# autoSetPorts indicates whether to automatically set the ports
|
# autoSetPorts indicates whether to automatically set the ports
|
||||||
autoSetPorts: true
|
autoSetPorts: true
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ rpc:
|
|||||||
ports: [ 10140, 10141, 10142, 10143, 10144, 10145, 10146, 10147, 10148, 10149, 10150, 10151, 10152, 10153, 10154, 10155 ]
|
ports: [ 10140, 10141, 10142, 10143, 10144, 10145, 10146, 10147, 10148, 10149, 10150, 10151, 10152, 10153, 10154, 10155 ]
|
||||||
|
|
||||||
prometheus:
|
prometheus:
|
||||||
# Enable or disable Prometheus monitoring
|
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
|
||||||
enable: true
|
enable: true
|
||||||
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
|
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
|
||||||
# It will only take effect when autoSetPorts is set to false.
|
# It will only take effect when autoSetPorts is set to false.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
prometheus:
|
prometheus:
|
||||||
# Enable or disable Prometheus monitoring
|
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
|
||||||
enable: true
|
enable: true
|
||||||
# autoSetPorts indicates whether to automatically set the ports
|
# autoSetPorts indicates whether to automatically set the ports
|
||||||
autoSetPorts: true
|
autoSetPorts: true
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ rpc:
|
|||||||
ports: [ 10170, 10171, 10172, 10173, 10174, 10175, 10176, 10177, 10178, 10179, 10180, 10181, 10182, 10183, 10184, 10185 ]
|
ports: [ 10170, 10171, 10172, 10173, 10174, 10175, 10176, 10177, 10178, 10179, 10180, 10181, 10182, 10183, 10184, 10185 ]
|
||||||
|
|
||||||
prometheus:
|
prometheus:
|
||||||
# Enable or disable Prometheus monitoring
|
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
|
||||||
enable: true
|
enable: true
|
||||||
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
|
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
|
||||||
# It will only take effect when autoSetPorts is set to false.
|
# It will only take effect when autoSetPorts is set to false.
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ rpc:
|
|||||||
ports: [ 10200 ]
|
ports: [ 10200 ]
|
||||||
|
|
||||||
prometheus:
|
prometheus:
|
||||||
# Enable or disable Prometheus monitoring
|
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
|
||||||
enable: true
|
enable: true
|
||||||
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
|
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
|
||||||
# It will only take effect when autoSetPorts is set to false.
|
# It will only take effect when autoSetPorts is set to false.
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ rpc:
|
|||||||
ports: [ 10220 ]
|
ports: [ 10220 ]
|
||||||
|
|
||||||
prometheus:
|
prometheus:
|
||||||
# Enable or disable Prometheus monitoring
|
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
|
||||||
enable: true
|
enable: true
|
||||||
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
|
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
|
||||||
# It will only take effect when autoSetPorts is set to false.
|
# It will only take effect when autoSetPorts is set to false.
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ rpc:
|
|||||||
ports: [ 10240 ]
|
ports: [ 10240 ]
|
||||||
|
|
||||||
prometheus:
|
prometheus:
|
||||||
# Enable or disable Prometheus monitoring
|
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
|
||||||
enable: true
|
enable: true
|
||||||
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
|
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
|
||||||
# It will only take effect when autoSetPorts is set to false.
|
# It will only take effect when autoSetPorts is set to false.
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ rpc:
|
|||||||
ports: [ 10260 ]
|
ports: [ 10260 ]
|
||||||
|
|
||||||
prometheus:
|
prometheus:
|
||||||
# Enable or disable Prometheus monitoring
|
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
|
||||||
enable: true
|
enable: true
|
||||||
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
|
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
|
||||||
# It will only take effect when autoSetPorts is set to false.
|
# It will only take effect when autoSetPorts is set to false.
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ rpc:
|
|||||||
ports: [ 10280 ]
|
ports: [ 10280 ]
|
||||||
|
|
||||||
prometheus:
|
prometheus:
|
||||||
# Enable or disable Prometheus monitoring
|
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
|
||||||
enable: true
|
enable: true
|
||||||
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
|
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
|
||||||
# It will only take effect when autoSetPorts is set to false.
|
# It will only take effect when autoSetPorts is set to false.
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ rpc:
|
|||||||
ports: [ 10300 ]
|
ports: [ 10300 ]
|
||||||
|
|
||||||
prometheus:
|
prometheus:
|
||||||
# Enable or disable Prometheus monitoring
|
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
|
||||||
enable: true
|
enable: true
|
||||||
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
|
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
|
||||||
# It will only take effect when autoSetPorts is set to false.
|
# It will only take effect when autoSetPorts is set to false.
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ rpc:
|
|||||||
ports: [ 10320 ]
|
ports: [ 10320 ]
|
||||||
|
|
||||||
prometheus:
|
prometheus:
|
||||||
# Whether to enable prometheus
|
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
|
||||||
enable: true
|
enable: true
|
||||||
# Prometheus listening ports, must be consistent with the number of rpc.ports
|
# Prometheus listening ports, must be consistent with the number of rpc.ports
|
||||||
# It will only take effect when autoSetPorts is set to false.
|
# It will only take effect when autoSetPorts is set to false.
|
||||||
|
|||||||
+24
-25
@@ -1,35 +1,34 @@
|
|||||||
# my global config
|
# Global Prometheus runtime settings.
|
||||||
global:
|
global:
|
||||||
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
|
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.
|
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
|
||||||
# scrape_timeout is set to the global default (10s).
|
# scrape_timeout defaults to 10s unless overridden in a specific scrape job.
|
||||||
|
|
||||||
# Alertmanager configuration
|
# Alertmanager endpoints that receive alert events from Prometheus.
|
||||||
alerting:
|
alerting:
|
||||||
alertmanagers:
|
alertmanagers:
|
||||||
- static_configs:
|
- static_configs:
|
||||||
- targets: [127.0.0.1:19093]
|
- targets: [127.0.0.1:19093] # Alertmanager address in host:port format.
|
||||||
|
|
||||||
# Load rules once and periodically evaluate them according to the global evaluation_interval.
|
# Rule files loaded by Prometheus.
|
||||||
rule_files:
|
rule_files:
|
||||||
- instance-down-rules.yml
|
- instance-down-rules.yml # Default OpenIM alert rules; add more files here if needed.
|
||||||
# - first_rules.yml
|
# - first_rules.yml
|
||||||
# - second_rules.yml
|
# - second_rules.yml
|
||||||
|
|
||||||
# A scrape configuration containing exactly one endpoint to scrape:
|
# Scrape jobs used to collect infrastructure and OpenIM service metrics.
|
||||||
# Here it's Prometheus itself.
|
|
||||||
scrape_configs:
|
scrape_configs:
|
||||||
# The job name is added as a label "job=job_name" to any timeseries scraped from this config.
|
# The job_name value is attached as the "job" label in collected time series.
|
||||||
# Monitored information captured by prometheus
|
|
||||||
|
|
||||||
# prometheus fetches application services
|
|
||||||
- job_name: node_exporter
|
- job_name: node_exporter
|
||||||
static_configs:
|
static_configs:
|
||||||
- targets: [ 127.0.0.1:19100 ]
|
- targets: [ 127.0.0.1:19100 ] # node_exporter endpoint for host CPU, memory, disk, and network metrics.
|
||||||
|
|
||||||
|
# OpenIM services are discovered dynamically from the admin API.
|
||||||
|
# For multi-host deployments, replace 127.0.0.1 with a reachable internal address.
|
||||||
|
|
||||||
- job_name: openimserver-openim-api
|
- job_name: openimserver-openim-api
|
||||||
http_sd_configs:
|
http_sd_configs:
|
||||||
- url: "http://127.0.0.1:10002/prometheus_discovery/api"
|
- url: "http://127.0.0.1:10002/prometheus_discovery/api" # Service discovery endpoint for OpenIM API instances.
|
||||||
# static_configs:
|
# static_configs:
|
||||||
# - targets: [ 127.0.0.1:12002 ]
|
# - targets: [ 127.0.0.1:12002 ]
|
||||||
# labels:
|
# labels:
|
||||||
@@ -37,7 +36,7 @@ scrape_configs:
|
|||||||
|
|
||||||
- job_name: openimserver-openim-msggateway
|
- job_name: openimserver-openim-msggateway
|
||||||
http_sd_configs:
|
http_sd_configs:
|
||||||
- url: "http://127.0.0.1:10002/prometheus_discovery/msg_gateway"
|
- url: "http://127.0.0.1:10002/prometheus_discovery/msg_gateway" # Service discovery endpoint for msggateway instances.
|
||||||
# static_configs:
|
# static_configs:
|
||||||
# - targets: [ 127.0.0.1:12140 ]
|
# - 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 ]
|
# # - 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 ]
|
||||||
@@ -46,7 +45,7 @@ scrape_configs:
|
|||||||
|
|
||||||
- job_name: openimserver-openim-msgtransfer
|
- job_name: openimserver-openim-msgtransfer
|
||||||
http_sd_configs:
|
http_sd_configs:
|
||||||
- url: "http://127.0.0.1:10002/prometheus_discovery/msg_transfer"
|
- url: "http://127.0.0.1:10002/prometheus_discovery/msg_transfer" # Service discovery endpoint for msgtransfer instances.
|
||||||
# static_configs:
|
# static_configs:
|
||||||
# - 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 ]
|
||||||
# # - 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 ]
|
# # - 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 ]
|
||||||
@@ -55,7 +54,7 @@ scrape_configs:
|
|||||||
|
|
||||||
- job_name: openimserver-openim-push
|
- job_name: openimserver-openim-push
|
||||||
http_sd_configs:
|
http_sd_configs:
|
||||||
- url: "http://127.0.0.1:10002/prometheus_discovery/push"
|
- url: "http://127.0.0.1:10002/prometheus_discovery/push" # Service discovery endpoint for push service instances.
|
||||||
# static_configs:
|
# static_configs:
|
||||||
# - 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 ]
|
||||||
## - 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 ]
|
## - 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 ]
|
||||||
@@ -64,7 +63,7 @@ scrape_configs:
|
|||||||
|
|
||||||
- job_name: openimserver-openim-rpc-auth
|
- job_name: openimserver-openim-rpc-auth
|
||||||
http_sd_configs:
|
http_sd_configs:
|
||||||
- url: "http://127.0.0.1:10002/prometheus_discovery/auth"
|
- url: "http://127.0.0.1:10002/prometheus_discovery/auth" # Service discovery endpoint for auth RPC instances.
|
||||||
# static_configs:
|
# static_configs:
|
||||||
# - targets: [ 127.0.0.1:12200 ]
|
# - targets: [ 127.0.0.1:12200 ]
|
||||||
# labels:
|
# labels:
|
||||||
@@ -72,7 +71,7 @@ scrape_configs:
|
|||||||
|
|
||||||
- job_name: openimserver-openim-rpc-conversation
|
- job_name: openimserver-openim-rpc-conversation
|
||||||
http_sd_configs:
|
http_sd_configs:
|
||||||
- url: "http://127.0.0.1:10002/prometheus_discovery/conversation"
|
- url: "http://127.0.0.1:10002/prometheus_discovery/conversation" # Service discovery endpoint for conversation RPC instances.
|
||||||
# static_configs:
|
# static_configs:
|
||||||
# - targets: [ 127.0.0.1:12220 ]
|
# - targets: [ 127.0.0.1:12220 ]
|
||||||
# labels:
|
# labels:
|
||||||
@@ -80,7 +79,7 @@ scrape_configs:
|
|||||||
|
|
||||||
- job_name: openimserver-openim-rpc-friend
|
- job_name: openimserver-openim-rpc-friend
|
||||||
http_sd_configs:
|
http_sd_configs:
|
||||||
- url: "http://127.0.0.1:10002/prometheus_discovery/friend"
|
- url: "http://127.0.0.1:10002/prometheus_discovery/friend" # Service discovery endpoint for friend RPC instances.
|
||||||
# static_configs:
|
# static_configs:
|
||||||
# - targets: [ 127.0.0.1:12240 ]
|
# - targets: [ 127.0.0.1:12240 ]
|
||||||
# labels:
|
# labels:
|
||||||
@@ -88,7 +87,7 @@ scrape_configs:
|
|||||||
|
|
||||||
- job_name: openimserver-openim-rpc-group
|
- job_name: openimserver-openim-rpc-group
|
||||||
http_sd_configs:
|
http_sd_configs:
|
||||||
- url: "http://127.0.0.1:10002/prometheus_discovery/group"
|
- url: "http://127.0.0.1:10002/prometheus_discovery/group" # Service discovery endpoint for group RPC instances.
|
||||||
# static_configs:
|
# static_configs:
|
||||||
# - targets: [ 127.0.0.1:12260 ]
|
# - targets: [ 127.0.0.1:12260 ]
|
||||||
# labels:
|
# labels:
|
||||||
@@ -96,7 +95,7 @@ scrape_configs:
|
|||||||
|
|
||||||
- job_name: openimserver-openim-rpc-msg
|
- job_name: openimserver-openim-rpc-msg
|
||||||
http_sd_configs:
|
http_sd_configs:
|
||||||
- url: "http://127.0.0.1:10002/prometheus_discovery/msg"
|
- url: "http://127.0.0.1:10002/prometheus_discovery/msg" # Service discovery endpoint for msg RPC instances.
|
||||||
# static_configs:
|
# static_configs:
|
||||||
# - targets: [ 127.0.0.1:12280 ]
|
# - targets: [ 127.0.0.1:12280 ]
|
||||||
# labels:
|
# labels:
|
||||||
@@ -104,7 +103,7 @@ scrape_configs:
|
|||||||
|
|
||||||
- job_name: openimserver-openim-rpc-third
|
- job_name: openimserver-openim-rpc-third
|
||||||
http_sd_configs:
|
http_sd_configs:
|
||||||
- url: "http://127.0.0.1:10002/prometheus_discovery/third"
|
- url: "http://127.0.0.1:10002/prometheus_discovery/third" # Service discovery endpoint for third-party RPC instances.
|
||||||
# static_configs:
|
# static_configs:
|
||||||
# - targets: [ 127.0.0.1:12300 ]
|
# - targets: [ 127.0.0.1:12300 ]
|
||||||
# labels:
|
# labels:
|
||||||
@@ -112,8 +111,8 @@ scrape_configs:
|
|||||||
|
|
||||||
- job_name: openimserver-openim-rpc-user
|
- job_name: openimserver-openim-rpc-user
|
||||||
http_sd_configs:
|
http_sd_configs:
|
||||||
- url: "http://127.0.0.1:10002/prometheus_discovery/user"
|
- url: "http://127.0.0.1:10002/prometheus_discovery/user" # Service discovery endpoint for user RPC instances.
|
||||||
# static_configs:
|
# static_configs:
|
||||||
# - targets: [ 127.0.0.1:12320 ]
|
# - targets: [ 127.0.0.1:12320 ]
|
||||||
# labels:
|
# labels:
|
||||||
# namespace: default
|
# namespace: default
|
||||||
|
|||||||
+2
-1
@@ -1,7 +1,8 @@
|
|||||||
address: [ localhost:16379 ]
|
address: [ localhost:16379 ]
|
||||||
username:
|
username:
|
||||||
password: openIM123
|
password: openIM123
|
||||||
clusterMode: false
|
# redisMode can be "cluster", "sentinel", or "standalone"
|
||||||
|
redisMode: "standalone"
|
||||||
db: 0
|
db: 0
|
||||||
maxRetry: 10
|
maxRetry: 10
|
||||||
poolSize: 100
|
poolSize: 100
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module github.com/openimsdk/open-im-server/v3
|
module github.com/openimsdk/open-im-server/v3
|
||||||
|
|
||||||
go 1.22.7
|
go 1.25.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
firebase.google.com/go/v4 v4.14.1
|
firebase.google.com/go/v4 v4.14.1
|
||||||
@@ -13,10 +13,10 @@ require (
|
|||||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
|
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
|
||||||
github.com/mitchellh/mapstructure v1.5.0
|
github.com/mitchellh/mapstructure v1.5.0
|
||||||
github.com/openimsdk/protocol v0.0.73-alpha.12
|
github.com/openimsdk/protocol v0.0.73-alpha.12
|
||||||
github.com/openimsdk/tools v0.0.50-alpha.103
|
github.com/openimsdk/tools v0.0.50-alpha.113
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/prometheus/client_golang v1.18.0
|
github.com/prometheus/client_golang v1.18.0
|
||||||
github.com/stretchr/testify v1.10.0
|
github.com/stretchr/testify v1.11.1
|
||||||
go.mongodb.org/mongo-driver v1.14.0
|
go.mongodb.org/mongo-driver v1.14.0
|
||||||
google.golang.org/api v0.170.0
|
google.golang.org/api v0.170.0
|
||||||
google.golang.org/grpc v1.71.0
|
google.golang.org/grpc v1.71.0
|
||||||
@@ -35,7 +35,7 @@ require (
|
|||||||
github.com/hashicorp/golang-lru/v2 v2.0.7
|
github.com/hashicorp/golang-lru/v2 v2.0.7
|
||||||
github.com/kelindar/bitmap v1.5.2
|
github.com/kelindar/bitmap v1.5.2
|
||||||
github.com/likexian/gokit v0.25.13
|
github.com/likexian/gokit v0.25.13
|
||||||
github.com/openimsdk/gomake v0.0.15-alpha.5
|
github.com/openimsdk/gomake v0.0.17
|
||||||
github.com/redis/go-redis/v9 v9.4.0
|
github.com/redis/go-redis/v9 v9.4.0
|
||||||
github.com/robfig/cron/v3 v3.0.1
|
github.com/robfig/cron/v3 v3.0.1
|
||||||
github.com/shirou/gopsutil v3.21.11+incompatible
|
github.com/shirou/gopsutil v3.21.11+incompatible
|
||||||
@@ -72,6 +72,7 @@ require (
|
|||||||
github.com/aws/aws-sdk-go-v2/service/sts v1.33.1 // indirect
|
github.com/aws/aws-sdk-go-v2/service/sts v1.33.1 // indirect
|
||||||
github.com/aws/smithy-go v1.22.1 // indirect
|
github.com/aws/smithy-go v1.22.1 // indirect
|
||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
|
github.com/bmatcuk/doublestar/v4 v4.10.0 // indirect
|
||||||
github.com/bytedance/sonic v1.11.6 // indirect
|
github.com/bytedance/sonic v1.11.6 // indirect
|
||||||
github.com/bytedance/sonic/loader v0.1.1 // indirect
|
github.com/bytedance/sonic/loader v0.1.1 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||||
@@ -86,6 +87,7 @@ require (
|
|||||||
github.com/eapache/go-resiliency v1.6.0 // indirect
|
github.com/eapache/go-resiliency v1.6.0 // indirect
|
||||||
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect
|
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect
|
||||||
github.com/eapache/queue v1.1.0 // indirect
|
github.com/eapache/queue v1.1.0 // indirect
|
||||||
|
github.com/ebitengine/purego v0.10.0 // indirect
|
||||||
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
|
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
|
||||||
github.com/felixge/httpsnoop v1.0.4 // indirect
|
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||||
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
||||||
@@ -94,7 +96,7 @@ require (
|
|||||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||||
github.com/go-logr/logr v1.4.2 // indirect
|
github.com/go-logr/logr v1.4.2 // indirect
|
||||||
github.com/go-logr/stdr v1.2.2 // indirect
|
github.com/go-logr/stdr v1.2.2 // indirect
|
||||||
github.com/go-ole/go-ole v1.2.6 // indirect
|
github.com/go-ole/go-ole v1.3.0 // indirect
|
||||||
github.com/go-openapi/jsonpointer v0.19.6 // indirect
|
github.com/go-openapi/jsonpointer v0.19.6 // indirect
|
||||||
github.com/go-openapi/jsonreference v0.20.2 // indirect
|
github.com/go-openapi/jsonreference v0.20.2 // indirect
|
||||||
github.com/go-openapi/swag v0.22.4 // indirect
|
github.com/go-openapi/swag v0.22.4 // indirect
|
||||||
@@ -104,7 +106,7 @@ require (
|
|||||||
github.com/golang/protobuf v1.5.4 // indirect
|
github.com/golang/protobuf v1.5.4 // indirect
|
||||||
github.com/golang/snappy v0.0.4 // indirect
|
github.com/golang/snappy v0.0.4 // indirect
|
||||||
github.com/google/gnostic-models v0.6.8 // indirect
|
github.com/google/gnostic-models v0.6.8 // indirect
|
||||||
github.com/google/go-cmp v0.6.0 // indirect
|
github.com/google/go-cmp v0.7.0 // indirect
|
||||||
github.com/google/go-querystring v1.1.0 // indirect
|
github.com/google/go-querystring v1.1.0 // indirect
|
||||||
github.com/google/gofuzz v1.2.0 // indirect
|
github.com/google/gofuzz v1.2.0 // indirect
|
||||||
github.com/google/s2a-go v0.1.7 // indirect
|
github.com/google/s2a-go v0.1.7 // indirect
|
||||||
@@ -131,7 +133,8 @@ require (
|
|||||||
github.com/leodido/go-urn v1.4.0 // indirect
|
github.com/leodido/go-urn v1.4.0 // indirect
|
||||||
github.com/lestrrat-go/strftime v1.0.6 // indirect
|
github.com/lestrrat-go/strftime v1.0.6 // indirect
|
||||||
github.com/lithammer/shortuuid v3.0.0+incompatible // indirect
|
github.com/lithammer/shortuuid v3.0.0+incompatible // indirect
|
||||||
github.com/magefile/mage v1.15.0 // indirect
|
github.com/lufia/plan9stats v0.0.0-20260216142805-b3301c5f2a88 // indirect
|
||||||
|
github.com/magefile/mage v1.16.1 // indirect
|
||||||
github.com/magiconair/properties v1.8.7 // indirect
|
github.com/magiconair/properties v1.8.7 // indirect
|
||||||
github.com/mailru/easyjson v0.7.7 // indirect
|
github.com/mailru/easyjson v0.7.7 // indirect
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
@@ -147,6 +150,7 @@ require (
|
|||||||
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
||||||
github.com/pierrec/lz4/v4 v4.1.21 // indirect
|
github.com/pierrec/lz4/v4 v4.1.21 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||||
|
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
|
||||||
github.com/prometheus/client_model v0.5.0 // indirect
|
github.com/prometheus/client_model v0.5.0 // indirect
|
||||||
github.com/prometheus/common v0.45.0 // indirect
|
github.com/prometheus/common v0.45.0 // indirect
|
||||||
github.com/prometheus/procfs v0.12.0 // indirect
|
github.com/prometheus/procfs v0.12.0 // indirect
|
||||||
@@ -156,6 +160,7 @@ require (
|
|||||||
github.com/sagikazarmark/locafero v0.4.0 // indirect
|
github.com/sagikazarmark/locafero v0.4.0 // indirect
|
||||||
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
|
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
|
||||||
github.com/sercand/kuberesolver/v6 v6.0.1 // indirect
|
github.com/sercand/kuberesolver/v6 v6.0.1 // indirect
|
||||||
|
github.com/shirou/gopsutil/v4 v4.26.2 // indirect
|
||||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||||
github.com/spf13/afero v1.11.0 // indirect
|
github.com/spf13/afero v1.11.0 // indirect
|
||||||
github.com/spf13/cast v1.6.0 // indirect
|
github.com/spf13/cast v1.6.0 // indirect
|
||||||
@@ -163,8 +168,8 @@ require (
|
|||||||
github.com/stretchr/objx v0.5.2 // indirect
|
github.com/stretchr/objx v0.5.2 // indirect
|
||||||
github.com/subosito/gotenv v1.6.0 // indirect
|
github.com/subosito/gotenv v1.6.0 // indirect
|
||||||
github.com/tencentyun/cos-go-sdk-v5 v0.7.47 // indirect
|
github.com/tencentyun/cos-go-sdk-v5 v0.7.47 // indirect
|
||||||
github.com/tklauser/go-sysconf v0.3.13 // indirect
|
github.com/tklauser/go-sysconf v0.3.16 // indirect
|
||||||
github.com/tklauser/numcpus v0.7.0 // indirect
|
github.com/tklauser/numcpus v0.11.0 // indirect
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||||
github.com/x448/float16 v0.8.4 // indirect
|
github.com/x448/float16 v0.8.4 // indirect
|
||||||
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
|
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
|
||||||
@@ -189,7 +194,7 @@ require (
|
|||||||
golang.org/x/image v0.15.0 // indirect
|
golang.org/x/image v0.15.0 // indirect
|
||||||
golang.org/x/net v0.34.0 // indirect
|
golang.org/x/net v0.34.0 // indirect
|
||||||
golang.org/x/oauth2 v0.25.0 // indirect
|
golang.org/x/oauth2 v0.25.0 // indirect
|
||||||
golang.org/x/sys v0.29.0 // indirect
|
golang.org/x/sys v0.42.0 // indirect
|
||||||
golang.org/x/term v0.28.0 // indirect
|
golang.org/x/term v0.28.0 // indirect
|
||||||
golang.org/x/text v0.21.0 // indirect
|
golang.org/x/text v0.21.0 // indirect
|
||||||
golang.org/x/time v0.5.0 // indirect
|
golang.org/x/time v0.5.0 // indirect
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLj
|
|||||||
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
||||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||||
|
github.com/bmatcuk/doublestar/v4 v4.10.0 h1:zU9WiOla1YA122oLM6i4EXvGW62DvKZVxIe6TYWexEs=
|
||||||
|
github.com/bmatcuk/doublestar/v4 v4.10.0/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
|
||||||
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
||||||
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
|
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
|
||||||
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
||||||
@@ -103,6 +105,8 @@ github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 h1:Oy0F4A
|
|||||||
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3/go.mod h1:YvSRo5mw33fLEx1+DlK6L2VV43tJt5Eyel9n9XBcR+0=
|
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3/go.mod h1:YvSRo5mw33fLEx1+DlK6L2VV43tJt5Eyel9n9XBcR+0=
|
||||||
github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc=
|
github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc=
|
||||||
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
|
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
|
||||||
|
github.com/ebitengine/purego v0.10.0 h1:QIw4xfpWT6GWTzaW5XEKy3HXoqrJGx1ijYHzTF0/ISU=
|
||||||
|
github.com/ebitengine/purego v0.10.0/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
|
||||||
github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g=
|
github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g=
|
||||||
github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
|
github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
@@ -134,8 +138,9 @@ github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
|||||||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||||
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
|
|
||||||
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
||||||
|
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
|
||||||
|
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
|
||||||
github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE=
|
github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE=
|
||||||
github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs=
|
github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs=
|
||||||
github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE=
|
github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE=
|
||||||
@@ -202,8 +207,8 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
|||||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||||
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
|
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
|
||||||
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
||||||
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
||||||
@@ -303,8 +308,10 @@ github.com/likexian/gokit v0.25.13 h1:p2Uw3+6fGG53CwdU2Dz0T6bOycdb2+bAFAa3ymwWVk
|
|||||||
github.com/likexian/gokit v0.25.13/go.mod h1:qQhEWFBEfqLCO3/vOEo2EDKd+EycekVtUK4tex+l2H4=
|
github.com/likexian/gokit v0.25.13/go.mod h1:qQhEWFBEfqLCO3/vOEo2EDKd+EycekVtUK4tex+l2H4=
|
||||||
github.com/lithammer/shortuuid v3.0.0+incompatible h1:NcD0xWW/MZYXEHa6ITy6kaXN5nwm/V115vj2YXfhS0w=
|
github.com/lithammer/shortuuid v3.0.0+incompatible h1:NcD0xWW/MZYXEHa6ITy6kaXN5nwm/V115vj2YXfhS0w=
|
||||||
github.com/lithammer/shortuuid v3.0.0+incompatible/go.mod h1:FR74pbAuElzOUuenUHTK2Tciko1/vKuIKS9dSkDrA4w=
|
github.com/lithammer/shortuuid v3.0.0+incompatible/go.mod h1:FR74pbAuElzOUuenUHTK2Tciko1/vKuIKS9dSkDrA4w=
|
||||||
github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg=
|
github.com/lufia/plan9stats v0.0.0-20260216142805-b3301c5f2a88 h1:PTw+yKnXcOFCR6+8hHTyWBeQ/P4Nb7dd4/0ohEcWQuM=
|
||||||
github.com/magefile/mage v1.15.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
|
github.com/lufia/plan9stats v0.0.0-20260216142805-b3301c5f2a88/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg=
|
||||||
|
github.com/magefile/mage v1.16.1 h1:j5UwkdA48xTlGs0Hcm1Q3sSAcxBorntQjiewDNMsqlo=
|
||||||
|
github.com/magefile/mage v1.16.1/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
|
||||||
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
|
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
|
||||||
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
|
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
|
||||||
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
|
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
|
||||||
@@ -345,12 +352,12 @@ github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA
|
|||||||
github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To=
|
github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To=
|
||||||
github.com/onsi/gomega v1.25.0 h1:Vw7br2PCDYijJHSfBOWhov+8cAnUf8MfMaIOV323l6Y=
|
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/onsi/gomega v1.25.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM=
|
||||||
github.com/openimsdk/gomake v0.0.15-alpha.5 h1:eEZCEHm+NsmcO3onXZPIUbGFCYPYbsX5beV3ZyOsGhY=
|
github.com/openimsdk/gomake v0.0.17 h1:q8haP48VOH45WhJRiLj1YSBJyUFJqD8CTedH65i1YH8=
|
||||||
github.com/openimsdk/gomake v0.0.15-alpha.5/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI=
|
github.com/openimsdk/gomake v0.0.17/go.mod h1:nnjS8yCtrPJAt1knMbyPiUwCH2gpyBzj/EZAONfUOXg=
|
||||||
github.com/openimsdk/protocol v0.0.73-alpha.12 h1:2NYawXeHChYUeSme6QJ9pOLh+Empce2WmwEtbP4JvKk=
|
github.com/openimsdk/protocol v0.0.73-alpha.12 h1:2NYawXeHChYUeSme6QJ9pOLh+Empce2WmwEtbP4JvKk=
|
||||||
github.com/openimsdk/protocol v0.0.73-alpha.12/go.mod h1:WF7EuE55vQvpyUAzDXcqg+B+446xQyEba0X35lTINmw=
|
github.com/openimsdk/protocol v0.0.73-alpha.12/go.mod h1:WF7EuE55vQvpyUAzDXcqg+B+446xQyEba0X35lTINmw=
|
||||||
github.com/openimsdk/tools v0.0.50-alpha.103 h1:jYvI86cWiVu8a8iw1panw+pwIiStuUHF76h3fxA6ESI=
|
github.com/openimsdk/tools v0.0.50-alpha.113 h1:rhLWaSJuhjgJFNVzmpChLCG7dPXS0+bte+CPI0008Us=
|
||||||
github.com/openimsdk/tools v0.0.50-alpha.103/go.mod h1:qCExFBqXpQBMzZck3XGIFwivBayAn2KNqB3WAd++IJw=
|
github.com/openimsdk/tools v0.0.50-alpha.113/go.mod h1:x9i/e+WJFW4tocy6RNJQ9NofQiP3KJ1Y576/06TqOG4=
|
||||||
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
|
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/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
|
||||||
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
|
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
|
||||||
@@ -361,6 +368,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
|
|||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
||||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU=
|
||||||
|
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
|
||||||
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
|
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
|
||||||
github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U=
|
github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U=
|
||||||
github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk=
|
github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk=
|
||||||
@@ -397,6 +406,8 @@ github.com/sercand/kuberesolver/v6 v6.0.1 h1:XZUTA0gy/lgDYp/UhEwv7Js24F1j8NJ833Q
|
|||||||
github.com/sercand/kuberesolver/v6 v6.0.1/go.mod h1:C0tsTuRMONSY+Xf7pv7RMW1/JlewY1+wS8SZE+1lf1s=
|
github.com/sercand/kuberesolver/v6 v6.0.1/go.mod h1:C0tsTuRMONSY+Xf7pv7RMW1/JlewY1+wS8SZE+1lf1s=
|
||||||
github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=
|
github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=
|
||||||
github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
|
github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
|
||||||
|
github.com/shirou/gopsutil/v4 v4.26.2 h1:X8i6sicvUFih4BmYIGT1m2wwgw2VG9YgrDTi7cIRGUI=
|
||||||
|
github.com/shirou/gopsutil/v4 v4.26.2/go.mod h1:LZ6ewCSkBqUpvSOf+LsTGnRinC6iaNUNMGBtDkJBaLQ=
|
||||||
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
|
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
|
||||||
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
|
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
|
||||||
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
|
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
|
||||||
@@ -423,18 +434,18 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
|
|||||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||||
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
|
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
|
||||||
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
|
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
|
||||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.563/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
|
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.563/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
|
||||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/kms v1.0.563/go.mod h1:uom4Nvi9W+Qkom0exYiJ9VWJjXwyxtPYTkKkaLMlfE0=
|
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/kms v1.0.563/go.mod h1:uom4Nvi9W+Qkom0exYiJ9VWJjXwyxtPYTkKkaLMlfE0=
|
||||||
github.com/tencentyun/cos-go-sdk-v5 v0.7.47 h1:uoS4Sob16qEYoapkqJq1D1Vnsy9ira9BfNUMtoFYTI4=
|
github.com/tencentyun/cos-go-sdk-v5 v0.7.47 h1:uoS4Sob16qEYoapkqJq1D1Vnsy9ira9BfNUMtoFYTI4=
|
||||||
github.com/tencentyun/cos-go-sdk-v5 v0.7.47/go.mod h1:DH9US8nB+AJXqwu/AMOrCFN1COv3dpytXuJWHgdg7kE=
|
github.com/tencentyun/cos-go-sdk-v5 v0.7.47/go.mod h1:DH9US8nB+AJXqwu/AMOrCFN1COv3dpytXuJWHgdg7kE=
|
||||||
github.com/tklauser/go-sysconf v0.3.13 h1:GBUpcahXSpR2xN01jhkNAbTLRk2Yzgggk8IM08lq3r4=
|
github.com/tklauser/go-sysconf v0.3.16 h1:frioLaCQSsF5Cy1jgRBrzr6t502KIIwQ0MArYICU0nA=
|
||||||
github.com/tklauser/go-sysconf v0.3.13/go.mod h1:zwleP4Q4OehZHGn4CYZDipCgg9usW5IJePewFCGVEa0=
|
github.com/tklauser/go-sysconf v0.3.16/go.mod h1:/qNL9xxDhc7tx3HSRsLWNnuzbVfh3e7gh/BmM179nYI=
|
||||||
github.com/tklauser/numcpus v0.7.0 h1:yjuerZP127QG9m5Zh/mSO4wqurYil27tHrqwRoRjpr4=
|
github.com/tklauser/numcpus v0.11.0 h1:nSTwhKH5e1dMNsCdVBukSZrURJRoHbSEQjdEbY+9RXw=
|
||||||
github.com/tklauser/numcpus v0.7.0/go.mod h1:bb6dMVcj8A42tSE7i32fsIUCbQNllK5iDguyOZRUzAY=
|
github.com/tklauser/numcpus v0.11.0/go.mod h1:z+LwcLq54uWZTX0u/bGobaV34u6V7KNlTZejzM6/3MQ=
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||||
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
|
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
|
||||||
@@ -548,6 +559,7 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||||||
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
@@ -556,8 +568,8 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
|
golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
|
||||||
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
|
|||||||
+10
-151
@@ -16,7 +16,6 @@ package msggateway
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
@@ -31,7 +30,6 @@ import (
|
|||||||
"github.com/openimsdk/tools/errs"
|
"github.com/openimsdk/tools/errs"
|
||||||
"github.com/openimsdk/tools/log"
|
"github.com/openimsdk/tools/log"
|
||||||
"github.com/openimsdk/tools/mcontext"
|
"github.com/openimsdk/tools/mcontext"
|
||||||
"github.com/openimsdk/tools/utils/stringutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -64,7 +62,7 @@ type PingPongHandler func(string) error
|
|||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
w *sync.Mutex
|
w *sync.Mutex
|
||||||
conn LongConn
|
conn ClientConn
|
||||||
PlatformID int `json:"platformID"`
|
PlatformID int `json:"platformID"`
|
||||||
IsCompress bool `json:"isCompress"`
|
IsCompress bool `json:"isCompress"`
|
||||||
UserID string `json:"userID"`
|
UserID string `json:"userID"`
|
||||||
@@ -83,10 +81,10 @@ type Client struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ResetClient updates the client's state with new connection and context information.
|
// ResetClient updates the client's state with new connection and context information.
|
||||||
func (c *Client) ResetClient(ctx *UserConnContext, conn LongConn, longConnServer LongConnServer) {
|
func (c *Client) ResetClient(ctx *UserConnContext, conn ClientConn, longConnServer LongConnServer) {
|
||||||
c.w = new(sync.Mutex)
|
c.w = new(sync.Mutex)
|
||||||
c.conn = conn
|
c.conn = conn
|
||||||
c.PlatformID = stringutil.StringToInt(ctx.GetPlatformID())
|
c.PlatformID = ctx.GetPlatformID()
|
||||||
c.IsCompress = ctx.GetCompression()
|
c.IsCompress = ctx.GetCompression()
|
||||||
c.IsBackground = ctx.GetBackground()
|
c.IsBackground = ctx.GetBackground()
|
||||||
c.UserID = ctx.GetUserID()
|
c.UserID = ctx.GetUserID()
|
||||||
@@ -110,22 +108,6 @@ func (c *Client) ResetClient(ctx *UserConnContext, conn LongConn, longConnServer
|
|||||||
c.subUserIDs = make(map[string]struct{})
|
c.subUserIDs = make(map[string]struct{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) pingHandler(appData string) error {
|
|
||||||
if err := c.conn.SetReadDeadline(pongWait); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
log.ZDebug(c.ctx, "ping Handler Success.", "appData", appData)
|
|
||||||
return c.writePongMsg(appData)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) pongHandler(_ string) error {
|
|
||||||
if err := c.conn.SetReadDeadline(pongWait); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// readMessage continuously reads messages from the connection.
|
// readMessage continuously reads messages from the connection.
|
||||||
func (c *Client) readMessage() {
|
func (c *Client) readMessage() {
|
||||||
defer func() {
|
defer func() {
|
||||||
@@ -136,52 +118,25 @@ func (c *Client) readMessage() {
|
|||||||
c.close()
|
c.close()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
c.conn.SetReadLimit(maxMessageSize)
|
|
||||||
_ = c.conn.SetReadDeadline(pongWait)
|
|
||||||
c.conn.SetPongHandler(c.pongHandler)
|
|
||||||
c.conn.SetPingHandler(c.pingHandler)
|
|
||||||
c.activeHeartbeat(c.hbCtx)
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
log.ZDebug(c.ctx, "readMessage")
|
log.ZDebug(c.ctx, "readMessage")
|
||||||
messageType, message, returnErr := c.conn.ReadMessage()
|
message, returnErr := c.conn.ReadMessage()
|
||||||
if returnErr != nil {
|
if returnErr != nil {
|
||||||
log.ZWarn(c.ctx, "readMessage", returnErr, "messageType", messageType)
|
log.ZWarn(c.ctx, "readMessage", returnErr)
|
||||||
c.closedErr = returnErr
|
c.closedErr = returnErr
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.ZDebug(c.ctx, "readMessage", "messageType", messageType)
|
|
||||||
if c.closed.Load() {
|
if c.closed.Load() {
|
||||||
// The scenario where the connection has just been closed, but the coroutine has not exited
|
// The scenario where the connection has just been closed, but the coroutine has not exited
|
||||||
c.closedErr = ErrConnClosed
|
c.closedErr = ErrConnClosed
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
switch messageType {
|
parseDataErr := c.handleMessage(message)
|
||||||
case MessageBinary:
|
if parseDataErr != nil {
|
||||||
_ = c.conn.SetReadDeadline(pongWait)
|
c.closedErr = parseDataErr
|
||||||
parseDataErr := c.handleMessage(message)
|
|
||||||
if parseDataErr != nil {
|
|
||||||
c.closedErr = parseDataErr
|
|
||||||
return
|
|
||||||
}
|
|
||||||
case MessageText:
|
|
||||||
_ = c.conn.SetReadDeadline(pongWait)
|
|
||||||
parseDataErr := c.handlerTextMessage(message)
|
|
||||||
if parseDataErr != nil {
|
|
||||||
c.closedErr = parseDataErr
|
|
||||||
return
|
|
||||||
}
|
|
||||||
case PingMessage:
|
|
||||||
err := c.writePongMsg("")
|
|
||||||
log.ZError(c.ctx, "writePongMsg", err)
|
|
||||||
|
|
||||||
case CloseMessage:
|
|
||||||
c.closedErr = ErrClientClosed
|
|
||||||
return
|
return
|
||||||
|
|
||||||
default:
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -356,109 +311,13 @@ func (c *Client) writeBinaryMsg(resp Resp) error {
|
|||||||
c.w.Lock()
|
c.w.Lock()
|
||||||
defer c.w.Unlock()
|
defer c.w.Unlock()
|
||||||
|
|
||||||
err = c.conn.SetWriteDeadline(writeWait)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if c.IsCompress {
|
if c.IsCompress {
|
||||||
resultBuf, compressErr := c.longConnServer.CompressWithPool(encodedBuf)
|
resultBuf, compressErr := c.longConnServer.CompressWithPool(encodedBuf)
|
||||||
if compressErr != nil {
|
if compressErr != nil {
|
||||||
return compressErr
|
return compressErr
|
||||||
}
|
}
|
||||||
return c.conn.WriteMessage(MessageBinary, resultBuf)
|
return c.conn.WriteMessage(resultBuf)
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.conn.WriteMessage(MessageBinary, encodedBuf)
|
return c.conn.WriteMessage(encodedBuf)
|
||||||
}
|
|
||||||
|
|
||||||
// Actively initiate Heartbeat when platform in Web.
|
|
||||||
func (c *Client) activeHeartbeat(ctx context.Context) {
|
|
||||||
if c.PlatformID == constant.WebPlatformID {
|
|
||||||
go func() {
|
|
||||||
defer func() {
|
|
||||||
if r := recover(); r != nil {
|
|
||||||
log.ZPanic(ctx, "activeHeartbeat Panic", errs.ErrPanic(r))
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
log.ZDebug(ctx, "server initiative send heartbeat start.")
|
|
||||||
ticker := time.NewTicker(pingPeriod)
|
|
||||||
defer ticker.Stop()
|
|
||||||
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-ticker.C:
|
|
||||||
if err := c.writePingMsg(); err != nil {
|
|
||||||
log.ZWarn(c.ctx, "send Ping Message error.", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
case <-c.hbCtx.Done():
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
func (c *Client) writePingMsg() error {
|
|
||||||
if c.closed.Load() {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
c.w.Lock()
|
|
||||||
defer c.w.Unlock()
|
|
||||||
|
|
||||||
err := c.conn.SetWriteDeadline(writeWait)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return c.conn.WriteMessage(PingMessage, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) writePongMsg(appData string) error {
|
|
||||||
log.ZDebug(c.ctx, "write Pong Msg in Server", "appData", appData)
|
|
||||||
if c.closed.Load() {
|
|
||||||
log.ZWarn(c.ctx, "is closed in server", nil, "appdata", appData, "closed err", c.closedErr)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
c.w.Lock()
|
|
||||||
defer c.w.Unlock()
|
|
||||||
|
|
||||||
err := c.conn.SetWriteDeadline(writeWait)
|
|
||||||
if err != nil {
|
|
||||||
log.ZWarn(c.ctx, "SetWriteDeadline in Server have error", errs.Wrap(err), "writeWait", writeWait, "appData", appData)
|
|
||||||
return errs.Wrap(err)
|
|
||||||
}
|
|
||||||
err = c.conn.WriteMessage(PongMessage, []byte(appData))
|
|
||||||
if err != nil {
|
|
||||||
log.ZWarn(c.ctx, "Write Message have error", errs.Wrap(err), "Pong msg", PongMessage)
|
|
||||||
}
|
|
||||||
|
|
||||||
return errs.Wrap(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) handlerTextMessage(b []byte) error {
|
|
||||||
var msg TextMessage
|
|
||||||
if err := json.Unmarshal(b, &msg); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
switch msg.Type {
|
|
||||||
case TextPong:
|
|
||||||
return nil
|
|
||||||
case TextPing:
|
|
||||||
msg.Type = TextPong
|
|
||||||
msgData, err := json.Marshal(msg)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
c.w.Lock()
|
|
||||||
defer c.w.Unlock()
|
|
||||||
if err := c.conn.SetWriteDeadline(writeWait); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return c.conn.WriteMessage(MessageText, msgData)
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("not support message type %s", msg.Type)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,212 @@
|
|||||||
|
package msggateway
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"sync/atomic"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/gorilla/websocket"
|
||||||
|
|
||||||
|
"github.com/openimsdk/tools/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
var ErrWriteFull = fmt.Errorf("websocket write buffer full,close connection")
|
||||||
|
|
||||||
|
type ClientConn interface {
|
||||||
|
ReadMessage() ([]byte, error)
|
||||||
|
WriteMessage(message []byte) error
|
||||||
|
Close() error
|
||||||
|
}
|
||||||
|
|
||||||
|
type websocketMessage struct {
|
||||||
|
MessageType int
|
||||||
|
Data []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewWebSocketClientConn(conn *websocket.Conn, readLimit int64, readTimeout time.Duration, pingInterval time.Duration) ClientConn {
|
||||||
|
c := &websocketClientConn{
|
||||||
|
readTimeout: readTimeout,
|
||||||
|
conn: conn,
|
||||||
|
writer: make(chan *websocketMessage, 256),
|
||||||
|
done: make(chan struct{}),
|
||||||
|
}
|
||||||
|
if readLimit > 0 {
|
||||||
|
c.conn.SetReadLimit(readLimit)
|
||||||
|
}
|
||||||
|
c.conn.SetPingHandler(c.pingHandler)
|
||||||
|
c.conn.SetPongHandler(c.pongHandler)
|
||||||
|
|
||||||
|
go c.loopSend()
|
||||||
|
if pingInterval > 0 {
|
||||||
|
go c.doPing(pingInterval)
|
||||||
|
}
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
type websocketClientConn struct {
|
||||||
|
readTimeout time.Duration
|
||||||
|
conn *websocket.Conn
|
||||||
|
writer chan *websocketMessage
|
||||||
|
done chan struct{}
|
||||||
|
err atomic.Pointer[error]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *websocketClientConn) ReadMessage() ([]byte, error) {
|
||||||
|
buf, err := c.readMessage()
|
||||||
|
if err != nil {
|
||||||
|
return nil, c.closeBy(fmt.Errorf("read message %w", err))
|
||||||
|
}
|
||||||
|
return buf, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *websocketClientConn) WriteMessage(message []byte) error {
|
||||||
|
return c.writeMessage(websocket.BinaryMessage, message)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *websocketClientConn) Close() error {
|
||||||
|
_ = c.closeBy(fmt.Errorf("websocket connection closed"))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *websocketClientConn) closeBy(err error) error {
|
||||||
|
if !c.err.CompareAndSwap(nil, &err) {
|
||||||
|
return *c.err.Load()
|
||||||
|
}
|
||||||
|
close(c.done)
|
||||||
|
log.ZWarn(context.Background(), "websocket connection closed", err, "remoteAddr", c.conn.RemoteAddr(),
|
||||||
|
"chan length", len(c.writer))
|
||||||
|
_ = c.conn.Close()
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *websocketClientConn) writeMessage(messageType int, data []byte) error {
|
||||||
|
if errPtr := c.err.Load(); errPtr != nil {
|
||||||
|
return *errPtr
|
||||||
|
}
|
||||||
|
select {
|
||||||
|
case c.writer <- &websocketMessage{MessageType: messageType, Data: data}:
|
||||||
|
return nil
|
||||||
|
default:
|
||||||
|
return c.closeBy(ErrWriteFull)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *websocketClientConn) loopSend() {
|
||||||
|
var err error
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-c.done:
|
||||||
|
return
|
||||||
|
case msg := <-c.writer:
|
||||||
|
switch msg.MessageType {
|
||||||
|
case websocket.TextMessage, websocket.BinaryMessage:
|
||||||
|
err = c.conn.WriteMessage(msg.MessageType, msg.Data)
|
||||||
|
default:
|
||||||
|
err = c.conn.WriteControl(msg.MessageType, msg.Data, time.Time{})
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
_ = c.closeBy(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *websocketClientConn) setReadDeadline() error {
|
||||||
|
deadline := time.Now().Add(c.readTimeout)
|
||||||
|
return c.conn.SetReadDeadline(deadline)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *websocketClientConn) readMessage() ([]byte, error) {
|
||||||
|
for {
|
||||||
|
if err := c.setReadDeadline(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
messageType, buf, err := c.conn.ReadMessage()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
switch messageType {
|
||||||
|
case websocket.BinaryMessage:
|
||||||
|
return buf, nil
|
||||||
|
case websocket.TextMessage:
|
||||||
|
if err := c.onReadTextMessage(buf); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
case websocket.PingMessage:
|
||||||
|
if err := c.pingHandler(string(buf)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
case websocket.PongMessage:
|
||||||
|
if err := c.pongHandler(string(buf)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
case websocket.CloseMessage:
|
||||||
|
if len(buf) == 0 {
|
||||||
|
return nil, errors.New("websocket connection closed by peer")
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("websocket connection closed by peer, data %s", string(buf))
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("unknown websocket message type %d", messageType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *websocketClientConn) onReadTextMessage(buf []byte) error {
|
||||||
|
var msg struct {
|
||||||
|
Type string `json:"type"`
|
||||||
|
Body json.RawMessage `json:"body"`
|
||||||
|
}
|
||||||
|
if err := json.Unmarshal(buf, &msg); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
switch msg.Type {
|
||||||
|
case TextPong:
|
||||||
|
return nil
|
||||||
|
case TextPing:
|
||||||
|
msg.Type = TextPong
|
||||||
|
msgData, err := json.Marshal(msg)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return c.writeMessage(websocket.TextMessage, msgData)
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("not support text message type %s", msg.Type)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *websocketClientConn) pingHandler(appData string) error {
|
||||||
|
log.ZWarn(context.Background(), "ping handler recv ping", nil, "remoteAddr", c.conn.RemoteAddr(), "appData", appData)
|
||||||
|
if err := c.setReadDeadline(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err := c.conn.WriteControl(websocket.PongMessage, []byte(appData), time.Now().Add(time.Second*1))
|
||||||
|
if err != nil {
|
||||||
|
log.ZWarn(context.Background(), "ping handler write pong error", err, "remoteAddr", c.conn.RemoteAddr(), "appData", appData)
|
||||||
|
}
|
||||||
|
log.ZWarn(context.Background(), "ping handler write pong success", nil, "remoteAddr", c.conn.RemoteAddr(), "appData", appData)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *websocketClientConn) pongHandler(string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *websocketClientConn) doPing(d time.Duration) {
|
||||||
|
ticker := time.NewTicker(d)
|
||||||
|
defer ticker.Stop()
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-c.done:
|
||||||
|
return
|
||||||
|
case <-ticker.C:
|
||||||
|
if err := c.writeMessage(websocket.PingMessage, nil); err != nil {
|
||||||
|
_ = c.closeBy(fmt.Errorf("send ping %w", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+133
-82
@@ -15,18 +15,31 @@
|
|||||||
package msggateway
|
package msggateway
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/servererrs"
|
"encoding/base64"
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/openimsdk/open-im-server/v3/pkg/common/servererrs"
|
||||||
|
|
||||||
"github.com/openimsdk/protocol/constant"
|
"github.com/openimsdk/protocol/constant"
|
||||||
"github.com/openimsdk/tools/utils/encrypt"
|
"github.com/openimsdk/tools/utils/encrypt"
|
||||||
"github.com/openimsdk/tools/utils/stringutil"
|
|
||||||
"github.com/openimsdk/tools/utils/timeutil"
|
"github.com/openimsdk/tools/utils/timeutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type UserConnContextInfo struct {
|
||||||
|
Token string `json:"token"`
|
||||||
|
UserID string `json:"userID"`
|
||||||
|
PlatformID int `json:"platformID"`
|
||||||
|
OperationID string `json:"operationID"`
|
||||||
|
Compression string `json:"compression"`
|
||||||
|
SDKType string `json:"sdkType"`
|
||||||
|
SendResponse bool `json:"sendResponse"`
|
||||||
|
Background bool `json:"background"`
|
||||||
|
}
|
||||||
|
|
||||||
type UserConnContext struct {
|
type UserConnContext struct {
|
||||||
RespWriter http.ResponseWriter
|
RespWriter http.ResponseWriter
|
||||||
Req *http.Request
|
Req *http.Request
|
||||||
@@ -34,6 +47,7 @@ type UserConnContext struct {
|
|||||||
Method string
|
Method string
|
||||||
RemoteAddr string
|
RemoteAddr string
|
||||||
ConnID string
|
ConnID string
|
||||||
|
info *UserConnContextInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *UserConnContext) Deadline() (deadline time.Time, ok bool) {
|
func (c *UserConnContext) Deadline() (deadline time.Time, ok bool) {
|
||||||
@@ -57,7 +71,7 @@ func (c *UserConnContext) Value(key any) any {
|
|||||||
case constant.ConnID:
|
case constant.ConnID:
|
||||||
return c.GetConnID()
|
return c.GetConnID()
|
||||||
case constant.OpUserPlatform:
|
case constant.OpUserPlatform:
|
||||||
return constant.PlatformIDToName(stringutil.StringToInt(c.GetPlatformID()))
|
return c.GetPlatformID()
|
||||||
case constant.RemoteAddr:
|
case constant.RemoteAddr:
|
||||||
return c.RemoteAddr
|
return c.RemoteAddr
|
||||||
default:
|
default:
|
||||||
@@ -82,30 +96,91 @@ func newContext(respWriter http.ResponseWriter, req *http.Request) *UserConnCont
|
|||||||
|
|
||||||
func newTempContext() *UserConnContext {
|
func newTempContext() *UserConnContext {
|
||||||
return &UserConnContext{
|
return &UserConnContext{
|
||||||
Req: &http.Request{URL: &url.URL{}},
|
Req: &http.Request{URL: &url.URL{}},
|
||||||
|
info: &UserConnContextInfo{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *UserConnContext) ParseEssentialArgs() error {
|
||||||
|
query := c.Req.URL.Query()
|
||||||
|
if data := query.Get("v"); data != "" {
|
||||||
|
return c.parseByJson(data)
|
||||||
|
} else {
|
||||||
|
return c.parseByQuery(query, c.Req.Header)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *UserConnContext) parseByQuery(query url.Values, header http.Header) error {
|
||||||
|
info := UserConnContextInfo{
|
||||||
|
Token: query.Get(Token),
|
||||||
|
UserID: query.Get(WsUserID),
|
||||||
|
OperationID: query.Get(OperationID),
|
||||||
|
Compression: query.Get(Compression),
|
||||||
|
SDKType: query.Get(SDKType),
|
||||||
|
}
|
||||||
|
platformID, err := strconv.Atoi(query.Get(PlatformID))
|
||||||
|
if err != nil {
|
||||||
|
return servererrs.ErrConnArgsErr.WrapMsg("platformID is not int")
|
||||||
|
}
|
||||||
|
info.PlatformID = platformID
|
||||||
|
if val := query.Get(SendResponse); val != "" {
|
||||||
|
ok, err := strconv.ParseBool(val)
|
||||||
|
if err != nil {
|
||||||
|
return servererrs.ErrConnArgsErr.WrapMsg("isMsgResp is not bool")
|
||||||
|
}
|
||||||
|
info.SendResponse = ok
|
||||||
|
}
|
||||||
|
if info.Compression == "" {
|
||||||
|
info.Compression = header.Get(Compression)
|
||||||
|
}
|
||||||
|
background, err := strconv.ParseBool(query.Get(BackgroundStatus))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
info.Background = background
|
||||||
|
return c.checkInfo(&info)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *UserConnContext) parseByJson(data string) error {
|
||||||
|
reqInfo, err := base64.RawURLEncoding.DecodeString(data)
|
||||||
|
if err != nil {
|
||||||
|
return servererrs.ErrConnArgsErr.WrapMsg("data is not base64")
|
||||||
|
}
|
||||||
|
var info UserConnContextInfo
|
||||||
|
if err := json.Unmarshal(reqInfo, &info); err != nil {
|
||||||
|
return servererrs.ErrConnArgsErr.WrapMsg("data is not json", "info", err.Error())
|
||||||
|
}
|
||||||
|
return c.checkInfo(&info)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *UserConnContext) checkInfo(info *UserConnContextInfo) error {
|
||||||
|
if info.OperationID == "" {
|
||||||
|
return servererrs.ErrConnArgsErr.WrapMsg("operationID is empty")
|
||||||
|
}
|
||||||
|
if info.Token == "" {
|
||||||
|
return servererrs.ErrConnArgsErr.WrapMsg("token is empty")
|
||||||
|
}
|
||||||
|
if info.UserID == "" {
|
||||||
|
return servererrs.ErrConnArgsErr.WrapMsg("sendID is empty")
|
||||||
|
}
|
||||||
|
if _, ok := constant.PlatformID2Name[info.PlatformID]; !ok {
|
||||||
|
return servererrs.ErrConnArgsErr.WrapMsg("platformID is invalid")
|
||||||
|
}
|
||||||
|
switch info.SDKType {
|
||||||
|
case "":
|
||||||
|
info.SDKType = GoSDK
|
||||||
|
case GoSDK, JsSDK:
|
||||||
|
default:
|
||||||
|
return servererrs.ErrConnArgsErr.WrapMsg("sdkType is invalid")
|
||||||
|
}
|
||||||
|
c.info = info
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (c *UserConnContext) GetRemoteAddr() string {
|
func (c *UserConnContext) GetRemoteAddr() string {
|
||||||
return c.RemoteAddr
|
return c.RemoteAddr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *UserConnContext) Query(key string) (string, bool) {
|
|
||||||
var value string
|
|
||||||
if value = c.Req.URL.Query().Get(key); value == "" {
|
|
||||||
return value, false
|
|
||||||
}
|
|
||||||
return value, true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *UserConnContext) GetHeader(key string) (string, bool) {
|
|
||||||
var value string
|
|
||||||
if value = c.Req.Header.Get(key); value == "" {
|
|
||||||
return value, false
|
|
||||||
}
|
|
||||||
return value, true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *UserConnContext) SetHeader(key, value string) {
|
func (c *UserConnContext) SetHeader(key, value string) {
|
||||||
c.RespWriter.Header().Set(key, value)
|
c.RespWriter.Header().Set(key, value)
|
||||||
}
|
}
|
||||||
@@ -119,93 +194,69 @@ func (c *UserConnContext) GetConnID() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *UserConnContext) GetUserID() string {
|
func (c *UserConnContext) GetUserID() string {
|
||||||
return c.Req.URL.Query().Get(WsUserID)
|
if c == nil || c.info == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return c.info.UserID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *UserConnContext) GetPlatformID() string {
|
func (c *UserConnContext) GetPlatformID() int {
|
||||||
return c.Req.URL.Query().Get(PlatformID)
|
if c == nil || c.info == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return c.info.PlatformID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *UserConnContext) GetOperationID() string {
|
func (c *UserConnContext) GetOperationID() string {
|
||||||
return c.Req.URL.Query().Get(OperationID)
|
if c == nil || c.info == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return c.info.OperationID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *UserConnContext) SetOperationID(operationID string) {
|
func (c *UserConnContext) SetOperationID(operationID string) {
|
||||||
values := c.Req.URL.Query()
|
if c.info == nil {
|
||||||
values.Set(OperationID, operationID)
|
c.info = &UserConnContextInfo{}
|
||||||
c.Req.URL.RawQuery = values.Encode()
|
}
|
||||||
|
c.info.OperationID = operationID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *UserConnContext) GetToken() string {
|
func (c *UserConnContext) GetToken() string {
|
||||||
return c.Req.URL.Query().Get(Token)
|
if c == nil || c.info == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return c.info.Token
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *UserConnContext) GetCompression() bool {
|
func (c *UserConnContext) GetCompression() bool {
|
||||||
compression, exists := c.Query(Compression)
|
return c != nil && c.info != nil && c.info.Compression == GzipCompressionProtocol
|
||||||
if exists && compression == GzipCompressionProtocol {
|
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
compression, exists := c.GetHeader(Compression)
|
|
||||||
if exists && compression == GzipCompressionProtocol {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *UserConnContext) GetSDKType() string {
|
func (c *UserConnContext) GetSDKType() string {
|
||||||
sdkType := c.Req.URL.Query().Get(SDKType)
|
if c == nil || c.info == nil {
|
||||||
if sdkType == "" {
|
return GoSDK
|
||||||
sdkType = GoSDK
|
}
|
||||||
|
switch c.info.SDKType {
|
||||||
|
case "", GoSDK:
|
||||||
|
return GoSDK
|
||||||
|
case JsSDK:
|
||||||
|
return JsSDK
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
return sdkType
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *UserConnContext) ShouldSendResp() bool {
|
func (c *UserConnContext) ShouldSendResp() bool {
|
||||||
errResp, exists := c.Query(SendResponse)
|
return c != nil && c.info != nil && c.info.SendResponse
|
||||||
if exists {
|
|
||||||
b, err := strconv.ParseBool(errResp)
|
|
||||||
if err != nil {
|
|
||||||
return false
|
|
||||||
} else {
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *UserConnContext) SetToken(token string) {
|
func (c *UserConnContext) SetToken(token string) {
|
||||||
c.Req.URL.RawQuery = Token + "=" + token
|
if c.info == nil {
|
||||||
|
c.info = &UserConnContextInfo{}
|
||||||
|
}
|
||||||
|
c.info.Token = token
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *UserConnContext) GetBackground() bool {
|
func (c *UserConnContext) GetBackground() bool {
|
||||||
b, err := strconv.ParseBool(c.Req.URL.Query().Get(BackgroundStatus))
|
return c != nil && c.info != nil && c.info.Background
|
||||||
if err != nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
func (c *UserConnContext) ParseEssentialArgs() error {
|
|
||||||
_, exists := c.Query(Token)
|
|
||||||
if !exists {
|
|
||||||
return servererrs.ErrConnArgsErr.WrapMsg("token is empty")
|
|
||||||
}
|
|
||||||
_, exists = c.Query(WsUserID)
|
|
||||||
if !exists {
|
|
||||||
return servererrs.ErrConnArgsErr.WrapMsg("sendID is empty")
|
|
||||||
}
|
|
||||||
platformIDStr, exists := c.Query(PlatformID)
|
|
||||||
if !exists {
|
|
||||||
return servererrs.ErrConnArgsErr.WrapMsg("platformID is empty")
|
|
||||||
}
|
|
||||||
_, err := strconv.Atoi(platformIDStr)
|
|
||||||
if err != nil {
|
|
||||||
return servererrs.ErrConnArgsErr.WrapMsg("platformID is not int")
|
|
||||||
}
|
|
||||||
switch sdkType, _ := c.Query(SDKType); sdkType {
|
|
||||||
case "", GoSDK, JsSDK:
|
|
||||||
default:
|
|
||||||
return servererrs.ErrConnArgsErr.WrapMsg("sdkType is not go or js")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,179 +0,0 @@
|
|||||||
// Copyright © 2023 OpenIM. All rights reserved.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package msggateway
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/openimsdk/tools/apiresp"
|
|
||||||
|
|
||||||
"github.com/gorilla/websocket"
|
|
||||||
"github.com/openimsdk/tools/errs"
|
|
||||||
)
|
|
||||||
|
|
||||||
type LongConn interface {
|
|
||||||
// Close this connection
|
|
||||||
Close() error
|
|
||||||
// WriteMessage Write message to connection,messageType means data type,can be set binary(2) and text(1).
|
|
||||||
WriteMessage(messageType int, message []byte) error
|
|
||||||
// ReadMessage Read message from connection.
|
|
||||||
ReadMessage() (int, []byte, error)
|
|
||||||
// SetReadDeadline sets the read deadline on the underlying network connection,
|
|
||||||
// after a read has timed out, will return an error.
|
|
||||||
SetReadDeadline(timeout time.Duration) error
|
|
||||||
// SetWriteDeadline sets to write deadline when send message,when read has timed out,will return error.
|
|
||||||
SetWriteDeadline(timeout time.Duration) error
|
|
||||||
// Dial Try to dial a connection,url must set auth args,header can control compress data
|
|
||||||
Dial(urlStr string, requestHeader http.Header) (*http.Response, error)
|
|
||||||
// IsNil Whether the connection of the current long connection is nil
|
|
||||||
IsNil() bool
|
|
||||||
// SetConnNil Set the connection of the current long connection to nil
|
|
||||||
SetConnNil()
|
|
||||||
// SetReadLimit sets the maximum size for a message read from the peer.bytes
|
|
||||||
SetReadLimit(limit int64)
|
|
||||||
SetPongHandler(handler PingPongHandler)
|
|
||||||
SetPingHandler(handler PingPongHandler)
|
|
||||||
// GenerateLongConn Check the connection of the current and when it was sent are the same
|
|
||||||
GenerateLongConn(w http.ResponseWriter, r *http.Request) error
|
|
||||||
}
|
|
||||||
type GWebSocket struct {
|
|
||||||
protocolType int
|
|
||||||
conn *websocket.Conn
|
|
||||||
handshakeTimeout time.Duration
|
|
||||||
writeBufferSize int
|
|
||||||
}
|
|
||||||
|
|
||||||
func newGWebSocket(protocolType int, handshakeTimeout time.Duration, wbs int) *GWebSocket {
|
|
||||||
return &GWebSocket{protocolType: protocolType, handshakeTimeout: handshakeTimeout, writeBufferSize: wbs}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *GWebSocket) Close() error {
|
|
||||||
return d.conn.Close()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *GWebSocket) GenerateLongConn(w http.ResponseWriter, r *http.Request) error {
|
|
||||||
upgrader := &websocket.Upgrader{
|
|
||||||
HandshakeTimeout: d.handshakeTimeout,
|
|
||||||
CheckOrigin: func(r *http.Request) bool { return true },
|
|
||||||
}
|
|
||||||
if d.writeBufferSize > 0 { // default is 4kb.
|
|
||||||
upgrader.WriteBufferSize = d.writeBufferSize
|
|
||||||
}
|
|
||||||
|
|
||||||
conn, err := upgrader.Upgrade(w, r, nil)
|
|
||||||
if err != nil {
|
|
||||||
// The upgrader.Upgrade method usually returns enough error messages to diagnose problems that may occur during the upgrade
|
|
||||||
return errs.WrapMsg(err, "GenerateLongConn: WebSocket upgrade failed")
|
|
||||||
}
|
|
||||||
d.conn = conn
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *GWebSocket) WriteMessage(messageType int, message []byte) error {
|
|
||||||
// d.setSendConn(d.conn)
|
|
||||||
return d.conn.WriteMessage(messageType, message)
|
|
||||||
}
|
|
||||||
|
|
||||||
// func (d *GWebSocket) setSendConn(sendConn *websocket.Conn) {
|
|
||||||
// d.sendConn = sendConn
|
|
||||||
//}
|
|
||||||
|
|
||||||
func (d *GWebSocket) ReadMessage() (int, []byte, error) {
|
|
||||||
return d.conn.ReadMessage()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *GWebSocket) SetReadDeadline(timeout time.Duration) error {
|
|
||||||
return d.conn.SetReadDeadline(time.Now().Add(timeout))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *GWebSocket) SetWriteDeadline(timeout time.Duration) error {
|
|
||||||
if timeout <= 0 {
|
|
||||||
return errs.New("timeout must be greater than 0")
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO SetWriteDeadline Future add error handling
|
|
||||||
if err := d.conn.SetWriteDeadline(time.Now().Add(timeout)); err != nil {
|
|
||||||
return errs.WrapMsg(err, "GWebSocket.SetWriteDeadline failed")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *GWebSocket) Dial(urlStr string, requestHeader http.Header) (*http.Response, error) {
|
|
||||||
conn, httpResp, err := websocket.DefaultDialer.Dial(urlStr, requestHeader)
|
|
||||||
if err != nil {
|
|
||||||
return httpResp, errs.WrapMsg(err, "GWebSocket.Dial failed", "url", urlStr)
|
|
||||||
}
|
|
||||||
d.conn = conn
|
|
||||||
return httpResp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *GWebSocket) IsNil() bool {
|
|
||||||
return d.conn == nil
|
|
||||||
//
|
|
||||||
// if d.conn != nil {
|
|
||||||
// return false
|
|
||||||
// }
|
|
||||||
// return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *GWebSocket) SetConnNil() {
|
|
||||||
d.conn = nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *GWebSocket) SetReadLimit(limit int64) {
|
|
||||||
d.conn.SetReadLimit(limit)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *GWebSocket) SetPongHandler(handler PingPongHandler) {
|
|
||||||
d.conn.SetPongHandler(handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *GWebSocket) SetPingHandler(handler PingPongHandler) {
|
|
||||||
d.conn.SetPingHandler(handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *GWebSocket) RespondWithError(err error, w http.ResponseWriter, r *http.Request) error {
|
|
||||||
if err := d.GenerateLongConn(w, r); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
data, err := json.Marshal(apiresp.ParseError(err))
|
|
||||||
if err != nil {
|
|
||||||
_ = d.Close()
|
|
||||||
return errs.WrapMsg(err, "json marshal failed")
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := d.WriteMessage(MessageText, data); err != nil {
|
|
||||||
_ = d.Close()
|
|
||||||
return errs.WrapMsg(err, "WriteMessage failed")
|
|
||||||
}
|
|
||||||
_ = d.Close()
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *GWebSocket) RespondWithSuccess() error {
|
|
||||||
data, err := json.Marshal(apiresp.ParseError(nil))
|
|
||||||
if err != nil {
|
|
||||||
_ = d.Close()
|
|
||||||
return errs.WrapMsg(err, "json marshal failed")
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := d.WriteMessage(MessageText, data); err != nil {
|
|
||||||
_ = d.Close()
|
|
||||||
return errs.WrapMsg(err, "WriteMessage failed")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
@@ -2,13 +2,16 @@ package msggateway
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/gorilla/websocket"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
||||||
|
"github.com/openimsdk/tools/apiresp"
|
||||||
|
|
||||||
"github.com/go-playground/validator/v10"
|
"github.com/go-playground/validator/v10"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics"
|
||||||
@@ -26,6 +29,8 @@ import (
|
|||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var wsSuccessResponse, _ = json.Marshal(&apiresp.ApiResponse{})
|
||||||
|
|
||||||
type LongConnServer interface {
|
type LongConnServer interface {
|
||||||
Run(done chan error) error
|
Run(done chan error) error
|
||||||
wsHandler(w http.ResponseWriter, r *http.Request)
|
wsHandler(w http.ResponseWriter, r *http.Request)
|
||||||
@@ -42,6 +47,7 @@ type LongConnServer interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type WsServer struct {
|
type WsServer struct {
|
||||||
|
websocket *websocket.Upgrader
|
||||||
msgGatewayConfig *Config
|
msgGatewayConfig *Config
|
||||||
port int
|
port int
|
||||||
wsMaxConnNum int64
|
wsMaxConnNum int64
|
||||||
@@ -131,9 +137,13 @@ func NewWsServer(msgGatewayConfig *Config, opts ...Option) *WsServer {
|
|||||||
o(&config)
|
o(&config)
|
||||||
}
|
}
|
||||||
//userRpcClient := rpcclient.NewUserRpcClient(client, config.Share.RpcRegisterName.User, config.Share.IMAdminUserID)
|
//userRpcClient := rpcclient.NewUserRpcClient(client, config.Share.RpcRegisterName.User, config.Share.IMAdminUserID)
|
||||||
|
upgrader := &websocket.Upgrader{
|
||||||
|
HandshakeTimeout: config.handshakeTimeout,
|
||||||
|
CheckOrigin: func(r *http.Request) bool { return true },
|
||||||
|
}
|
||||||
v := validator.New()
|
v := validator.New()
|
||||||
return &WsServer{
|
return &WsServer{
|
||||||
|
websocket: upgrader,
|
||||||
msgGatewayConfig: msgGatewayConfig,
|
msgGatewayConfig: msgGatewayConfig,
|
||||||
port: config.port,
|
port: config.port,
|
||||||
wsMaxConnNum: config.maxConnNum,
|
wsMaxConnNum: config.maxConnNum,
|
||||||
@@ -439,16 +449,39 @@ func (ws *WsServer) unregisterClient(client *Client) {
|
|||||||
// validateRespWithRequest checks if the response matches the expected userID and platformID.
|
// validateRespWithRequest checks if the response matches the expected userID and platformID.
|
||||||
func (ws *WsServer) validateRespWithRequest(ctx *UserConnContext, resp *pbAuth.ParseTokenResp) error {
|
func (ws *WsServer) validateRespWithRequest(ctx *UserConnContext, resp *pbAuth.ParseTokenResp) error {
|
||||||
userID := ctx.GetUserID()
|
userID := ctx.GetUserID()
|
||||||
platformID := stringutil.StringToInt32(ctx.GetPlatformID())
|
platformID := ctx.GetPlatformID()
|
||||||
if resp.UserID != userID {
|
if resp.UserID != userID {
|
||||||
return servererrs.ErrTokenInvalid.WrapMsg(fmt.Sprintf("token uid %s != userID %s", resp.UserID, userID))
|
return servererrs.ErrTokenInvalid.WrapMsg(fmt.Sprintf("token uid %s != userID %s", resp.UserID, userID))
|
||||||
}
|
}
|
||||||
if resp.PlatformID != platformID {
|
if int(resp.PlatformID) != platformID {
|
||||||
return servererrs.ErrTokenInvalid.WrapMsg(fmt.Sprintf("token platform %d != platformID %d", resp.PlatformID, platformID))
|
return servererrs.ErrTokenInvalid.WrapMsg(fmt.Sprintf("token platform %d != platformID %d", resp.PlatformID, platformID))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ws *WsServer) handlerError(ctx *UserConnContext, w http.ResponseWriter, r *http.Request, err error) {
|
||||||
|
if !ctx.ShouldSendResp() {
|
||||||
|
httpError(ctx, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// the browser cannot get the response of upgrade failure
|
||||||
|
data, err := json.Marshal(apiresp.ParseError(err))
|
||||||
|
if err != nil {
|
||||||
|
log.ZError(ctx, "json marshal failed", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
conn, upgradeErr := ws.websocket.Upgrade(w, r, nil)
|
||||||
|
if upgradeErr != nil {
|
||||||
|
log.ZWarn(ctx, "websocket upgrade failed", upgradeErr, "respErr", err, "resp", string(data))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer conn.Close()
|
||||||
|
if err := conn.WriteMessage(websocket.TextMessage, data); err != nil {
|
||||||
|
log.ZWarn(ctx, "WriteMessage failed", err, "respErr", err, "resp", string(data))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (ws *WsServer) wsHandler(w http.ResponseWriter, r *http.Request) {
|
func (ws *WsServer) wsHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
// Create a new connection context
|
// Create a new connection context
|
||||||
connContext := newContext(w, r)
|
connContext := newContext(w, r)
|
||||||
@@ -456,7 +489,7 @@ func (ws *WsServer) wsHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
// Check if the current number of online user connections exceeds the maximum limit
|
// Check if the current number of online user connections exceeds the maximum limit
|
||||||
if ws.onlineUserConnNum.Load() >= ws.wsMaxConnNum {
|
if ws.onlineUserConnNum.Load() >= ws.wsMaxConnNum {
|
||||||
// If it exceeds the maximum connection number, return an error via HTTP and stop processing
|
// If it exceeds the maximum connection number, return an error via HTTP and stop processing
|
||||||
httpError(connContext, servererrs.ErrConnOverMaxNumLimit.WrapMsg("over max conn num limit"))
|
ws.handlerError(connContext, w, r, servererrs.ErrConnOverMaxNumLimit.WrapMsg("over max conn num limit"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -464,26 +497,14 @@ func (ws *WsServer) wsHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
err := connContext.ParseEssentialArgs()
|
err := connContext.ParseEssentialArgs()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// If there's an error during parsing, return an error via HTTP and stop processing
|
// If there's an error during parsing, return an error via HTTP and stop processing
|
||||||
|
ws.handlerError(connContext, w, r, err)
|
||||||
httpError(connContext, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call the authentication client to parse the Token obtained from the context
|
// Call the authentication client to parse the Token obtained from the context
|
||||||
resp, err := ws.authClient.ParseToken(connContext, connContext.GetToken())
|
resp, err := ws.authClient.ParseToken(connContext, connContext.GetToken())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// If there's an error parsing the Token, decide whether to send the error message via WebSocket based on the context flag
|
ws.handlerError(connContext, w, r, err)
|
||||||
shouldSendError := connContext.ShouldSendResp()
|
|
||||||
if shouldSendError {
|
|
||||||
// Create a WebSocket connection object and attempt to send the error message via WebSocket
|
|
||||||
wsLongConn := newGWebSocket(WebSocket, ws.handshakeTimeout, ws.writeBufferSize)
|
|
||||||
if err := wsLongConn.RespondWithError(err, w, r); err == nil {
|
|
||||||
// If the error message is successfully sent via WebSocket, stop processing
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// If sending via WebSocket is not required or fails, return the error via HTTP and stop processing
|
|
||||||
httpError(connContext, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -491,32 +512,30 @@ func (ws *WsServer) wsHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
err = ws.validateRespWithRequest(connContext, resp)
|
err = ws.validateRespWithRequest(connContext, resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// If validation fails, return an error via HTTP and stop processing
|
// If validation fails, return an error via HTTP and stop processing
|
||||||
httpError(connContext, err)
|
ws.handlerError(connContext, w, r, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
conn, err := ws.websocket.Upgrade(w, r, nil)
|
||||||
log.ZDebug(connContext, "new conn", "token", connContext.GetToken())
|
if err != nil {
|
||||||
// Create a WebSocket long connection object
|
log.ZWarn(connContext, "websocket upgrade failed", err)
|
||||||
wsLongConn := newGWebSocket(WebSocket, ws.handshakeTimeout, ws.writeBufferSize)
|
|
||||||
if err := wsLongConn.GenerateLongConn(w, r); err != nil {
|
|
||||||
//If the creation of the long connection fails, the error is handled internally during the handshake process.
|
|
||||||
log.ZWarn(connContext, "long connection fails", err)
|
|
||||||
return
|
return
|
||||||
} else {
|
}
|
||||||
// Check if a normal response should be sent via WebSocket
|
if connContext.ShouldSendResp() {
|
||||||
shouldSendSuccessResp := connContext.ShouldSendResp()
|
if err := conn.WriteMessage(websocket.TextMessage, wsSuccessResponse); err != nil {
|
||||||
if shouldSendSuccessResp {
|
log.ZWarn(connContext, "WriteMessage first response", err)
|
||||||
// Attempt to send a success message through WebSocket
|
return
|
||||||
if err := wsLongConn.RespondWithSuccess(); err != nil {
|
|
||||||
// If the success message is successfully sent, end further processing
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.ZDebug(connContext, "new conn", "token", connContext.GetToken())
|
||||||
|
|
||||||
|
var pingInterval time.Duration
|
||||||
|
if connContext.GetPlatformID() == constant.WebPlatformID {
|
||||||
|
pingInterval = pingPeriod
|
||||||
|
}
|
||||||
|
|
||||||
// Retrieve a client object from the client pool, reset its state, and associate it with the current WebSocket long connection
|
// Retrieve a client object from the client pool, reset its state, and associate it with the current WebSocket long connection
|
||||||
client := ws.clientPool.Get().(*Client)
|
client := ws.clientPool.Get().(*Client)
|
||||||
client.ResetClient(connContext, wsLongConn, ws)
|
client.ResetClient(connContext, NewWebSocketClientConn(conn, maxMessageSize, pongWait, pingInterval), ws)
|
||||||
|
|
||||||
// Register the client with the server and start message processing
|
// Register the client with the server and start message processing
|
||||||
ws.registerChan <- client
|
ws.registerChan <- client
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ func (c *conversationServer) GetFullOwnerConversationIDs(ctx context.Context, re
|
|||||||
conversationIDs = nil
|
conversationIDs = nil
|
||||||
}
|
}
|
||||||
return &conversation.GetFullOwnerConversationIDsResp{
|
return &conversation.GetFullOwnerConversationIDsResp{
|
||||||
Version: idHash,
|
Version: uint64(vl.Version),
|
||||||
VersionID: vl.ID.Hex(),
|
VersionID: vl.ID.Hex(),
|
||||||
Equal: req.IdHash == idHash,
|
Equal: req.IdHash == idHash,
|
||||||
ConversationIDs: conversationIDs,
|
ConversationIDs: conversationIDs,
|
||||||
|
|||||||
+291
-276
File diff suppressed because it is too large
Load Diff
@@ -476,14 +476,15 @@ func (g *NotificationSender) GroupApplicationAcceptedNotification(ctx context.Co
|
|||||||
if err = g.fillOpUser(ctx, &opUser, group.GroupID); err != nil {
|
if err = g.fillOpUser(ctx, &opUser, group.GroupID); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tips := &sdkws.GroupApplicationAcceptedTips{
|
uid := g.uuid()
|
||||||
Group: group,
|
|
||||||
OpUser: opUser,
|
|
||||||
HandleMsg: req.HandledMsg,
|
|
||||||
Uuid: g.uuid(),
|
|
||||||
Request: request,
|
|
||||||
}
|
|
||||||
for _, userID := range append(userIDs, req.FromUserID) {
|
for _, userID := range append(userIDs, req.FromUserID) {
|
||||||
|
tips := &sdkws.GroupApplicationAcceptedTips{
|
||||||
|
Group: group,
|
||||||
|
OpUser: opUser,
|
||||||
|
HandleMsg: req.HandledMsg,
|
||||||
|
Uuid: uid,
|
||||||
|
Request: request,
|
||||||
|
}
|
||||||
if userID == req.FromUserID {
|
if userID == req.FromUserID {
|
||||||
tips.ReceiverAs = applicantReceiver
|
tips.ReceiverAs = applicantReceiver
|
||||||
} else {
|
} else {
|
||||||
@@ -520,14 +521,15 @@ func (g *NotificationSender) GroupApplicationRejectedNotification(ctx context.Co
|
|||||||
if err = g.fillOpUser(ctx, &opUser, group.GroupID); err != nil {
|
if err = g.fillOpUser(ctx, &opUser, group.GroupID); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tips := &sdkws.GroupApplicationRejectedTips{
|
uid := g.uuid()
|
||||||
Group: group,
|
|
||||||
OpUser: opUser,
|
|
||||||
HandleMsg: req.HandledMsg,
|
|
||||||
Uuid: g.uuid(),
|
|
||||||
Request: request,
|
|
||||||
}
|
|
||||||
for _, userID := range append(userIDs, req.FromUserID) {
|
for _, userID := range append(userIDs, req.FromUserID) {
|
||||||
|
tips := &sdkws.GroupApplicationRejectedTips{
|
||||||
|
Group: group,
|
||||||
|
OpUser: opUser,
|
||||||
|
HandleMsg: req.HandledMsg,
|
||||||
|
Uuid: uid,
|
||||||
|
Request: request,
|
||||||
|
}
|
||||||
if userID == req.FromUserID {
|
if userID == req.FromUserID {
|
||||||
tips.ReceiverAs = applicantReceiver
|
tips.ReceiverAs = applicantReceiver
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+22
-13
@@ -2,6 +2,7 @@ package group
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/internal/rpc/incrversion"
|
"github.com/openimsdk/open-im-server/v3/internal/rpc/incrversion"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
|
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
|
||||||
@@ -12,23 +13,24 @@ import (
|
|||||||
pbgroup "github.com/openimsdk/protocol/group"
|
pbgroup "github.com/openimsdk/protocol/group"
|
||||||
"github.com/openimsdk/protocol/sdkws"
|
"github.com/openimsdk/protocol/sdkws"
|
||||||
"github.com/openimsdk/tools/errs"
|
"github.com/openimsdk/tools/errs"
|
||||||
|
"github.com/openimsdk/tools/log"
|
||||||
"github.com/openimsdk/tools/mcontext"
|
"github.com/openimsdk/tools/mcontext"
|
||||||
"github.com/openimsdk/tools/utils/datautil"
|
"github.com/openimsdk/tools/utils/datautil"
|
||||||
)
|
)
|
||||||
|
|
||||||
const versionSyncLimit = 500
|
const versionSyncLimit = 500
|
||||||
|
|
||||||
func (g *groupServer) GetFullGroupMemberUserIDs(ctx context.Context, req *pbgroup.GetFullGroupMemberUserIDsReq) (*pbgroup.GetFullGroupMemberUserIDsResp, error) {
|
func (s *groupServer) GetFullGroupMemberUserIDs(ctx context.Context, req *pbgroup.GetFullGroupMemberUserIDsReq) (*pbgroup.GetFullGroupMemberUserIDsResp, error) {
|
||||||
userIDs, err := g.db.FindGroupMemberUserID(ctx, req.GroupID)
|
userIDs, err := s.db.FindGroupMemberUserID(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if !authverify.IsAppManagerUid(ctx, g.config.Share.IMAdminUserID) {
|
if !authverify.IsAppManagerUid(ctx, s.config.Share.IMAdminUserID) {
|
||||||
if !datautil.Contain(mcontext.GetOpUserID(ctx), userIDs...) {
|
if !datautil.Contain(mcontext.GetOpUserID(ctx), userIDs...) {
|
||||||
return nil, errs.ErrNoPermission.WrapMsg("op user not in group")
|
return nil, errs.ErrNoPermission.WrapMsg("op user not in group")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vl, err := g.db.FindMaxGroupMemberVersionCache(ctx, req.GroupID)
|
vl, err := s.db.FindMaxGroupMemberVersionCache(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -37,7 +39,7 @@ func (g *groupServer) GetFullGroupMemberUserIDs(ctx context.Context, req *pbgrou
|
|||||||
userIDs = nil
|
userIDs = nil
|
||||||
}
|
}
|
||||||
return &pbgroup.GetFullGroupMemberUserIDsResp{
|
return &pbgroup.GetFullGroupMemberUserIDsResp{
|
||||||
Version: idHash,
|
Version: uint64(vl.Version),
|
||||||
VersionID: vl.ID.Hex(),
|
VersionID: vl.ID.Hex(),
|
||||||
Equal: req.IdHash == idHash,
|
Equal: req.IdHash == idHash,
|
||||||
UserIDs: userIDs,
|
UserIDs: userIDs,
|
||||||
@@ -61,7 +63,7 @@ func (s *groupServer) GetFullJoinGroupIDs(ctx context.Context, req *pbgroup.GetF
|
|||||||
groupIDs = nil
|
groupIDs = nil
|
||||||
}
|
}
|
||||||
return &pbgroup.GetFullJoinGroupIDsResp{
|
return &pbgroup.GetFullJoinGroupIDsResp{
|
||||||
Version: idHash,
|
Version: uint64(vl.Version),
|
||||||
VersionID: vl.ID.Hex(),
|
VersionID: vl.ID.Hex(),
|
||||||
Equal: req.IdHash == idHash,
|
Equal: req.IdHash == idHash,
|
||||||
GroupIDs: groupIDs,
|
GroupIDs: groupIDs,
|
||||||
@@ -146,8 +148,8 @@ func (s *groupServer) GetIncrementalGroupMember(ctx context.Context, req *pbgrou
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *groupServer) GetIncrementalJoinGroup(ctx context.Context, req *pbgroup.GetIncrementalJoinGroupReq) (*pbgroup.GetIncrementalJoinGroupResp, error) {
|
func (s *groupServer) GetIncrementalJoinGroup(ctx context.Context, req *pbgroup.GetIncrementalJoinGroupReq) (*pbgroup.GetIncrementalJoinGroupResp, error) {
|
||||||
if err := authverify.CheckAccessV3(ctx, req.UserID, g.config.Share.IMAdminUserID); err != nil {
|
if err := authverify.CheckAccessV3(ctx, req.UserID, s.config.Share.IMAdminUserID); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
opt := incrversion.Option[*sdkws.GroupInfo, pbgroup.GetIncrementalJoinGroupResp]{
|
opt := incrversion.Option[*sdkws.GroupInfo, pbgroup.GetIncrementalJoinGroupResp]{
|
||||||
@@ -155,9 +157,9 @@ func (g *groupServer) GetIncrementalJoinGroup(ctx context.Context, req *pbgroup.
|
|||||||
VersionKey: req.UserID,
|
VersionKey: req.UserID,
|
||||||
VersionID: req.VersionID,
|
VersionID: req.VersionID,
|
||||||
VersionNumber: req.Version,
|
VersionNumber: req.Version,
|
||||||
Version: g.db.FindJoinIncrVersion,
|
Version: s.db.FindJoinIncrVersion,
|
||||||
CacheMaxVersion: g.db.FindMaxJoinGroupVersionCache,
|
CacheMaxVersion: s.db.FindMaxJoinGroupVersionCache,
|
||||||
Find: g.getGroupsInfo,
|
Find: s.getGroupsInfo,
|
||||||
Resp: func(version *model.VersionLog, delIDs []string, insertList, updateList []*sdkws.GroupInfo, full bool) *pbgroup.GetIncrementalJoinGroupResp {
|
Resp: func(version *model.VersionLog, delIDs []string, insertList, updateList []*sdkws.GroupInfo, full bool) *pbgroup.GetIncrementalJoinGroupResp {
|
||||||
return &pbgroup.GetIncrementalJoinGroupResp{
|
return &pbgroup.GetIncrementalJoinGroupResp{
|
||||||
VersionID: version.ID.Hex(),
|
VersionID: version.ID.Hex(),
|
||||||
@@ -172,22 +174,29 @@ func (g *groupServer) GetIncrementalJoinGroup(ctx context.Context, req *pbgroup.
|
|||||||
return opt.Build()
|
return opt.Build()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *groupServer) BatchGetIncrementalGroupMember(ctx context.Context, req *pbgroup.BatchGetIncrementalGroupMemberReq) (*pbgroup.BatchGetIncrementalGroupMemberResp, error) {
|
func (s *groupServer) BatchGetIncrementalGroupMember(ctx context.Context, req *pbgroup.BatchGetIncrementalGroupMemberReq) (*pbgroup.BatchGetIncrementalGroupMemberResp, error) {
|
||||||
var num int
|
var num int
|
||||||
resp := make(map[string]*pbgroup.GetIncrementalGroupMemberResp)
|
resp := make(map[string]*pbgroup.GetIncrementalGroupMemberResp)
|
||||||
|
|
||||||
for _, memberReq := range req.ReqList {
|
for _, memberReq := range req.ReqList {
|
||||||
if _, ok := resp[memberReq.GroupID]; ok {
|
if _, ok := resp[memberReq.GroupID]; ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
memberResp, err := g.GetIncrementalGroupMember(ctx, memberReq)
|
memberResp, err := s.GetIncrementalGroupMember(ctx, memberReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if errors.Is(err, servererrs.ErrDismissedAlready) {
|
||||||
|
log.ZWarn(ctx, "Failed to get incremental group member", err, "groupID", memberReq.GroupID, "request", memberReq)
|
||||||
|
continue
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp[memberReq.GroupID] = memberResp
|
resp[memberReq.GroupID] = memberResp
|
||||||
num += len(memberResp.Insert) + len(memberResp.Update) + len(memberResp.Delete)
|
num += len(memberResp.Insert) + len(memberResp.Update) + len(memberResp.Delete)
|
||||||
if num >= versionSyncLimit {
|
if num >= versionSyncLimit {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pbgroup.BatchGetIncrementalGroupMemberResp{RespList: resp}, nil
|
return &pbgroup.BatchGetIncrementalGroupMemberResp{RespList: resp}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,8 +87,9 @@ func (m *msgServer) setConversationAtInfo(nctx context.Context, msg *sdkws.MsgDa
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
// template admin permission for next operation
|
||||||
ctx := mcontext.NewCtx("@@@" + mcontext.GetOperationID(nctx))
|
ctx := mcontext.NewCtx("@@@" + mcontext.GetOperationID(nctx))
|
||||||
|
ctx = mcontext.WithOpUserIDContext(ctx, m.config.Share.IMAdminUserID[0])
|
||||||
var atUserID []string
|
var atUserID []string
|
||||||
|
|
||||||
conversation := &pbconversation.ConversationReq{
|
conversation := &pbconversation.ConversationReq{
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ func (s *friendServer) GetFullFriendUserIDs(ctx context.Context, req *relation.G
|
|||||||
userIDs = nil
|
userIDs = nil
|
||||||
}
|
}
|
||||||
return &relation.GetFullFriendUserIDsResp{
|
return &relation.GetFullFriendUserIDsResp{
|
||||||
Version: idHash,
|
Version: uint64(vl.Version),
|
||||||
VersionID: vl.ID.Hex(),
|
VersionID: vl.ID.Hex(),
|
||||||
Equal: req.IdHash == idHash,
|
Equal: req.IdHash == idHash,
|
||||||
UserIDs: userIDs,
|
UserIDs: userIDs,
|
||||||
|
|||||||
+101
-4
@@ -5,22 +5,58 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/openimsdk/gomake/mageutil"
|
"github.com/openimsdk/gomake/mageutil"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/version"
|
||||||
|
"github.com/openimsdk/tools/utils/datautil"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Default = Build
|
var Default = Build
|
||||||
|
|
||||||
|
var Aliases = map[string]any{
|
||||||
|
"buildcc": BuildWithCustomConfig,
|
||||||
|
"startcc": StartWithCustomConfig,
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
customRootDir = "." // workDir in mage, default is "./"(project root directory)
|
||||||
|
customSrcDir = "cmd" // source code directory, default is "cmd"
|
||||||
|
customOutputDir = "_output" // output directory, default is "_output"
|
||||||
|
customConfigDir = "config" // configuration directory, default is "config"
|
||||||
|
customToolsDir = "tools" // tools source code directory, default is "tools"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Build support specifical binary build.
|
||||||
|
//
|
||||||
|
// Example: `mage build openim-api openim-rpc-user seq`
|
||||||
func Build() {
|
func Build() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
bin := flag.Args()
|
||||||
|
if len(bin) != 0 {
|
||||||
|
bin = bin[1:]
|
||||||
|
}
|
||||||
|
mageutil.WithSpinner("Building binaries...", func() { mageutil.Build(bin, nil, nil) })
|
||||||
|
}
|
||||||
|
|
||||||
|
func BuildWithCustomConfig() {
|
||||||
|
flag.Parse()
|
||||||
bin := flag.Args()
|
bin := flag.Args()
|
||||||
if len(bin) != 0 {
|
if len(bin) != 0 {
|
||||||
bin = bin[1:]
|
bin = bin[1:]
|
||||||
}
|
}
|
||||||
|
|
||||||
mageutil.Build(bin)
|
config := &mageutil.PathOptions{
|
||||||
|
RootDir: &customRootDir,
|
||||||
|
OutputDir: &customOutputDir,
|
||||||
|
SrcDir: &customSrcDir,
|
||||||
|
ToolsDir: &customToolsDir,
|
||||||
|
}
|
||||||
|
|
||||||
|
mageutil.WithSpinner("Building binaries with custom config...", func() {
|
||||||
|
mageutil.Build(bin, config, nil)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func Start() {
|
func Start() {
|
||||||
@@ -30,13 +66,74 @@ func Start() {
|
|||||||
mageutil.PrintRed("setMaxOpenFiles failed " + err.Error())
|
mageutil.PrintRed("setMaxOpenFiles failed " + err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
mageutil.StartToolsAndServices()
|
|
||||||
|
flag.Parse()
|
||||||
|
bin := flag.Args()
|
||||||
|
if len(bin) != 0 {
|
||||||
|
bin = bin[1:]
|
||||||
|
}
|
||||||
|
|
||||||
|
mageutil.WithSpinner("Starting...", func() {
|
||||||
|
mageutil.StartToolsAndServices(bin, nil)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func StartWithCustomConfig() {
|
||||||
|
mageutil.InitForSSC()
|
||||||
|
err := setMaxOpenFiles()
|
||||||
|
if err != nil {
|
||||||
|
mageutil.PrintRed("setMaxOpenFiles failed " + err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
flag.Parse()
|
||||||
|
bin := flag.Args()
|
||||||
|
if len(bin) != 0 {
|
||||||
|
bin = bin[1:]
|
||||||
|
}
|
||||||
|
|
||||||
|
config := &mageutil.PathOptions{
|
||||||
|
RootDir: &customRootDir,
|
||||||
|
OutputDir: &customOutputDir,
|
||||||
|
ConfigDir: &customConfigDir,
|
||||||
|
}
|
||||||
|
|
||||||
|
mageutil.WithSpinner("Starting with custom config...", func() {
|
||||||
|
mageutil.StartToolsAndServices(bin, config)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func Stop() {
|
func Stop() {
|
||||||
mageutil.StopAndCheckBinaries()
|
mageutil.WithSpinner("Stopping...", mageutil.StopAndCheckBinaries)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Check() {
|
func Check() {
|
||||||
mageutil.CheckAndReportBinariesStatus()
|
mageutil.WithSpinner("Checking binaries...", mageutil.CheckAndReportBinariesStatus)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Export() {
|
||||||
|
mappingPaths, err := mageutil.GetDefaultExportMappingPaths([]string{
|
||||||
|
"cmd",
|
||||||
|
"internal",
|
||||||
|
"pkg",
|
||||||
|
"test",
|
||||||
|
"tools",
|
||||||
|
"**/*.go",
|
||||||
|
"go.mod",
|
||||||
|
"go.work",
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
mageutil.PrintRed("GetDefaultExportMappingPaths failed " + err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
mageutil.WithSpinner("Exporting...", func() {
|
||||||
|
mageutil.ExportMageLauncherArchived(mappingPaths, &mageutil.ExportOptions{
|
||||||
|
ProjectName: datautil.ToPtr(fmt.Sprintf("open-im-server_%s", version.Version)),
|
||||||
|
BuildOpt: &mageutil.BuildOptions{
|
||||||
|
Release: datautil.ToPtr(true),
|
||||||
|
Compress: datautil.ToPtr(true),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-14
@@ -354,13 +354,13 @@ type User struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Redis struct {
|
type Redis struct {
|
||||||
Address []string `mapstructure:"address"`
|
Address []string `mapstructure:"address"`
|
||||||
Username string `mapstructure:"username"`
|
Username string `mapstructure:"username"`
|
||||||
Password string `mapstructure:"password"`
|
Password string `mapstructure:"password"`
|
||||||
ClusterMode bool `mapstructure:"clusterMode"`
|
RedisMode string `mapstructure:"redisMode"`
|
||||||
DB int `mapstructure:"db"`
|
DB int `mapstructure:"db"`
|
||||||
MaxRetry int `mapstructure:"maxRetry"`
|
MaxRetry int `mapstructure:"maxRetry"`
|
||||||
PoolSize int `mapstructure:"poolSize"`
|
PoolSize int `mapstructure:"poolSize"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type BeforeConfig struct {
|
type BeforeConfig struct {
|
||||||
@@ -511,13 +511,13 @@ func (m *Mongo) Build() *mongoutil.Config {
|
|||||||
|
|
||||||
func (r *Redis) Build() *redisutil.Config {
|
func (r *Redis) Build() *redisutil.Config {
|
||||||
return &redisutil.Config{
|
return &redisutil.Config{
|
||||||
ClusterMode: r.ClusterMode,
|
RedisMode: r.RedisMode,
|
||||||
Address: r.Address,
|
Address: r.Address,
|
||||||
Username: r.Username,
|
Username: r.Username,
|
||||||
Password: r.Password,
|
Password: r.Password,
|
||||||
DB: r.DB,
|
DB: r.DB,
|
||||||
MaxRetry: r.MaxRetry,
|
MaxRetry: r.MaxRetry,
|
||||||
PoolSize: r.PoolSize,
|
PoolSize: r.PoolSize,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ const (
|
|||||||
BlockedByPeer = 1302 // Blocked by the peer
|
BlockedByPeer = 1302 // Blocked by the peer
|
||||||
NotPeersFriend = 1303 // Not the peer's friend
|
NotPeersFriend = 1303 // Not the peer's friend
|
||||||
RelationshipAlreadyError = 1304 // Already in a friend relationship
|
RelationshipAlreadyError = 1304 // Already in a friend relationship
|
||||||
|
FriendRequestHandled = 1305 // Friend request has already been handled
|
||||||
|
|
||||||
// Message error codes.
|
// Message error codes.
|
||||||
MessageHasReadDisable = 1401
|
MessageHasReadDisable = 1401
|
||||||
|
|||||||
@@ -49,10 +49,11 @@ var (
|
|||||||
|
|
||||||
ErrMessageHasReadDisable = errs.NewCodeError(MessageHasReadDisable, "MessageHasReadDisable")
|
ErrMessageHasReadDisable = errs.NewCodeError(MessageHasReadDisable, "MessageHasReadDisable")
|
||||||
|
|
||||||
ErrCanNotAddYourself = errs.NewCodeError(CanNotAddYourselfError, "CanNotAddYourselfError")
|
ErrCanNotAddYourself = errs.NewCodeError(CanNotAddYourselfError, "CanNotAddYourselfError")
|
||||||
ErrBlockedByPeer = errs.NewCodeError(BlockedByPeer, "BlockedByPeer")
|
ErrBlockedByPeer = errs.NewCodeError(BlockedByPeer, "BlockedByPeer")
|
||||||
ErrNotPeersFriend = errs.NewCodeError(NotPeersFriend, "NotPeersFriend")
|
ErrNotPeersFriend = errs.NewCodeError(NotPeersFriend, "NotPeersFriend")
|
||||||
ErrRelationshipAlready = errs.NewCodeError(RelationshipAlreadyError, "RelationshipAlreadyError")
|
ErrRelationshipAlready = errs.NewCodeError(RelationshipAlreadyError, "RelationshipAlreadyError")
|
||||||
|
ErrFriendRequestHandled = errs.NewCodeError(FriendRequestHandled, "FriendRequestHandled")
|
||||||
|
|
||||||
ErrMutedInGroup = errs.NewCodeError(MutedInGroup, "MutedInGroup")
|
ErrMutedInGroup = errs.NewCodeError(MutedInGroup, "MutedInGroup")
|
||||||
ErrMutedGroup = errs.NewCodeError(MutedGroup, "MutedGroup")
|
ErrMutedGroup = errs.NewCodeError(MutedGroup, "MutedGroup")
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ package controller
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/openimsdk/open-im-server/v3/pkg/common/servererrs"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database/mgo"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database/mgo"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
|
||||||
@@ -109,15 +109,13 @@ func (f *friendDatabase) CheckIn(ctx context.Context, userID1, userID2 string) (
|
|||||||
// Retrieve friend IDs of userID1 from the cache
|
// Retrieve friend IDs of userID1 from the cache
|
||||||
userID1FriendIDs, err := f.cache.GetFriendIDs(ctx, userID1)
|
userID1FriendIDs, err := f.cache.GetFriendIDs(ctx, userID1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error retrieving friend IDs for user %s: %w", userID1, err)
|
return false, false, err
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve friend IDs of userID2 from the cache
|
// Retrieve friend IDs of userID2 from the cache
|
||||||
userID2FriendIDs, err := f.cache.GetFriendIDs(ctx, userID2)
|
userID2FriendIDs, err := f.cache.GetFriendIDs(ctx, userID2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error retrieving friend IDs for user %s: %w", userID2, err)
|
return false, false, err
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if userID2 is in userID1's friend list and vice versa
|
// Check if userID2 is in userID1's friend list and vice versa
|
||||||
@@ -214,12 +212,12 @@ func (f *friendDatabase) RefuseFriendRequest(ctx context.Context, friendRequest
|
|||||||
// Attempt to retrieve the friend request from the database.
|
// Attempt to retrieve the friend request from the database.
|
||||||
fr, err := f.friendRequest.Take(ctx, friendRequest.FromUserID, friendRequest.ToUserID)
|
fr, err := f.friendRequest.Take(ctx, friendRequest.FromUserID, friendRequest.ToUserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to retrieve friend request from %s to %s: %w", friendRequest.FromUserID, friendRequest.ToUserID, err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the friend request has already been handled.
|
// Check if the friend request has already been handled.
|
||||||
if fr.HandleResult != 0 {
|
if fr.HandleResult != 0 {
|
||||||
return fmt.Errorf("friend request from %s to %s has already been processed", friendRequest.FromUserID, friendRequest.ToUserID)
|
return servererrs.ErrFriendRequestHandled.WrapMsg("friend request has already been processed", "from", friendRequest.FromUserID, "to", friendRequest.ToUserID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log the action of refusing the friend request for debugging and auditing purposes.
|
// Log the action of refusing the friend request for debugging and auditing purposes.
|
||||||
@@ -232,7 +230,7 @@ func (f *friendDatabase) RefuseFriendRequest(ctx context.Context, friendRequest
|
|||||||
friendRequest.HandleResult = constant.FriendResponseRefuse
|
friendRequest.HandleResult = constant.FriendResponseRefuse
|
||||||
friendRequest.HandleTime = time.Now()
|
friendRequest.HandleTime = time.Now()
|
||||||
if err := f.friendRequest.Update(ctx, friendRequest); err != nil {
|
if err := f.friendRequest.Update(ctx, friendRequest); err != nil {
|
||||||
return fmt.Errorf("failed to update friend request from %s to %s as refused: %w", friendRequest.FromUserID, friendRequest.ToUserID, err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -350,9 +348,9 @@ func (f *friendDatabase) PageFriendRequestToMe(ctx context.Context, userID strin
|
|||||||
func (f *friendDatabase) FindFriendsWithError(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*model.Friend, err error) {
|
func (f *friendDatabase) FindFriendsWithError(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*model.Friend, err error) {
|
||||||
friends, err = f.friend.FindFriends(ctx, ownerUserID, friendUserIDs)
|
friends, err = f.friend.FindFriends(ctx, ownerUserID, friendUserIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return nil, err
|
||||||
}
|
}
|
||||||
return
|
return friends, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *friendDatabase) FindFriendUserIDs(ctx context.Context, ownerUserID string) (friendUserIDs []string, err error) {
|
func (f *friendDatabase) FindFriendUserIDs(ctx context.Context, ownerUserID string) (friendUserIDs []string, err error) {
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ func (s *seqConversationMongo) Malloc(ctx context.Context, conversationID string
|
|||||||
}
|
}
|
||||||
filter := map[string]any{"conversation_id": conversationID}
|
filter := map[string]any{"conversation_id": conversationID}
|
||||||
update := map[string]any{
|
update := map[string]any{
|
||||||
"$inc": map[string]any{"max_seq": size},
|
"$inc": map[string]any{"max_seq": size},
|
||||||
"$set": map[string]any{"min_seq": int64(0)},
|
"$setOnInsert": map[string]any{"min_seq": int64(0)},
|
||||||
}
|
}
|
||||||
opt := options.FindOneAndUpdate().SetUpsert(true).SetReturnDocument(options.After).SetProjection(map[string]any{"_id": 0, "max_seq": 1})
|
opt := options.FindOneAndUpdate().SetUpsert(true).SetReturnDocument(options.After).SetProjection(map[string]any{"_id": 0, "max_seq": 1})
|
||||||
lastSeq, err := mongoutil.FindOneAndUpdate[int64](ctx, s.coll, filter, update, opt)
|
lastSeq, err := mongoutil.FindOneAndUpdate[int64](ctx, s.coll, filter, update, opt)
|
||||||
|
|||||||
+14
-7
@@ -49,7 +49,7 @@ func New[V any](opts ...Option) Cache[V] {
|
|||||||
if opt.expirationEvict {
|
if opt.expirationEvict {
|
||||||
return lru.NewExpirationLRU[string, V](opt.localSlotSize, opt.localSuccessTTL, opt.localFailedTTL, opt.target, c.onEvict)
|
return lru.NewExpirationLRU[string, V](opt.localSlotSize, opt.localSuccessTTL, opt.localFailedTTL, opt.target, c.onEvict)
|
||||||
} else {
|
} else {
|
||||||
return lru.NewLayLRU[string, V](opt.localSlotSize, opt.localSuccessTTL, opt.localFailedTTL, opt.target, c.onEvict)
|
return lru.NewLazyLRU[string, V](opt.localSlotSize, opt.localSuccessTTL, opt.localFailedTTL, opt.target, c.onEvict)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if opt.localSlotNum == 1 {
|
if opt.localSlotNum == 1 {
|
||||||
@@ -72,11 +72,18 @@ type cache[V any] struct {
|
|||||||
|
|
||||||
func (c *cache[V]) onEvict(key string, value V) {
|
func (c *cache[V]) onEvict(key string, value V) {
|
||||||
if c.link != nil {
|
if c.link != nil {
|
||||||
lks := c.link.Del(key)
|
// Do not delete other keys while the underlying LRU still holds its lock;
|
||||||
for k := range lks {
|
// defer linked deletions to avoid re-entering the same slot and deadlocking.
|
||||||
if key != k { // prevent deadlock
|
if lks := c.link.Del(key); len(lks) > 0 {
|
||||||
c.local.Del(k)
|
go c.delLinked(key, lks)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *cache[V]) delLinked(src string, keys map[string]struct{}) {
|
||||||
|
for k := range keys {
|
||||||
|
if src != k {
|
||||||
|
c.local.Del(k)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,7 +110,7 @@ func (c *cache[V]) Get(ctx context.Context, key string, fetch func(ctx context.C
|
|||||||
func (c *cache[V]) GetLink(ctx context.Context, key string, fetch func(ctx context.Context) (V, error), link ...string) (V, error) {
|
func (c *cache[V]) GetLink(ctx context.Context, key string, fetch func(ctx context.Context) (V, error), link ...string) (V, error) {
|
||||||
if c.local != nil {
|
if c.local != nil {
|
||||||
return c.local.Get(key, func() (V, error) {
|
return c.local.Get(key, func() (V, error) {
|
||||||
if len(link) > 0 {
|
if len(link) > 0 && c.link != nil {
|
||||||
c.link.Link(key, link...)
|
c.link.Link(key, link...)
|
||||||
}
|
}
|
||||||
return fetch(ctx)
|
return fetch(ctx)
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/openimsdk/open-im-server/v3/pkg/localcache/lru"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestName(t *testing.T) {
|
func TestName(t *testing.T) {
|
||||||
@@ -91,3 +93,68 @@ func TestName(t *testing.T) {
|
|||||||
t.Log("del", del.Load())
|
t.Log("del", del.Load())
|
||||||
// 137.35s
|
// 137.35s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test deadlock scenario when eviction callback deletes a linked key that hashes to the same slot.
|
||||||
|
func TestCacheEvictDeadlock(t *testing.T) {
|
||||||
|
ctx := context.Background()
|
||||||
|
c := New[string](WithLocalSlotNum(1), WithLocalSlotSize(1), WithLazy())
|
||||||
|
|
||||||
|
if _, err := c.GetLink(ctx, "k1", func(ctx context.Context) (string, error) {
|
||||||
|
return "v1", nil
|
||||||
|
}, "k2"); err != nil {
|
||||||
|
t.Fatalf("seed cache failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
done := make(chan struct{})
|
||||||
|
go func() {
|
||||||
|
defer close(done)
|
||||||
|
_, _ = c.GetLink(ctx, "k2", func(ctx context.Context) (string, error) {
|
||||||
|
return "v2", nil
|
||||||
|
}, "k1")
|
||||||
|
}()
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-done:
|
||||||
|
// expected to finish quickly; current implementation deadlocks here.
|
||||||
|
case <-time.After(time.Second):
|
||||||
|
t.Fatal("GetLink deadlocked during eviction of linked key")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestExpirationLRUGetBatch(t *testing.T) {
|
||||||
|
l := lru.NewExpirationLRU[string, string](2, time.Minute, time.Second*5, EmptyTarget{}, nil)
|
||||||
|
|
||||||
|
keys := []string{"a", "b"}
|
||||||
|
values, err := l.GetBatch(keys, func(keys []string) (map[string]string, error) {
|
||||||
|
res := make(map[string]string)
|
||||||
|
for _, k := range keys {
|
||||||
|
res[k] = k + "_v"
|
||||||
|
}
|
||||||
|
return res, nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unexpected error: %v", err)
|
||||||
|
}
|
||||||
|
if len(values) != len(keys) {
|
||||||
|
t.Fatalf("expected %d values, got %d", len(keys), len(values))
|
||||||
|
}
|
||||||
|
for _, k := range keys {
|
||||||
|
if v, ok := values[k]; !ok || v != k+"_v" {
|
||||||
|
t.Fatalf("unexpected value for %s: %q, ok=%v", k, v, ok)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// second batch should hit cache
|
||||||
|
values, err = l.GetBatch(keys, func(keys []string) (map[string]string, error) {
|
||||||
|
t.Fatalf("should not fetch on cache hit")
|
||||||
|
return nil, nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unexpected error on cache hit: %v", err)
|
||||||
|
}
|
||||||
|
for _, k := range keys {
|
||||||
|
if v, ok := values[k]; !ok || v != k+"_v" {
|
||||||
|
t.Fatalf("unexpected cached value for %s: %q, ok=%v", k, v, ok)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -52,8 +52,53 @@ type ExpirationLRU[K comparable, V any] struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (x *ExpirationLRU[K, V]) GetBatch(keys []K, fetch func(keys []K) (map[K]V, error)) (map[K]V, error) {
|
func (x *ExpirationLRU[K, V]) GetBatch(keys []K, fetch func(keys []K) (map[K]V, error)) (map[K]V, error) {
|
||||||
//TODO implement me
|
var (
|
||||||
panic("implement me")
|
err error
|
||||||
|
results = make(map[K]V)
|
||||||
|
misses = make([]K, 0, len(keys))
|
||||||
|
)
|
||||||
|
|
||||||
|
for _, key := range keys {
|
||||||
|
x.lock.Lock()
|
||||||
|
v, ok := x.core.Get(key)
|
||||||
|
x.lock.Unlock()
|
||||||
|
if ok {
|
||||||
|
x.target.IncrGetHit()
|
||||||
|
v.lock.RLock()
|
||||||
|
results[key] = v.value
|
||||||
|
if v.err != nil && err == nil {
|
||||||
|
err = v.err
|
||||||
|
}
|
||||||
|
v.lock.RUnlock()
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
misses = append(misses, key)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(misses) == 0 {
|
||||||
|
return results, err
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchValues, fetchErr := fetch(misses)
|
||||||
|
if fetchErr != nil && err == nil {
|
||||||
|
err = fetchErr
|
||||||
|
}
|
||||||
|
|
||||||
|
for key, val := range fetchValues {
|
||||||
|
results[key] = val
|
||||||
|
if fetchErr != nil {
|
||||||
|
x.target.IncrGetFailed()
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
x.target.IncrGetSuccess()
|
||||||
|
item := &expirationLruItem[V]{value: val}
|
||||||
|
x.lock.Lock()
|
||||||
|
x.core.Add(key, item)
|
||||||
|
x.lock.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
// any keys not returned from fetch remain absent (no cache write)
|
||||||
|
return results, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *ExpirationLRU[K, V]) Get(key K, fetch func() (V, error)) (V, error) {
|
func (x *ExpirationLRU[K, V]) Get(key K, fetch func() (V, error)) (V, error) {
|
||||||
|
|||||||
@@ -21,25 +21,25 @@ import (
|
|||||||
"github.com/hashicorp/golang-lru/v2/simplelru"
|
"github.com/hashicorp/golang-lru/v2/simplelru"
|
||||||
)
|
)
|
||||||
|
|
||||||
type layLruItem[V any] struct {
|
type lazyLruItem[V any] struct {
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
expires int64
|
expires int64
|
||||||
err error
|
err error
|
||||||
value V
|
value V
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLayLRU[K comparable, V any](size int, successTTL, failedTTL time.Duration, target Target, onEvict EvictCallback[K, V]) *LayLRU[K, V] {
|
func NewLazyLRU[K comparable, V any](size int, successTTL, failedTTL time.Duration, target Target, onEvict EvictCallback[K, V]) *LazyLRU[K, V] {
|
||||||
var cb simplelru.EvictCallback[K, *layLruItem[V]]
|
var cb simplelru.EvictCallback[K, *lazyLruItem[V]]
|
||||||
if onEvict != nil {
|
if onEvict != nil {
|
||||||
cb = func(key K, value *layLruItem[V]) {
|
cb = func(key K, value *lazyLruItem[V]) {
|
||||||
onEvict(key, value.value)
|
onEvict(key, value.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
core, err := simplelru.NewLRU[K, *layLruItem[V]](size, cb)
|
core, err := simplelru.NewLRU[K, *lazyLruItem[V]](size, cb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
return &LayLRU[K, V]{
|
return &LazyLRU[K, V]{
|
||||||
core: core,
|
core: core,
|
||||||
successTTL: successTTL,
|
successTTL: successTTL,
|
||||||
failedTTL: failedTTL,
|
failedTTL: failedTTL,
|
||||||
@@ -47,15 +47,15 @@ func NewLayLRU[K comparable, V any](size int, successTTL, failedTTL time.Duratio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type LayLRU[K comparable, V any] struct {
|
type LazyLRU[K comparable, V any] struct {
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
core *simplelru.LRU[K, *layLruItem[V]]
|
core *simplelru.LRU[K, *lazyLruItem[V]]
|
||||||
successTTL time.Duration
|
successTTL time.Duration
|
||||||
failedTTL time.Duration
|
failedTTL time.Duration
|
||||||
target Target
|
target Target
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *LayLRU[K, V]) Get(key K, fetch func() (V, error)) (V, error) {
|
func (x *LazyLRU[K, V]) Get(key K, fetch func() (V, error)) (V, error) {
|
||||||
x.lock.Lock()
|
x.lock.Lock()
|
||||||
v, ok := x.core.Get(key)
|
v, ok := x.core.Get(key)
|
||||||
if ok {
|
if ok {
|
||||||
@@ -68,7 +68,7 @@ func (x *LayLRU[K, V]) Get(key K, fetch func() (V, error)) (V, error) {
|
|||||||
return value, err
|
return value, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
v = &layLruItem[V]{}
|
v = &lazyLruItem[V]{}
|
||||||
x.core.Add(key, v)
|
x.core.Add(key, v)
|
||||||
v.lock.Lock()
|
v.lock.Lock()
|
||||||
x.lock.Unlock()
|
x.lock.Unlock()
|
||||||
@@ -88,15 +88,15 @@ func (x *LayLRU[K, V]) Get(key K, fetch func() (V, error)) (V, error) {
|
|||||||
return v.value, v.err
|
return v.value, v.err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *LayLRU[K, V]) GetBatch(keys []K, fetch func(keys []K) (map[K]V, error)) (map[K]V, error) {
|
func (x *LazyLRU[K, V]) GetBatch(keys []K, fetch func(keys []K) (map[K]V, error)) (map[K]V, error) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
once sync.Once
|
once sync.Once
|
||||||
)
|
)
|
||||||
|
|
||||||
res := make(map[K]V)
|
res := make(map[K]V)
|
||||||
queries := make([]K, 0)
|
queries := make([]K, 0, len(keys))
|
||||||
setVs := make(map[K]*layLruItem[V])
|
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
x.lock.Lock()
|
x.lock.Lock()
|
||||||
v, ok := x.core.Get(key)
|
v, ok := x.core.Get(key)
|
||||||
@@ -118,14 +118,20 @@ func (x *LayLRU[K, V]) GetBatch(keys []K, fetch func(keys []K) (map[K]V, error))
|
|||||||
}
|
}
|
||||||
queries = append(queries, key)
|
queries = append(queries, key)
|
||||||
}
|
}
|
||||||
values, err1 := fetch(queries)
|
|
||||||
if err1 != nil {
|
if len(queries) == 0 {
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
values, fetchErr := fetch(queries)
|
||||||
|
if fetchErr != nil {
|
||||||
once.Do(func() {
|
once.Do(func() {
|
||||||
err = err1
|
err = fetchErr
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, val := range values {
|
for key, val := range values {
|
||||||
v := &layLruItem[V]{}
|
v := &lazyLruItem[V]{}
|
||||||
v.value = val
|
v.value = val
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -135,7 +141,7 @@ func (x *LayLRU[K, V]) GetBatch(keys []K, fetch func(keys []K) (map[K]V, error))
|
|||||||
v.expires = time.Now().Add(x.failedTTL).UnixMilli()
|
v.expires = time.Now().Add(x.failedTTL).UnixMilli()
|
||||||
x.target.IncrGetFailed()
|
x.target.IncrGetFailed()
|
||||||
}
|
}
|
||||||
setVs[key] = v
|
|
||||||
x.lock.Lock()
|
x.lock.Lock()
|
||||||
x.core.Add(key, v)
|
x.core.Add(key, v)
|
||||||
x.lock.Unlock()
|
x.lock.Unlock()
|
||||||
@@ -145,29 +151,29 @@ func (x *LayLRU[K, V]) GetBatch(keys []K, fetch func(keys []K) (map[K]V, error))
|
|||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
//func (x *LayLRU[K, V]) Has(key K) bool {
|
//func (x *LazyLRU[K, V]) Has(key K) bool {
|
||||||
// x.lock.Lock()
|
// x.lock.Lock()
|
||||||
// defer x.lock.Unlock()
|
// defer x.lock.Unlock()
|
||||||
// return x.core.Contains(key)
|
// return x.core.Contains(key)
|
||||||
//}
|
//}
|
||||||
|
|
||||||
func (x *LayLRU[K, V]) Set(key K, value V) {
|
func (x *LazyLRU[K, V]) Set(key K, value V) {
|
||||||
x.lock.Lock()
|
x.lock.Lock()
|
||||||
defer x.lock.Unlock()
|
defer x.lock.Unlock()
|
||||||
x.core.Add(key, &layLruItem[V]{value: value, expires: time.Now().Add(x.successTTL).UnixMilli()})
|
x.core.Add(key, &lazyLruItem[V]{value: value, expires: time.Now().Add(x.successTTL).UnixMilli()})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *LayLRU[K, V]) SetHas(key K, value V) bool {
|
func (x *LazyLRU[K, V]) SetHas(key K, value V) bool {
|
||||||
x.lock.Lock()
|
x.lock.Lock()
|
||||||
defer x.lock.Unlock()
|
defer x.lock.Unlock()
|
||||||
if x.core.Contains(key) {
|
if x.core.Contains(key) {
|
||||||
x.core.Add(key, &layLruItem[V]{value: value, expires: time.Now().Add(x.successTTL).UnixMilli()})
|
x.core.Add(key, &lazyLruItem[V]{value: value, expires: time.Now().Add(x.successTTL).UnixMilli()})
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *LayLRU[K, V]) Del(key K) bool {
|
func (x *LazyLRU[K, V]) Del(key K) bool {
|
||||||
x.lock.Lock()
|
x.lock.Lock()
|
||||||
ok := x.core.Remove(key)
|
ok := x.core.Remove(key)
|
||||||
x.lock.Unlock()
|
x.lock.Unlock()
|
||||||
@@ -179,6 +185,6 @@ func (x *LayLRU[K, V]) Del(key K) bool {
|
|||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *LayLRU[K, V]) Stop() {
|
func (x *LazyLRU[K, V]) Stop() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,15 +3,16 @@ package rpccache
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
|
||||||
"github.com/openimsdk/protocol/constant"
|
|
||||||
"github.com/openimsdk/protocol/user"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
||||||
|
"github.com/openimsdk/protocol/constant"
|
||||||
|
"github.com/openimsdk/protocol/user"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/cachekey"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/cachekey"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/localcache"
|
"github.com/openimsdk/open-im-server/v3/pkg/localcache"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/localcache/lru"
|
"github.com/openimsdk/open-im-server/v3/pkg/localcache/lru"
|
||||||
@@ -46,7 +47,7 @@ func NewOnlineCache(client *rpcli.UserClient, group *GroupLocalCache, rdb redis.
|
|||||||
case false:
|
case false:
|
||||||
log.ZDebug(ctx, "fullUserCache is false")
|
log.ZDebug(ctx, "fullUserCache is false")
|
||||||
x.lruCache = lru.NewSlotLRU(1024, localcache.LRUStringHash, func() lru.LRU[string, []int32] {
|
x.lruCache = lru.NewSlotLRU(1024, localcache.LRUStringHash, func() lru.LRU[string, []int32] {
|
||||||
return lru.NewLayLRU[string, []int32](2048, cachekey.OnlineExpire/2, time.Second*3, localcache.EmptyTarget{}, func(key string, value []int32) {})
|
return lru.NewLazyLRU[string, []int32](2048, cachekey.OnlineExpire/2, time.Second*3, localcache.EmptyTarget{}, func(key string, value []int32) {})
|
||||||
})
|
})
|
||||||
x.CurrentPhase.Store(DoSubscribeOver)
|
x.CurrentPhase.Store(DoSubscribeOver)
|
||||||
x.Cond.Broadcast()
|
x.Cond.Broadcast()
|
||||||
|
|||||||
Reference in New Issue
Block a user