feat(main): 🚀 Database Name Correction and S3 Module Int32 Overflow Fix with Go Routine Integration for Automated Checks and Script Optimization (#1799)

* feat: replace mongo database openIM_v3 to openim_v3

* openim-building-an-efficient-version-control-and-testing-workflow

* feat: complete openim source deployment rpc start timeout

* feat: optimize config

Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com>

* feat: add scripts format

* feat: use scripts format code

* fix cos and minio etc to typecheck

* feat: scripts make verify check ci

* fix: make file verify spelling

* fix: make file verify spelling

* Concurrent Type Checking and Cross-Platform Development in Go

* feat: add copyright make lint and format

* feat: add config examples file

Signed-off-by: Xinwei Xiong <3293172751@qq.com>

* feat: add config examples file

Signed-off-by: Xinwei Xiong <3293172751@qq.com>

---------

Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com>
Signed-off-by: Xinwei Xiong <3293172751@qq.com>
pull/1816/head
Xinwei Xiong 8 months ago committed by GitHub
parent fa55c44113
commit d356f7a035
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -2,7 +2,6 @@
// Reference Doc: https://code.visualstudio.com/remote/advancedcontainers/overview // Reference Doc: https://code.visualstudio.com/remote/advancedcontainers/overview
"name": "OpenIM Dev Environment", "name": "OpenIM Dev Environment",
// Update the container version when you publish dev-container // Update the container version when you publish dev-container
"dockerComposeFile": "docker-compose.yml",
"build": { "dockerfile": "Dockerfile" }, "build": { "dockerfile": "Dockerfile" },
// Replace with uncommented line below to build your own local copy of the image // Replace with uncommented line below to build your own local copy of the image
// "dockerFile": "../docker/Dockerfile-dev", // "dockerFile": "../docker/Dockerfile-dev",

@ -17,6 +17,7 @@ on:
issues: issues:
types: types:
- labeled - labeled
jobs: jobs:
add-comment: add-comment:
if: github.event.label.name == 'help wanted' || github.event.label.name == 'good first issue' if: github.event.label.name == 'help wanted' || github.event.label.name == 'good first issue'

@ -23,6 +23,8 @@ on:
- "docs/**" - "docs/**"
- "README.md" - "README.md"
- "README_zh-CN.md" - "README_zh-CN.md"
- "**.md"
- "docs/**"
- "CONTRIBUTING.md" - "CONTRIBUTING.md"
pull_request: pull_request:
branches: branches:
@ -31,7 +33,8 @@ on:
paths-ignore: paths-ignore:
- "README.md" - "README.md"
- "README_zh-CN.md" - "README_zh-CN.md"
- "CONTRIBUTING.md" - "CONTRIBUTING/**"
- "**.md"
- "docs/**" - "docs/**"
env: env:
@ -67,6 +70,9 @@ jobs:
version: '3.x' # If available, use the latest major version that's compatible version: '3.x' # If available, use the latest major version that's compatible
repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: OpenIM Scripts Verification(make verify)
run: sudo make verify
- name: Module Operations - name: Module Operations
run: | run: |
sudo make tidy sudo make tidy
@ -91,13 +97,6 @@ jobs:
- name: Cleanup Build - name: Cleanup Build
run: sudo make clean run: sudo make clean
- name: Push Changes to Main
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "cicd: robot automated Change"
branch: main
continue-on-error: true
- name: Set Current Directory - name: Set Current Directory
id: set_directory id: set_directory
run: echo "::set-output name=directory::$(pwd)" run: echo "::set-output name=directory::$(pwd)"

1
.gitignore vendored

@ -34,6 +34,7 @@ deployments/charts/generated-configs/
### OpenIM Config ### ### OpenIM Config ###
.env .env
config/config.yaml config/config.yaml
config/openim.yaml
config/alertmanager.yml config/alertmanager.yml
config/prometheus.yml config/prometheus.yml
config/email.tmpl config/email.tmpl

@ -1,15 +0,0 @@
# Version logging for OpenIM
<!-- BEGIN MUNGE: GENERATED_TOC -->
<!-- END MUNGE: GENERATED_TOC -->
<a name="unreleased"></a>
## [Unreleased]
<a name="v3.5.0+3.97baaac"></a>
## [v3.5.0+3.97baaac] - 2024-01-12
[Unreleased]: https://github.com/openimsdk/open-im-server/compare/v3.5.0+3.97baaac...HEAD
[v3.5.0+3.97baaac]: https://github.com/openimsdk/open-im-server/compare/v3.5.0+5.950e970...v3.5.0+3.97baaac

@ -42,7 +42,7 @@ OpenIM is a service platform specifically designed for integrating chat, audio-v
- 🛡️ API wrapping - 🛡️ API wrapping
- 🌐 Connection management - 🌐 Connection management
## 📚 Main Modules: + 📚 Main Modules:
1. 🚀 Initialization and Login 1. 🚀 Initialization and Login
2. 👤 User Management 2. 👤 User Management
@ -70,11 +70,16 @@ It is built using Golang and supports cross-platform deployment, ensuring a cons
## :rocket: Quick Start ## :rocket: Quick Start
We support many platforms. Here are the addresses for quick experience on the web side
👉 **[OpenIM online web demo](https://web-enterprise.rentsoft.cn/)**
🤲 To facilitate user experience, we offer various deployment solutions. You can choose your deployment method from the list below: 🤲 To facilitate user experience, we offer various deployment solutions. You can choose your deployment method from the list below:
+ **[Source Code Deployment Guide](https://docs.openim.io/guides/gettingStarted/imSourceCodeDeployment)** + **[Source Code Deployment Guide](https://docs.openim.io/guides/gettingStarted/imSourceCodeDeployment)**
+ **[Docker Deployment Guide](https://docs.openim.io/guides/gettingStarted/dockerCompose)** + **[Docker Deployment Guide](https://docs.openim.io/guides/gettingStarted/dockerCompose)**
+ **[Kubernetes Deployment Guide](https://docs.openim.io/guides/gettingStarted/k8s-deployment)** + **[Kubernetes Deployment Guide](https://docs.openim.io/guides/gettingStarted/k8s-deployment)**
+ **[Mac Developer Deployment Guide](https://docs.openim.io/guides/gettingstarted/mac-deployment-guide)**
## :hammer_and_wrench: To Start Developing OpenIM ## :hammer_and_wrench: To Start Developing OpenIM

@ -14,7 +14,7 @@
# ----------------------------------------------------------------- # -----------------------------------------------------------------
# TODO: This config file is the template file # TODO: This config file is the template file
# --| source: deployments/templates/openim.yaml # --| source: deployments/templates/config.yaml
# --| env: scripts/install/environment # --| env: scripts/install/environment
# --| target: config/config.yaml # --| target: config/config.yaml
# ----------------------------------------------------------------- # -----------------------------------------------------------------
@ -52,8 +52,8 @@ mongo:
# Default MongoDB database name # Default MongoDB database name
# Maximum connection pool size # Maximum connection pool size
address: [ 172.28.0.1:37017 ] address: [ 172.28.0.1:37017 ]
database: openIM_v3 database: openim_v3
username: root username: openIM
password: openIM123 password: openIM123
maxPoolSize: 100 maxPoolSize: 100
@ -122,14 +122,14 @@ api:
# minio.signEndpoint is minio public network address # minio.signEndpoint is minio public network address
object: object:
enable: "minio" enable: "minio"
apiURL: "http://14.155.64.202:10002" apiURL: "http://172.28.0.1:10002"
minio: minio:
bucket: "openim" bucket: "openim"
endpoint: "http://172.28.0.1:10005" endpoint: "http://172.28.0.1:10005"
accessKeyID: "root" accessKeyID: "root"
secretAccessKey: "openIM123" secretAccessKey: "openIM123"
sessionToken: '' sessionToken: ''
signEndpoint: "http://14.155.64.202:10005" signEndpoint: "http://172.28.0.1:10005"
publicRead: false publicRead: false
cos: cos:
bucketURL: https://temp-1252357374.cos.ap-chengdu.myqcloud.com bucketURL: https://temp-1252357374.cos.ap-chengdu.myqcloud.com
@ -193,7 +193,7 @@ rpcRegisterName:
# Whether to output in json format # Whether to output in json format
# Whether to include stack trace in logs # Whether to include stack trace in logs
log: log:
storageLocation: /data/workspaces/open-im-server/logs/ storageLocation: /workspaces/open-im-server/logs/
rotationTime: 24 rotationTime: 24
remainRotationCount: 2 remainRotationCount: 2
remainLogLevel: 6 remainLogLevel: 6
@ -247,6 +247,14 @@ manager:
userID: [ "openIM123456", "openIM654321", "openIMAdmin" ] userID: [ "openIM123456", "openIM654321", "openIMAdmin" ]
nickname: [ "system1", "system2", "system3" ] nickname: [ "system1", "system2", "system3" ]
# chatAdmin, use for send notification
#
# Built-in app system notification account ID
# Built-in app system notification account nickname
im-admin:
userID: [ "imAdmin" ]
nickname: [ "imAdmin" ]
# Multi-platform login policy # Multi-platform login policy
# For each platform(Android, iOS, Windows, Mac, web), only one can be online at a time # For each platform(Android, iOS, Windows, Mac, web), only one can be online at a time
multiLoginPolicy: 1 multiLoginPolicy: 1
@ -307,7 +315,7 @@ iosPush:
# Timeout in seconds # Timeout in seconds
# Whether to continue execution if callback fails # Whether to continue execution if callback fails
callback: callback:
url: "" url: "http://127.0.0.1:10008/callbackExample"
beforeSendSingleMsg: beforeSendSingleMsg:
enable: false enable: false
timeout: 5 timeout: 5
@ -321,7 +329,7 @@ callback:
timeout: 5 timeout: 5
failedContinue: true failedContinue: true
afterSendSingleMsg: afterSendSingleMsg:
enable: false enable: true
timeout: 5 timeout: 5
failedContinue: true failedContinue: true
beforeSendGroupMsg: beforeSendGroupMsg:
@ -505,8 +513,8 @@ callback:
# The number of Prometheus ports per service needs to correspond to rpcPort # The number of Prometheus ports per service needs to correspond to rpcPort
# The number of ports needs to be consistent with msg_transfer_service_num in script/path_info.sh # The number of ports needs to be consistent with msg_transfer_service_num in script/path_info.sh
prometheus: prometheus:
enable: false enable: true
grafanaUrl: 172.28.0.1:13000 grafanaUrl: http://172.28.0.1:13000/
apiPrometheusPort: [20100] apiPrometheusPort: [20100]
userPrometheusPort: [ 20110 ] userPrometheusPort: [ 20110 ]
friendPrometheusPort: [ 20120 ] friendPrometheusPort: [ 20120 ]

@ -1,4 +1,4 @@
# Copyright © 2023 OpenIM. All rights reserved. # Copyright © 2024 OpenIM. All rights reserved.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@ -12,31 +12,26 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# ====================================== # -----------------------------------------------------------------------------
# ========= Basic Configuration ======== # General Configuration
# ====================================== # This section contains general configuration options for the entire environment.
# These options can be set via environment variables. If both environment variables
# The user for authentication or system operations. # and settings in this .env file exist, the environment variables take precedence.
# Default: OPENIM_USER=root # -----------------------------------------------------------------------------
USER=root # ==========================
# General Configuration
# Password associated with the specified user for authentication. # ==========================
# Default: PASSWORD=openIM123 # These settings apply to the overall environment.
PASSWORD=openIM123
# Data storage directory for persistent data.
# Base URL for the application programming interface (API). # Example: DATA_DIR=/path/to/data
# Default: API_URL=http://172.28.0.1:10002 DATA_DIR=/workspaces/open-im-server
API_URL=http://14.155.64.202:10002
# Docker image registry. Uncomment the preferred one.
# Directory path for storing data files or related information. # Options: ghcr.io/openimsdk, openim, registry.cn-hangzhou.aliyuncs.com/openimsdk
# Default: DATA_DIR=./ # IMAGE_REGISTRY="ghcr.io/openimsdk"
DATA_DIR=/data/workspaces/open-im-server # IMAGE_REGISTRY="openim"
# IMAGE_REGISTRY="registry.cn-hangzhou.aliyuncs.com/openimsdk"
# Choose the appropriate image address, the default is GITHUB image,
# you can choose docker hub, for Chinese users can choose Ali Cloud
# export IMAGE_REGISTRY="ghcr.io/openimsdk"
# export IMAGE_REGISTRY="openim"
# export IMAGE_REGISTRY="registry.cn-hangzhou.aliyuncs.com/openimsdk"
IMAGE_REGISTRY=ghcr.io/openimsdk IMAGE_REGISTRY=ghcr.io/openimsdk
# ====================================== # ======================================
@ -47,10 +42,9 @@ IMAGE_REGISTRY=ghcr.io/openimsdk
# Default: DOCKER_BRIDGE_SUBNET=172.28.0.0/16 # Default: DOCKER_BRIDGE_SUBNET=172.28.0.0/16
DOCKER_BRIDGE_SUBNET=172.28.0.0/16 DOCKER_BRIDGE_SUBNET=172.28.0.0/16
# Gateway for the Docker network. # Set and specify the IP addresses of some containers. Generally speaking,
# Default: DOCKER_BRIDGE_GATEWAY=172.28.0.1 # you do not need to modify these configurations to facilitate debugging
DOCKER_BRIDGE_GATEWAY=172.28.0.1 DOCKER_BRIDGE_GATEWAY=172.28.0.1
MONGO_NETWORK_ADDRESS=172.28.0.2 MONGO_NETWORK_ADDRESS=172.28.0.2
REDIS_NETWORK_ADDRESS=172.28.0.3 REDIS_NETWORK_ADDRESS=172.28.0.3
KAFKA_NETWORK_ADDRESS=172.28.0.4 KAFKA_NETWORK_ADDRESS=172.28.0.4
@ -65,45 +59,66 @@ NODE_EXPORTER_NETWORK_ADDRESS=172.28.0.12
OPENIM_ADMIN_FRONT_NETWORK_ADDRESS=172.28.0.13 OPENIM_ADMIN_FRONT_NETWORK_ADDRESS=172.28.0.13
ALERT_MANAGER_NETWORK_ADDRESS=172.28.0.14 ALERT_MANAGER_NETWORK_ADDRESS=172.28.0.14
# =============================================== # ==============================================================================
# = Component Extension Configuration = # Configuration Update Instructions
# =============================================== # ==============================================================================
# This header outlines the methods to update common variables in config.yaml and .env files.
# These instructions are vital for maintaining the OpenIM environment's configuration.
#
# METHOD 1: Regenerate All Configurations
# ----------------------------------------
# Use this method to regenerate all configurations.
# Steps:
# 1. Delete existing config files:
# - openim-server/config/config.yaml
# - openim-chat/config/config.yaml
# 2. Modify the .env file as required.
# 3. Run 'docker compose up -d'. This will regenerate:
# - config/config.yaml
#
# METHOD 2: Modify Individual Configuration Files
# -----------------------------------------------
# Use this method to update specific configuration files.
# Steps:
# 1. Modify the .env file as necessary.
# 2. Update the corresponding entries in:
# - config/config.yaml
# 3. Restart the services with 'docker compose up -d'.
# 4. Special Note: If you modify OPENIM_IP, API_OPENIM_PORT, or MINIO_PORT in .env,
# ensure to update the corresponding services and configurations accordingly.
#
# It is essential to follow these methods to ensure consistent and correct application behavior.
# ==============================================================================
# Local IP address of the service. Modify if necessary.
# Example: OPENIM_IP=172.28.0.1
OPENIM_IP=172.28.0.1
# ============ Component Extension Configuration ==========
# ----- ZooKeeper Configuration ----- # ----- ZooKeeper Configuration -----
# Address or hostname for the ZooKeeper service.
# Default: ZOOKEEPER_ADDRESS=172.28.0.1
ZOOKEEPER_ADDRESS=172.28.0.5
# Port for ZooKeeper service. # Port for ZooKeeper service.
# Default: ZOOKEEPER_PORT=12181 # Default: ZOOKEEPER_PORT=12181
ZOOKEEPER_PORT=12181 ZOOKEEPER_PORT=12181
# ----- MongoDB Configuration ----- # MongoDB service port configuration.
# Address or hostname for the MongoDB service.
# Default: MONGO_ADDRESS=172.28.0.1
MONGO_ADDRESS=172.28.0.2
# Port on which MongoDB service is running.
# Default: MONGO_PORT=37017 # Default: MONGO_PORT=37017
# MONGO_PORT=37017 # MONGO_PORT=37017
# Username to authenticate with the MongoDB service. # Password for MongoDB admin user. Used for service authentication.
# Default: MONGO_USERNAME=root
# MONGO_USERNAME=root
# Password to authenticate with the MongoDB service.
# Default: MONGO_PASSWORD=openIM123 # Default: MONGO_PASSWORD=openIM123
MONGO_PASSWORD=openIM123 MONGO_PASSWORD=openIM123
# Name of the database in MongoDB to be used. # Username for a regular OpenIM user in MongoDB.
# Default: MONGO_DATABASE=openIM_v3 # Default: MONGO_OPENIM_USERNAME=openIM
MONGO_DATABASE=openIM_v3 MONGO_OPENIM_USERNAME=openIM
# Password for a regular OpenIM user in MongoDB.
# Default: MONGO_OPENIM_PASSWORD=openIM123456
MONGO_OPENIM_PASSWORD=openIM123
# Specifies the database name to be used within MongoDB.
# Default: MONGO_DATABASE=openim_v3
MONGO_DATABASE=openim_v3
# ----- Redis Configuration ----- # ----- Redis Configuration -----
# Address or hostname for the Redis service.
# Default: REDIS_ADDRESS=172.28.0.1
REDIS_ADDRESS=172.28.0.3
# Port on which Redis in-memory data structure store is running. # Port on which Redis in-memory data structure store is running.
# Default: REDIS_PORT=16379 # Default: REDIS_PORT=16379
@ -113,11 +128,6 @@ REDIS_PORT=16379
# Default: REDIS_PASSWORD=openIM123 # Default: REDIS_PASSWORD=openIM123
REDIS_PASSWORD=openIM123 REDIS_PASSWORD=openIM123
# ----- Kafka Configuration -----
# Address or hostname for the Kafka service.
# Default: KAFKA_ADDRESS=172.28.0.1
KAFKA_ADDRESS=172.28.0.4
# Kakfa username to authenticate with the Kafka service. # Kakfa username to authenticate with the Kafka service.
# KAFKA_USERNAME='' # KAFKA_USERNAME=''
@ -129,20 +139,13 @@ KAFKA_PORT=19094
# Default: KAFKA_LATESTMSG_REDIS_TOPIC=latestMsgToRedis # Default: KAFKA_LATESTMSG_REDIS_TOPIC=latestMsgToRedis
KAFKA_LATESTMSG_REDIS_TOPIC=latestMsgToRedis KAFKA_LATESTMSG_REDIS_TOPIC=latestMsgToRedis
# Topic in Kafka for pushing messages (e.g. notifications or updates). # MINIO_PORT
# Default: KAFKA_MSG_PUSH_TOPIC=msgToPush # ----------
KAFKA_MSG_PUSH_TOPIC=msgToPush # MINIO_PORT sets the port for the MinIO object storage service.
# Upon changing this port, the MinIO endpoint URLs in the file must be updated
# Topic in Kafka for storing offline messages in MongoDB. # to reflect this change. The endpoints include both the 'endpoint' and 'signEndpoint'
# Default: KAFKA_OFFLINEMSG_MONGO_TOPIC=offlineMsgToMongoMysql # under the MinIO configuration.
KAFKA_OFFLINEMSG_MONGO_TOPIC=offlineMsgToMongoMysql #
# ----- MinIO Configuration ----
# Address or hostname for the MinIO object storage service.
# Default: MINIO_ADDRESS=172.28.0.1
MINIO_ADDRESS=172.28.0.6
# Port on which MinIO object storage service is running.
# Default: MINIO_PORT=10005 # Default: MINIO_PORT=10005
MINIO_PORT=10005 MINIO_PORT=10005
@ -155,19 +158,11 @@ MINIO_PORT=10005
MINIO_SECRET_KEY=openIM123 MINIO_SECRET_KEY=openIM123
# ----- Prometheus Configuration ----- # ----- Prometheus Configuration -----
# Address or hostname for the Prometheus service.
# Default: PROMETHEUS_ADDRESS=172.28.0.1
PROMETHEUS_ADDRESS=172.28.0.10
# Port on which Prometheus service is running. # Port on which Prometheus service is running.
# Default: PROMETHEUS_PORT=19090 # Default: PROMETHEUS_PORT=19090
PROMETHEUS_PORT=19090 PROMETHEUS_PORT=19090
# ----- Grafana Configuration ----- # ----- Grafana Configuration -----
# Address or hostname for the Grafana service.
# Default: GRAFANA_ADDRESS=172.28.0.1
GRAFANA_ADDRESS=172.28.0.11
# Port on which Grafana service is running. # Port on which Grafana service is running.
# Default: GRAFANA_PORT=13000 # Default: GRAFANA_PORT=13000
GRAFANA_PORT=13000 GRAFANA_PORT=13000
@ -183,41 +178,34 @@ OPENIM_WEB_PORT=11001
# ====================================== # ======================================
# ========= OpenIM Server ============== # ========= OpenIM Server ==============
# ====================================== # ======================================
# Address or hostname for the OpenIM server.
# Default: OPENIM_SERVER_ADDRESS=172.28.0.1
OPENIM_SERVER_ADDRESS=172.28.0.8
# Port for the OpenIM WebSockets. # Port for the OpenIM WebSockets.
# Default: OPENIM_WS_PORT=10001 # Default: OPENIM_WS_PORT=10001
OPENIM_WS_PORT=10001 OPENIM_WS_PORT=10001
# Port for the OpenIM API. # API_OPENIM_PORT
# ---------------
# This variable defines the port on which the OpenIM API service will listen.
# When changing this port, it's essential to update the apiURL in the config.yaml file
# to ensure the API service is accessible at the new port.
#
# Default: API_OPENIM_PORT=10002 # Default: API_OPENIM_PORT=10002
API_OPENIM_PORT=10002 API_OPENIM_PORT=10002
# ====================================== # ======================================
# ========== OpenIM Chat =============== # ========== OpenIM Chat ===============
# ====================================== # ======================================
# Branch name for OpenIM chat. # Branch name for OpenIM chat.
# Default: CHAT_IMAGE_VERSION=main # Default: CHAT_IMAGE_VERSION=main
# https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/version.md
CHAT_IMAGE_VERSION=main CHAT_IMAGE_VERSION=main
# Address or hostname for the OpenIM chat service.
# Default: OPENIM_CHAT_ADDRESS=172.28.0.1
OPENIM_CHAT_ADDRESS=172.28.0.9
# Port for the OpenIM chat API. # Port for the OpenIM chat API.
# Default: OPENIM_CHAT_API_PORT=10008 # Default: OPENIM_CHAT_API_PORT=10008
OPENIM_CHAT_API_PORT=10008 OPENIM_CHAT_API_PORT=10008
# Directory path for storing data files or related information for OpenIM chat. # Port for the OpenIM admin API.
# Default: OPENIM_CHAT_DATA_DIR=./openim-chat/main # Default: OPENIM_ADMIN_API_PORT=10009
OPENIM_CHAT_DATA_DIR=./openim-chat/main OPENIM_ADMIN_API_PORT=10009
# ====================================== # ======================================
# ========== OpenIM Admin ============== # ========== OpenIM Admin ==============
@ -227,10 +215,6 @@ OPENIM_CHAT_DATA_DIR=./openim-chat/main
# Default: SERVER_IMAGE_VERSION=main # Default: SERVER_IMAGE_VERSION=main
SERVER_IMAGE_VERSION=main SERVER_IMAGE_VERSION=main
# Port for the OpenIM admin API.
# Default: OPENIM_ADMIN_API_PORT=10009
OPENIM_ADMIN_API_PORT=10009
# Port for the node exporter. # Port for the node exporter.
# Default: NODE_EXPORTER_PORT=19100 # Default: NODE_EXPORTER_PORT=19100
NODE_EXPORTER_PORT=19100 NODE_EXPORTER_PORT=19100

@ -165,7 +165,7 @@ export MINIO_ENDPOINT="http://im-minio:9000"
export MINIO_SIGN_ENDPOINT="https://openim.server.com/im-minio-api" export MINIO_SIGN_ENDPOINT="https://openim.server.com/im-minio-api"
mkdir ./charts/generated-configs mkdir ./charts/generated-configs
../scripts/genconfig.sh ../scripts/install/environment.sh ./templates/openim.yaml > ./charts/generated-configs/config.yaml ../scripts/genconfig.sh ../scripts/install/environment.sh ./templates/config.yaml > ./charts/generated-configs/config.yaml
cp ../config/notification.yaml ./charts/generated-configs/notification.yaml cp ../config/notification.yaml ./charts/generated-configs/notification.yaml
../scripts/genconfig.sh ../scripts/install/environment.sh ./templates/helm-image.yaml > ./charts/generated-configs/helm-image.yaml ../scripts/genconfig.sh ../scripts/install/environment.sh ./templates/helm-image.yaml > ./charts/generated-configs/helm-image.yaml
``` ```

File diff suppressed because it is too large Load Diff

@ -14,7 +14,7 @@
# ----------------------------------------------------------------- # -----------------------------------------------------------------
# TODO: This config file is the template file # TODO: This config file is the template file
# --| source: deployments/templates/openim.yaml # --| source: deployments/templates/config.yaml
# --| env: scripts/install/environment # --| env: scripts/install/environment
# --| target: config/config.yaml # --| target: config/config.yaml
# ----------------------------------------------------------------- # -----------------------------------------------------------------

@ -115,7 +115,7 @@ MONGO_OPENIM_USERNAME=${MONGO_OPENIM_USERNAME}
MONGO_OPENIM_PASSWORD=${MONGO_OPENIM_PASSWORD} MONGO_OPENIM_PASSWORD=${MONGO_OPENIM_PASSWORD}
# Specifies the database name to be used within MongoDB. # Specifies the database name to be used within MongoDB.
# Default: MONGO_DATABASE=openIM_v3 # Default: MONGO_DATABASE=openim_v3
MONGO_DATABASE=${MONGO_DATABASE} MONGO_DATABASE=${MONGO_DATABASE}
# ----- Redis Configuration ----- # ----- Redis Configuration -----

@ -27,7 +27,7 @@ services:
- wiredTigerCacheSizeGB=1 - wiredTigerCacheSizeGB=1
- MONGO_INITDB_ROOT_USERNAME=${MONGO_USERNAME:-root} - MONGO_INITDB_ROOT_USERNAME=${MONGO_USERNAME:-root}
- MONGO_INITDB_ROOT_PASSWORD=${MONGO_PASSWORD:-openIM123} - MONGO_INITDB_ROOT_PASSWORD=${MONGO_PASSWORD:-openIM123}
- MONGO_INITDB_DATABASE=${MONGO_DATABASE:-openIM_v3} - MONGO_INITDB_DATABASE=${MONGO_DATABASE:-openim_v3}
- MONGO_OPENIM_USERNAME=${MONGO_OPENIM_USERNAME:-openIM} # Non-root username - MONGO_OPENIM_USERNAME=${MONGO_OPENIM_USERNAME:-openIM} # Non-root username
- MONGO_OPENIM_PASSWORD=${MONGO_OPENIM_PASSWORD:-openIM123456} # Non-root password - MONGO_OPENIM_PASSWORD=${MONGO_OPENIM_PASSWORD:-openIM123456} # Non-root password
restart: always restart: always
@ -87,6 +87,7 @@ services:
- KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=0@<your_host>:9093 - KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=0@<your_host>:9093
- KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094 - KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092,EXTERNAL://${DOCKER_BRIDGE_GATEWAY:-172.28.0.1}:${KAFKA_PORT:-19094} - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092,EXTERNAL://${DOCKER_BRIDGE_GATEWAY:-172.28.0.1}:${KAFKA_PORT:-19094}
# - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092,EXTERNAL://127.0.0.1:${KAFKA_PORT:-19094} # Mac Deployment
- KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT - KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT
- KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER - KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER
networks: networks:
@ -213,6 +214,7 @@ services:
# - "${OPENIM_ADMIN_API_PORT:-10009}:10009" # - "${OPENIM_ADMIN_API_PORT:-10009}:10009"
# volumes: # volumes:
# - "${DATA_DIR:-./}/components/openim-chat/logs:/openim/openim-chat/logs" # - "${DATA_DIR:-./}/components/openim-chat/logs:/openim/openim-chat/logs"
# - "${DATA_DIR:-./}/components/openim-chat/_output/logs:/openim/openim-chat/_output/logs"
# - "${DATA_DIR:-./}/components/openim-chat/config:/openim/openim-chat/config" # - "${DATA_DIR:-./}/components/openim-chat/config:/openim/openim-chat/config"
# restart: always # restart: always
# # user: root:root # # user: root:root

@ -31,7 +31,7 @@ docs/guide/en-US/cmd/openim/openim-rpc-user_list.md
docs/guide/en-US/cmd/openim/openim-rpc-user_update.md docs/guide/en-US/cmd/openim/openim-rpc-user_update.md
docs/guide/en-US/cmd/openim/openim_validate.md docs/guide/en-US/cmd/openim/openim_validate.md
docs/guide/en-US/cmd/openim/openim_version.md docs/guide/en-US/cmd/openim/openim_version.md
docs/guide/en-US/yaml/openim/openim.yaml docs/guide/en-US/yaml/openim/config.yaml
docs/guide/en-US/yaml/openim/openim_color.yaml docs/guide/en-US/yaml/openim/openim_color.yaml
docs/guide/en-US/yaml/openim/openim_completion.yaml docs/guide/en-US/yaml/openim/openim_completion.yaml
docs/guide/en-US/yaml/openim/openim_info.yaml docs/guide/en-US/yaml/openim/openim_info.yaml

@ -89,7 +89,7 @@ While the first two methods will be our main focus, it's worth noting that the t
### 1.2. <a name='SourceCodeDeployment'></a>Source Code Deployment ### 1.2. <a name='SourceCodeDeployment'></a>Source Code Deployment
In the source code deployment method, the configuration generation process involves executing `make init`, which fundamentally runs the script `./scripts/init-config.sh`. This script utilizes variables defined in the [`environment.sh`](https://github.com/openimsdk/open-im-server/blob/main/scripts/install/environment.sh) script to render the [`openim.yaml`](https://github.com/openimsdk/open-im-server/blob/main/deployments/templates/openim.yaml) template file, subsequently generating the [`config.yaml`](https://github.com/openimsdk/open-im-server/blob/main/config/config.yaml) configuration file. In the source code deployment method, the configuration generation process involves executing `make init`, which fundamentally runs the script `./scripts/init-config.sh`. This script utilizes variables defined in the [`environment.sh`](https://github.com/openimsdk/open-im-server/blob/main/scripts/install/environment.sh) script to render the [`config.yaml`](https://github.com/openimsdk/open-im-server/blob/main/deployments/templates/config.yaml) template file, subsequently generating the [`config.yaml`](https://github.com/openimsdk/open-im-server/blob/main/config/config.yaml) configuration file.
### 1.3. <a name='DockerComposeDeployment'></a>Docker Compose Deployment ### 1.3. <a name='DockerComposeDeployment'></a>Docker Compose Deployment

@ -45,86 +45,162 @@ Homebrew is an essential package manager for macOS. Install it using:
git config --global user.email "your.email@example.com" git config --global user.email "your.email@example.com"
``` ```
### Forking and Cloning the Repository ### Setting Up the Devcontainer
`Devcontainers` provide a Docker-based isolated development environment.
Read [README.md](https://github.com/openimsdk/open-im-server/tree/main/.devcontainer) in the `.devcontainer` directory of the project to learn more about the devcontainer.
To optimize and add logic to your instructions, particularly regarding deploying on a Mac, you can modify them as follows: To set it up:
1. Install Docker Desktop for Mac from [Docker Hub](https://docs.docker.com/desktop/install/mac-install/).
2. Install Visual Studio Code and the Remote - Containers extension.
3. Open the cloned OpenIM repository in VS Code.
4. VS Code will prompt to reopen the project in a container. Accept this to set up the environment automatically.
1. **Fork the OpenIM Repository**: Fork the OpenIM repository on GitHub to your account. ### Installing Go and Dependencies
2. **Clone Your Fork to Your Local Machine**: Use Homebrew to install Go:
Open your terminal and execute the following commands:
```sh ```sh
# Clone the repository brew install go
git clone https://github.com/<your-username>/open-im-server.git ```
# Set Docker bridging network mode for Mac Ensure the version of Go is compatible with the version required by OpenIM (refer to the main documentation for version requirements).
export DOCKER_BRIDGE_SUBNET=127.0.0.0/16
# Set OpenIM IP ### Additional Tools
export OPENIM_IP=<your-ip>
# Initialize configuration Install other required tools like Docker, Vagrant, and necessary GNU utils as described in the main documentation.
make init
# Start components using Docker ## Mac Deployment openim-chat and openim-server
docker compose up -d
# Start OpenIM Server To integrate the Chinese document into an English document for Linux deployment, we will first translate the content and then adapt it to suit the Linux environment. Here's how the translated and adapted content might look:
make start
### Ensure a Clean Environment
- It's recommended to execute in a new directory.
- Run `ps -ef | grep openim` to ensure no OpenIM processes are running.
- Run `ps -ef | grep chat` to check for absence of chat-related processes.
- Execute `docker ps` to verify there are no related containers running.
### Source Code Deployment
#### Deploying openim-server
Source code deployment is slightly more complex because Docker's networking on Linux differs from Mac.
```bash
git clone https://github.com/openimsdk/open-im-server
cd open-im-server
export OPENIM_IP="Your IP" # If it's a cloud server, setting might not be needed
make init # Generates configuration files
``` ```
3. **Additional Steps for Mac Deployment**: Before deploying openim-server, modify the Kafka logic in the docker-compose.yml file. Replace:
If you are deploying on a Mac and wish to use the chat feature, you need to modify the `docker-compose` file. Specifically, you'll need to uncomment the sections related to `openim-chat` and `mysql`.
Here's how to do it: ```yaml
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092,EXTERNAL://${DOCKER_BRIDGE_GATEWAY:-172.28.0.1}:${KAFKA_PORT:-19094}
```
- Open the `docker-compose.yml` file in a text editor. With:
- Find the sections for `openim-chat` and `mysql`.
- Remove the comment marks (`#`) at the beginning of the lines in these sections to enable them.
- Save the file after making these changes.
4. **Update and Restart Services**: ```yaml
After modifying the `docker-compose` file, you need to update and restart the services to apply these changes. Run the following command in your terminal: - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092,EXTERNAL://127.0.0.1:${KAFKA_PORT:-19094}
```
```sh Then start the service:
# Update and restart services
```bash
docker compose up -d docker compose up -d
```
Before starting the openim-server source, set `config/config.yaml` by replacing all instances of `172.28.0.1` with `127.0.0.1`:
```bash
vim config/config.yaml -c "%s/172\.28\.0\.1/127.0.0.1/g" -c "wq"
```
Then start openim-server:
# Check openim-chat start ```bash
docker compose logs openim-chat make start
``` ```
This command will re-read the `docker-compose.yml` file, apply the new configuration, and restart the necessary containers. To check the startup:
Remember, replacing `<your-username>` and `<your-ip>` with your actual GitHub username and desired IP address for OpenIM is crucial. These steps should streamline the setup process, particularly for Mac users wishing to use the chat feature. ```bash
make check
```
### Setting Up the Devcontainer <aside>
🚧 To avoid mishaps, it's best to wait five minutes before running `make check` again.
`Devcontainers` provide a Docker-based isolated development environment. </aside>
Read [README.md](https://github.com/openimsdk/open-im-server/tree/main/.devcontainer) in the `.devcontainer` directory of the project to learn more about the devcontainer. #### Deploying openim-chat
To set it up: There are several ways to deploy openim-chat, either by source code or using Docker.
1. Install Docker Desktop for Mac from [Docker Hub](https://docs.docker.com/desktop/install/mac-install/). Navigate back to the parent directory:
2. Install Visual Studio Code and the Remote - Containers extension.
3. Open the cloned OpenIM repository in VS Code.
4. VS Code will prompt to reopen the project in a container. Accept this to set up the environment automatically.
### Installing Go and Dependencies ```bash
cd ..
```
Use Homebrew to install Go: First, let's look at deploying chat from source:
```sh ```bash
brew install go git clone https://github.com/openimsdk/chat
cd chat
make init # Generates configuration files
``` ```
Ensure the version of Go is compatible with the version required by OpenIM (refer to the main documentation for version requirements). If openim-chat has not deployed MySQL, you will need to deploy it. Note that the official Docker Hub for MySQL does not support architectures like ARM, so you can use the newer version of the open-source edition:
```bash
docker run -d \
--name mysql \
-p 13306:3306 \
-p 3306:33060 \
-v "$(pwd)/components/mysql/data:/var/lib/mysql" \
-v "/etc/localtime:/etc/localtime" \
-e MYSQL_ROOT_PASSWORD="openIM123" \
--restart always \
mariadb:10.6
```
### Additional Tools Before starting the source code of openim-chat, set `config/config.yaml` by replacing all instances of `172.28.0.1` with `127.0.0.1`:
Install other required tools like Docker, Vagrant, and necessary GNU utils as described in the main documentation. ```bash
vim config/config.yaml -c "%s/172\.28\.0\.1/127.0.0.1/g" -c "wq"
```
Then start openim-chat from source:
```bash
make start
```
To check, ensure the following four processes start successfully:
```bash
make check
```
### Docker Deployment
Refer to https://github.com/openimsdk/openim-docker for Docker deployment instructions, which can be followed similarly on Linux.
```bash
git clone https://github.com/openimsdk/openim-docker
cd openim-docker
export OPENIM_IP="Your IP"
make init
docker compose up -d
docker compose logs -f openim-server
docker compose logs -f openim-chat
```
## GitHub Development Workflow ## GitHub Development Workflow

@ -5,7 +5,7 @@ go 1.19
require ( require (
firebase.google.com/go v3.13.0+incompatible firebase.google.com/go v3.13.0+incompatible
github.com/OpenIMSDK/protocol v0.0.48 github.com/OpenIMSDK/protocol v0.0.48
github.com/OpenIMSDK/tools v0.0.23 github.com/OpenIMSDK/tools v0.0.28
github.com/bwmarrin/snowflake v0.3.0 // indirect github.com/bwmarrin/snowflake v0.3.0 // indirect
github.com/dtm-labs/rockscache v0.1.1 github.com/dtm-labs/rockscache v0.1.1
github.com/gin-gonic/gin v1.9.1 github.com/gin-gonic/gin v1.9.1
@ -38,6 +38,7 @@ require (
github.com/aliyun/aliyun-oss-go-sdk v2.2.9+incompatible github.com/aliyun/aliyun-oss-go-sdk v2.2.9+incompatible
github.com/go-redis/redis v6.15.9+incompatible github.com/go-redis/redis v6.15.9+incompatible
github.com/redis/go-redis/v9 v9.2.1 github.com/redis/go-redis/v9 v9.2.1
github.com/spf13/pflag v1.0.5
github.com/stathat/consistent v1.0.0 github.com/stathat/consistent v1.0.0
github.com/tencentyun/cos-go-sdk-v5 v0.7.45 github.com/tencentyun/cos-go-sdk-v5 v0.7.45
go.uber.org/automaxprocs v1.5.3 go.uber.org/automaxprocs v1.5.3
@ -116,7 +117,6 @@ require (
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rs/xid v1.5.0 // indirect github.com/rs/xid v1.5.0 // indirect
github.com/sergi/go-diff v1.0.0 // indirect github.com/sergi/go-diff v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/src-d/gcfg v1.4.0 // indirect github.com/src-d/gcfg v1.4.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect github.com/stretchr/objx v0.5.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect

@ -15,13 +15,13 @@ cloud.google.com/go/storage v1.30.1 h1:uOdMxAs8HExqBlnLtnQyP0YkvbiDpdGShGKtx6U/o
cloud.google.com/go/storage v1.30.1/go.mod h1:NfxhC0UJE1aXSx7CIIbCf7y9HKT7BiccwkR7+P7gN8E= cloud.google.com/go/storage v1.30.1/go.mod h1:NfxhC0UJE1aXSx7CIIbCf7y9HKT7BiccwkR7+P7gN8E=
firebase.google.com/go v3.13.0+incompatible h1:3TdYC3DDi6aHn20qoRkxwGqNgdjtblwVAyRLQwGn/+4= firebase.google.com/go v3.13.0+incompatible h1:3TdYC3DDi6aHn20qoRkxwGqNgdjtblwVAyRLQwGn/+4=
firebase.google.com/go v3.13.0+incompatible/go.mod h1:xlah6XbEyW6tbfSklcfe5FHJIwjt8toICdV5Wh9ptHs= firebase.google.com/go v3.13.0+incompatible/go.mod h1:xlah6XbEyW6tbfSklcfe5FHJIwjt8toICdV5Wh9ptHs=
github.com/AndrewZuo01/protocol v0.0.0-20240112093520-fd9c53e27b94 h1:o86vkek41ZrQqoBGqyKvS0z6N0uJj64mpzK72OkDZVM=
github.com/AndrewZuo01/protocol v0.0.0-20240112093520-fd9c53e27b94/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/IBM/sarama v1.41.3 h1:MWBEJ12vHC8coMjdEXFq/6ftO6DUZnQlFYcxtOJFa7c= github.com/IBM/sarama v1.41.3 h1:MWBEJ12vHC8coMjdEXFq/6ftO6DUZnQlFYcxtOJFa7c=
github.com/IBM/sarama v1.41.3/go.mod h1:Xxho9HkHd4K/MDUo/T/sOqwtX/17D33++E9Wib6hUdQ= github.com/IBM/sarama v1.41.3/go.mod h1:Xxho9HkHd4K/MDUo/T/sOqwtX/17D33++E9Wib6hUdQ=
github.com/OpenIMSDK/tools v0.0.23 h1:xozfrGzhbpNPlDTap5DLVPk+JfgZ/ZyIj4Cuu3/bm9w= github.com/OpenIMSDK/protocol v0.0.48 h1:8MIMjyzJRsruYhVv2ZKArFiOveroaofDOb3dlAdgjsw=
github.com/OpenIMSDK/tools v0.0.23/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI= github.com/OpenIMSDK/protocol v0.0.48/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
github.com/OpenIMSDK/tools v0.0.28 h1:UT0rN1ysCFvsxQXyuxAj2TEkHt4C/sUezy+ChKpgt2Y=
github.com/OpenIMSDK/tools v0.0.28/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI=
github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM= github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM=
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs= github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs=
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs= github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=

@ -201,27 +201,27 @@ func (u *UserApi) GetSubscribeUsersStatus(c *gin.Context) {
a2r.Call(user.UserClient.GetSubscribeUsersStatus, u.Client, c) a2r.Call(user.UserClient.GetSubscribeUsersStatus, u.Client, c)
} }
// ProcessUserCommandAdd user general function add // ProcessUserCommandAdd user general function add.
func (u *UserApi) ProcessUserCommandAdd(c *gin.Context) { func (u *UserApi) ProcessUserCommandAdd(c *gin.Context) {
a2r.Call(user.UserClient.ProcessUserCommandAdd, u.Client, c) a2r.Call(user.UserClient.ProcessUserCommandAdd, u.Client, c)
} }
// ProcessUserCommandDelete user general function delete // ProcessUserCommandDelete user general function delete.
func (u *UserApi) ProcessUserCommandDelete(c *gin.Context) { func (u *UserApi) ProcessUserCommandDelete(c *gin.Context) {
a2r.Call(user.UserClient.ProcessUserCommandDelete, u.Client, c) a2r.Call(user.UserClient.ProcessUserCommandDelete, u.Client, c)
} }
// ProcessUserCommandUpdate user general function update // ProcessUserCommandUpdate user general function update.
func (u *UserApi) ProcessUserCommandUpdate(c *gin.Context) { func (u *UserApi) ProcessUserCommandUpdate(c *gin.Context) {
a2r.Call(user.UserClient.ProcessUserCommandUpdate, u.Client, c) a2r.Call(user.UserClient.ProcessUserCommandUpdate, u.Client, c)
} }
// ProcessUserCommandGet user general function get // ProcessUserCommandGet user general function get.
func (u *UserApi) ProcessUserCommandGet(c *gin.Context) { func (u *UserApi) ProcessUserCommandGet(c *gin.Context) {
a2r.Call(user.UserClient.ProcessUserCommandGet, u.Client, c) a2r.Call(user.UserClient.ProcessUserCommandGet, u.Client, c)
} }
// ProcessUserCommandGet user general function get all // ProcessUserCommandGet user general function get all.
func (u *UserApi) ProcessUserCommandGetAll(c *gin.Context) { func (u *UserApi) ProcessUserCommandGetAll(c *gin.Context) {
a2r.Call(user.UserClient.ProcessUserCommandGetAll, u.Client, c) a2r.Call(user.UserClient.ProcessUserCommandGetAll, u.Client, c)
} }

@ -19,7 +19,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"github.com/OpenIMSDK/tools/apiresp"
"net/http" "net/http"
"os" "os"
"os/signal" "os/signal"
@ -29,6 +28,8 @@ import (
"syscall" "syscall"
"time" "time"
"github.com/OpenIMSDK/tools/apiresp"
"github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10"
"github.com/redis/go-redis/v9" "github.com/redis/go-redis/v9"
"golang.org/x/sync/errgroup" "golang.org/x/sync/errgroup"

@ -16,9 +16,10 @@ package push
import ( import (
"context" "context"
"github.com/OpenIMSDK/tools/utils"
"sync" "sync"
"github.com/OpenIMSDK/tools/utils"
"google.golang.org/grpc" "google.golang.org/grpc"
"github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/constant"

@ -18,9 +18,10 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"errors" "errors"
"google.golang.org/grpc"
"sync" "sync"
"google.golang.org/grpc"
"golang.org/x/sync/errgroup" "golang.org/x/sync/errgroup"
"github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/constant"
@ -143,7 +144,7 @@ func (p *Pusher) UnmarshalNotificationElem(bytes []byte, t any) error {
} }
/* /*
k8s deployment,offline push group messages function k8s deployment,offline push group messages function.
*/ */
func (p *Pusher) k8sOfflinePush2SuperGroup(ctx context.Context, groupID string, msg *sdkws.MsgData, wsResults []*msggateway.SingleMsgToUserResults) error { func (p *Pusher) k8sOfflinePush2SuperGroup(ctx context.Context, groupID string, msg *sdkws.MsgData, wsResults []*msggateway.SingleMsgToUserResults) error {

@ -17,9 +17,10 @@ package conversation
import ( import (
"context" "context"
"errors" "errors"
"github.com/OpenIMSDK/protocol/sdkws"
"sort" "sort"
"github.com/OpenIMSDK/protocol/sdkws"
"github.com/OpenIMSDK/tools/tx" "github.com/OpenIMSDK/tools/tx"
"github.com/openimsdk/open-im-server/v3/pkg/common/db/mgo" "github.com/openimsdk/open-im-server/v3/pkg/common/db/mgo"

@ -18,6 +18,7 @@ import (
"context" "context"
utils2 "github.com/OpenIMSDK/tools/utils" utils2 "github.com/OpenIMSDK/tools/utils"
cbapi "github.com/openimsdk/open-im-server/v3/pkg/callbackstruct" cbapi "github.com/openimsdk/open-im-server/v3/pkg/callbackstruct"
"github.com/redis/go-redis/v9" "github.com/redis/go-redis/v9"

@ -16,6 +16,7 @@ package msg
import ( import (
"context" "context"
pbmsg "github.com/OpenIMSDK/protocol/msg" pbmsg "github.com/OpenIMSDK/protocol/msg"
) )

@ -19,12 +19,14 @@ import (
"encoding/base64" "encoding/base64"
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
"github.com/google/uuid"
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
"path" "path"
"strconv" "strconv"
"time" "time"
"github.com/google/uuid"
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
"github.com/openimsdk/open-im-server/v3/pkg/common/db/s3" "github.com/openimsdk/open-im-server/v3/pkg/common/db/s3"
"github.com/OpenIMSDK/protocol/third" "github.com/OpenIMSDK/protocol/third"

@ -16,6 +16,7 @@ package user
import ( import (
"context" "context"
pbuser "github.com/OpenIMSDK/protocol/user" pbuser "github.com/OpenIMSDK/protocol/user"
"github.com/OpenIMSDK/tools/utils" "github.com/OpenIMSDK/tools/utils"

@ -17,12 +17,14 @@ package user
import ( import (
"context" "context"
"errors" "errors"
"github.com/OpenIMSDK/tools/pagination"
"github.com/openimsdk/open-im-server/v3/pkg/common/db/table/relation"
"math/rand" "math/rand"
"strings" "strings"
"time" "time"
"github.com/OpenIMSDK/tools/pagination"
"github.com/openimsdk/open-im-server/v3/pkg/common/db/table/relation"
"github.com/OpenIMSDK/tools/tx" "github.com/OpenIMSDK/tools/tx"
"github.com/openimsdk/open-im-server/v3/pkg/common/db/mgo" "github.com/openimsdk/open-im-server/v3/pkg/common/db/mgo"
@ -387,7 +389,7 @@ func (s *userServer) GetSubscribeUsersStatus(ctx context.Context,
return &pbuser.GetSubscribeUsersStatusResp{StatusList: onlineStatusList}, nil return &pbuser.GetSubscribeUsersStatusResp{StatusList: onlineStatusList}, nil
} }
// ProcessUserCommandAdd user general function add // ProcessUserCommandAdd user general function add.
func (s *userServer) ProcessUserCommandAdd(ctx context.Context, req *pbuser.ProcessUserCommandAddReq) (*pbuser.ProcessUserCommandAddResp, error) { func (s *userServer) ProcessUserCommandAdd(ctx context.Context, req *pbuser.ProcessUserCommandAddReq) (*pbuser.ProcessUserCommandAddResp, error) {
err := authverify.CheckAccessV3(ctx, req.UserID) err := authverify.CheckAccessV3(ctx, req.UserID)
if err != nil { if err != nil {
@ -418,7 +420,7 @@ func (s *userServer) ProcessUserCommandAdd(ctx context.Context, req *pbuser.Proc
return &pbuser.ProcessUserCommandAddResp{}, nil return &pbuser.ProcessUserCommandAddResp{}, nil
} }
// ProcessUserCommandDelete user general function delete // ProcessUserCommandDelete user general function delete.
func (s *userServer) ProcessUserCommandDelete(ctx context.Context, req *pbuser.ProcessUserCommandDeleteReq) (*pbuser.ProcessUserCommandDeleteResp, error) { func (s *userServer) ProcessUserCommandDelete(ctx context.Context, req *pbuser.ProcessUserCommandDeleteReq) (*pbuser.ProcessUserCommandDeleteResp, error) {
err := authverify.CheckAccessV3(ctx, req.UserID) err := authverify.CheckAccessV3(ctx, req.UserID)
if err != nil { if err != nil {
@ -440,7 +442,7 @@ func (s *userServer) ProcessUserCommandDelete(ctx context.Context, req *pbuser.P
return &pbuser.ProcessUserCommandDeleteResp{}, nil return &pbuser.ProcessUserCommandDeleteResp{}, nil
} }
// ProcessUserCommandUpdate user general function update // ProcessUserCommandUpdate user general function update.
func (s *userServer) ProcessUserCommandUpdate(ctx context.Context, req *pbuser.ProcessUserCommandUpdateReq) (*pbuser.ProcessUserCommandUpdateResp, error) { func (s *userServer) ProcessUserCommandUpdate(ctx context.Context, req *pbuser.ProcessUserCommandUpdateReq) (*pbuser.ProcessUserCommandUpdateResp, error) {
err := authverify.CheckAccessV3(ctx, req.UserID) err := authverify.CheckAccessV3(ctx, req.UserID)
if err != nil { if err != nil {

@ -17,6 +17,7 @@ package convert
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/OpenIMSDK/protocol/sdkws" "github.com/OpenIMSDK/protocol/sdkws"
"github.com/OpenIMSDK/tools/utils" "github.com/OpenIMSDK/tools/utils"

@ -146,7 +146,7 @@ func Test_BatchInsertChat2DB(t *testing.T) {
func GetDB() *commonMsgDatabase { func GetDB() *commonMsgDatabase {
config.Config.Mongo.Address = []string{"203.56.175.233:37017"} config.Config.Mongo.Address = []string{"203.56.175.233:37017"}
// config.Config.Mongo.Timeout = 60 // config.Config.Mongo.Timeout = 60
config.Config.Mongo.Database = "openIM_v3" config.Config.Mongo.Database = "openim_v3"
// config.Config.Mongo.Source = "admin" // config.Config.Mongo.Source = "admin"
config.Config.Mongo.Username = "root" config.Config.Mongo.Username = "root"
config.Config.Mongo.Password = "openIM123" config.Config.Mongo.Password = "openIM123"

@ -142,12 +142,12 @@ func (u *userDatabase) Find(ctx context.Context, userIDs []string) (users []*rel
return u.cache.GetUsersInfo(ctx, userIDs) return u.cache.GetUsersInfo(ctx, userIDs)
} }
// Find userInfo By Nickname // Find userInfo By Nickname.
func (u *userDatabase) FindByNickname(ctx context.Context, nickname string) (users []*relation.UserModel, err error) { func (u *userDatabase) FindByNickname(ctx context.Context, nickname string) (users []*relation.UserModel, err error) {
return u.userDB.TakeByNickname(ctx, nickname) return u.userDB.TakeByNickname(ctx, nickname)
} }
// Find notificationAccouts // Find notificationAccouts.
func (u *userDatabase) FindNotification(ctx context.Context, level int64) (users []*relation.UserModel, err error) { func (u *userDatabase) FindNotification(ctx context.Context, level int64) (users []*relation.UserModel, err error) {
return u.userDB.TakeNotification(ctx, level) return u.userDB.TakeNotification(ctx, level)
} }
@ -190,7 +190,14 @@ func (u *userDatabase) Page(ctx context.Context, pagination pagination.Paginatio
func (u *userDatabase) PageFindUser(ctx context.Context, level1 int64, level2 int64, pagination pagination.Pagination) (count int64, users []*relation.UserModel, err error) { func (u *userDatabase) PageFindUser(ctx context.Context, level1 int64, level2 int64, pagination pagination.Pagination) (count int64, users []*relation.UserModel, err error) {
return u.userDB.PageFindUser(ctx, level1, level2, pagination) return u.userDB.PageFindUser(ctx, level1, level2, pagination)
} }
func (u *userDatabase) PageFindUserWithKeyword(ctx context.Context, level1 int64, level2 int64, userID, nickName string, pagination pagination.Pagination) (count int64, users []*relation.UserModel, err error) {
func (u *userDatabase) PageFindUserWithKeyword(
ctx context.Context,
level1 int64,
level2 int64,
userID, nickName string,
pagination pagination.Pagination,
) (count int64, users []*relation.UserModel, err error) {
return u.userDB.PageFindUserWithKeyword(ctx, level1, level2, userID, nickName, pagination) return u.userDB.PageFindUserWithKeyword(ctx, level1, level2, userID, nickName, pagination)
} }

@ -16,6 +16,7 @@ package mgo
import ( import (
"context" "context"
"github.com/OpenIMSDK/tools/mgoutil" "github.com/OpenIMSDK/tools/mgoutil"
"github.com/OpenIMSDK/tools/pagination" "github.com/OpenIMSDK/tools/pagination"
"go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/options"

@ -16,10 +16,11 @@ package mgo
import ( import (
"context" "context"
"time"
"github.com/OpenIMSDK/protocol/user" "github.com/OpenIMSDK/protocol/user"
"github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/errs"
"go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/bson/primitive"
"time"
"github.com/OpenIMSDK/tools/mgoutil" "github.com/OpenIMSDK/tools/mgoutil"
"github.com/OpenIMSDK/tools/pagination" "github.com/OpenIMSDK/tools/pagination"
@ -89,7 +90,15 @@ func (u *UserMgo) PageFindUser(ctx context.Context, level1 int64, level2 int64,
return mgoutil.FindPage[*relation.UserModel](ctx, u.coll, query, pagination) return mgoutil.FindPage[*relation.UserModel](ctx, u.coll, query, pagination)
} }
func (u *UserMgo) PageFindUserWithKeyword(ctx context.Context, level1 int64, level2 int64, userID string, nickName string, pagination pagination.Pagination) (count int64, users []*relation.UserModel, err error) {
func (u *UserMgo) PageFindUserWithKeyword(
ctx context.Context,
level1 int64,
level2 int64,
userID string,
nickName string,
pagination pagination.Pagination,
) (count int64, users []*relation.UserModel, err error) {
// Initialize the base query with level conditions // Initialize the base query with level conditions
query := bson.M{ query := bson.M{
"$and": []bson.M{ "$and": []bson.M{

@ -36,9 +36,9 @@ import (
) )
const ( const (
minPartSize = 1024 * 1024 * 1 // 1MB minPartSize int64 = 1024 * 1024 * 1 // 1MB
maxPartSize = 1024 * 1024 * 1024 * 5 // 5GB maxPartSize int64 = 1024 * 1024 * 1024 * 5 // 5GB
maxNumSize = 1000 maxNumSize int64 = 1000
) )
const ( const (
@ -133,7 +133,7 @@ func (c *Cos) PartSize(ctx context.Context, size int64) (int64, error) {
return 0, errors.New("size must be greater than 0") return 0, errors.New("size must be greater than 0")
} }
if size > maxPartSize*maxNumSize { if size > maxPartSize*maxNumSize {
return 0, fmt.Errorf("size must be less than %db", maxPartSize*maxNumSize) return 0, fmt.Errorf("COS size must be less than the maximum allowed limit")
} }
if size <= minPartSize*maxNumSize { if size <= minPartSize*maxNumSize {
return minPartSize, nil return minPartSize, nil

@ -45,9 +45,9 @@ const (
) )
const ( const (
minPartSize = 1024 * 1024 * 5 // 1MB minPartSize int64 = 1024 * 1024 * 5 // 1MB
maxPartSize = 1024 * 1024 * 1024 * 5 // 5GB maxPartSize int64 = 1024 * 1024 * 1024 * 5 // 5GB
maxNumSize = 10000 maxNumSize int64 = 10000
) )
const ( const (
@ -240,7 +240,7 @@ func (m *Minio) PartSize(ctx context.Context, size int64) (int64, error) {
return 0, errors.New("size must be greater than 0") return 0, errors.New("size must be greater than 0")
} }
if size > maxPartSize*maxNumSize { if size > maxPartSize*maxNumSize {
return 0, fmt.Errorf("size must be less than %db", maxPartSize*maxNumSize) return 0, fmt.Errorf("MINIO size must be less than the maximum allowed limit")
} }
if size <= minPartSize*maxNumSize { if size <= minPartSize*maxNumSize {
return minPartSize, nil return minPartSize, nil

@ -37,9 +37,9 @@ import (
) )
const ( const (
minPartSize = 1024 * 1024 * 1 // 1MB minPartSize int64 = 1024 * 1024 * 1 // 1MB
maxPartSize = 1024 * 1024 * 1024 * 5 // 5GB maxPartSize int64 = 1024 * 1024 * 1024 * 5 // 5GB
maxNumSize = 10000 maxNumSize int64 = 10000
) )
const ( const (
@ -141,7 +141,7 @@ func (o *OSS) PartSize(ctx context.Context, size int64) (int64, error) {
return 0, errors.New("size must be greater than 0") return 0, errors.New("size must be greater than 0")
} }
if size > maxPartSize*maxNumSize { if size > maxPartSize*maxNumSize {
return 0, fmt.Errorf("size must be less than %db", maxPartSize*maxNumSize) return 0, fmt.Errorf("OSS size must be less than the maximum allowed limit")
} }
if size <= minPartSize*maxNumSize { if size <= minPartSize*maxNumSize {
return minPartSize, nil return minPartSize, nil

@ -24,7 +24,7 @@ import (
type PartLimit struct { type PartLimit struct {
MinPartSize int64 `json:"minPartSize"` MinPartSize int64 `json:"minPartSize"`
MaxPartSize int64 `json:"maxPartSize"` MaxPartSize int64 `json:"maxPartSize"`
MaxNumSize int `json:"maxNumSize"` MaxNumSize int64 `json:"maxNumSize"`
} }
type InitiateMultipartUploadResult struct { type InitiateMultipartUploadResult struct {

@ -16,9 +16,10 @@ package relation
import ( import (
"context" "context"
"github.com/OpenIMSDK/protocol/user"
"time" "time"
"github.com/OpenIMSDK/protocol/user"
"github.com/OpenIMSDK/tools/pagination" "github.com/OpenIMSDK/tools/pagination"
) )

@ -18,15 +18,17 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/stathat/consistent"
"os" "os"
"strconv" "strconv"
"strings" "strings"
"github.com/stathat/consistent"
"google.golang.org/grpc" "google.golang.org/grpc"
"github.com/OpenIMSDK/tools/discoveryregistry" "github.com/OpenIMSDK/tools/discoveryregistry"
"github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/log"
"github.com/openimsdk/open-im-server/v3/pkg/common/config" "github.com/openimsdk/open-im-server/v3/pkg/common/config"
) )
@ -102,7 +104,7 @@ func getSelfHost(ctx context.Context) string {
return host return host
} }
// like openimserver-openim-msggateway-0.openimserver-openim-msggateway-headless.openim-lin.svc.cluster.local:88 // like openimserver-openim-msggateway-0.openimserver-openim-msggateway-headless.openim-lin.svc.cluster.local:88.
func getMsgGatewayHost(ctx context.Context) []string { func getMsgGatewayHost(ctx context.Context) []string {
port := 88 port := 88
instance := "openimserver" instance := "openimserver"
@ -166,7 +168,7 @@ func (cli *K8sDR) CloseConn(conn *grpc.ClientConn) {
conn.Close() conn.Close()
} }
// do not use this method for call rpc // do not use this method for call rpc.
func (cli *K8sDR) GetClientLocalConns() map[string][]*grpc.ClientConn { func (cli *K8sDR) GetClientLocalConns() map[string][]*grpc.ClientConn {
fmt.Println("should not call this function!!!!!!!!!!!!!!!!!!!!!!!!!") fmt.Println("should not call this function!!!!!!!!!!!!!!!!!!!!!!!!!")
return nil return nil

@ -17,6 +17,7 @@ package rpcclient
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"

@ -1,7 +1,21 @@
// Copyright © 2024 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 flag package flag
import ( import (
goFlag "flag" "flag"
"log" "log"
"strings" "strings"
@ -29,7 +43,7 @@ func WarnWordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedNam
// InitFlags normalizes, parses, then logs the command line flags. // InitFlags normalizes, parses, then logs the command line flags.
func InitFlags() { func InitFlags() {
pflag.CommandLine.SetNormalizeFunc(WordSepNormalizeFunc) pflag.CommandLine.SetNormalizeFunc(WordSepNormalizeFunc)
pflag.CommandLine.AddGoFlagSet(goFlag.CommandLine) pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
} }
// PrintFlags logs the flags in the flagset. // PrintFlags logs the flags in the flagset.

@ -1,3 +1,17 @@
// Copyright © 2024 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 genutil package genutil
import ( import (

@ -1,3 +1,17 @@
// Copyright © 2024 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 genutil package genutil
import ( import (

@ -0,0 +1,173 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#**************************************************************************
# Copyright (C) 2011, Paul Lutus *
# *
# This program is free software; you can redistribute it and/or modify *
# it under the terms of the GNU General Public License as published by *
# the Free Software Foundation; either version 2 of the License, or *
# (at your option) any later version. *
# *
# This program is distributed in the hope that it will be useful, *
# but WITHOUT ANY WARRANTY; without even the implied warranty of *
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# GNU General Public License for more details. *
# *
# You should have received a copy of the GNU General Public License *
# along with this program; if not, write to the *
# Free Software Foundation, Inc., *
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
#**************************************************************************
import re
import sys
PVERSION = '1.0'
class BeautifyBash:
def __init__(self):
self.tab_str = ' '
self.tab_size = 2
def read_file(self, fp):
with open(fp) as f:
return f.read()
def write_file(self, fp, data):
with open(fp, 'w') as f:
f.write(data)
def beautify_string(self, data, path=''):
tab = 0
case_stack = []
in_here_doc = False
defer_ext_quote = False
in_ext_quote = False
ext_quote_string = ''
here_string = ''
output = []
line = 1
for record in re.split('\n', data):
record = record.rstrip()
stripped_record = record.strip()
# collapse multiple quotes between ' ... '
test_record = re.sub(r'\'.*?\'', '', stripped_record)
# collapse multiple quotes between " ... "
test_record = re.sub(r'".*?"', '', test_record)
# collapse multiple quotes between ` ... `
test_record = re.sub(r'`.*?`', '', test_record)
# collapse multiple quotes between \` ... ' (weird case)
test_record = re.sub(r'\\`.*?\'', '', test_record)
# strip out any escaped single characters
test_record = re.sub(r'\\.', '', test_record)
# remove '#' comments
test_record = re.sub(r'(\A|\s)(#.*)', '', test_record, 1)
if(not in_here_doc):
if(re.search('<<-?', test_record)):
here_string = re.sub(
'.*<<-?\s*[\'|"]?([_|\w]+)[\'|"]?.*', '\\1', stripped_record, 1)
in_here_doc = (len(here_string) > 0)
if(in_here_doc): # pass on with no changes
output.append(record)
# now test for here-doc termination string
if(re.search(here_string, test_record) and not re.search('<<', test_record)):
in_here_doc = False
else: # not in here doc
if(in_ext_quote):
if(re.search(ext_quote_string, test_record)):
# provide line after quotes
test_record = re.sub(
'.*%s(.*)' % ext_quote_string, '\\1', test_record, 1)
in_ext_quote = False
else: # not in ext quote
if(re.search(r'(\A|\s)(\'|")', test_record)):
# apply only after this line has been processed
defer_ext_quote = True
ext_quote_string = re.sub(
'.*([\'"]).*', '\\1', test_record, 1)
# provide line before quote
test_record = re.sub(
'(.*)%s.*' % ext_quote_string, '\\1', test_record, 1)
if(in_ext_quote):
# pass on unchanged
output.append(record)
else: # not in ext quote
inc = len(re.findall(
'(\s|\A|;)(case|then|do)(;|\Z|\s)', test_record))
inc += len(re.findall('(\{|\(|\[)', test_record))
outc = len(re.findall(
'(\s|\A|;)(esac|fi|done|elif)(;|\)|\||\Z|\s)', test_record))
outc += len(re.findall('(\}|\)|\])', test_record))
if(re.search(r'\besac\b', test_record)):
if(len(case_stack) == 0):
sys.stderr.write(
'File %s: error: "esac" before "case" in line %d.\n' % (
path, line)
)
else:
outc += case_stack.pop()
# sepcial handling for bad syntax within case ... esac
if(len(case_stack) > 0):
if(re.search('\A[^(]*\)', test_record)):
# avoid overcount
outc -= 2
case_stack[-1] += 1
if(re.search(';;', test_record)):
outc += 1
case_stack[-1] -= 1
# an ad-hoc solution for the "else" keyword
else_case = (
0, -1)[re.search('^(else)', test_record) != None]
net = inc - outc
tab += min(net, 0)
extab = tab + else_case
extab = max(0, extab)
output.append(
(self.tab_str * self.tab_size * extab) + stripped_record)
tab += max(net, 0)
if(defer_ext_quote):
in_ext_quote = True
defer_ext_quote = False
if(re.search(r'\bcase\b', test_record)):
case_stack.append(0)
line += 1
error = (tab != 0)
if(error):
sys.stderr.write(
'File %s: error: indent/outdent mismatch: %d.\n' % (path, tab))
return '\n'.join(output), error
def beautify_file(self, path):
error = False
if(path == '-'):
data = sys.stdin.read()
result, error = self.beautify_string(data, '(stdin)')
sys.stdout.write(result)
else: # named file
data = self.read_file(path)
result, error = self.beautify_string(data, path)
if(data != result):
# make a backup copy
self.write_file(path + '~', data)
self.write_file(path, result)
return error
def main(self):
error = False
sys.argv.pop(0)
if(len(sys.argv) < 1):
sys.stderr.write(
'usage: shell script filenames or \"-\" for stdin.\n')
else:
for path in sys.argv:
error |= self.beautify_file(path)
sys.exit((0, 1)[error])
# if not called as a module
if(__name__ == '__main__'):
BeautifyBash().main()

@ -148,7 +148,7 @@ function openim::build::verify_prereqs() {
fi fi
OPENIM_GIT_BRANCH=$(git symbolic-ref --short -q HEAD 2>/dev/null || true) OPENIM_GIT_BRANCH=$(git symbolic-ref --short -q HEAD 2>/dev/null || true)
OPENIM_ROOT_HASH=$(openim::build::short_hash "${HOSTNAME:-}:"${OPENIM_ROOT}":${OPENIM_GIT_BRANCH}") OPENIM_ROOT_HASH=$(openim::build::short_hash "${HOSTNAME:-}:${OPENIM_ROOT}:${OPENIM_GIT_BRANCH}")
OPENIM_BUILD_IMAGE_TAG_BASE="build-${OPENIM_ROOT_HASH}" OPENIM_BUILD_IMAGE_TAG_BASE="build-${OPENIM_ROOT_HASH}"
#OPENIM_BUILD_IMAGE_TAG="${OPENIM_BUILD_IMAGE_TAG_BASE}-${OPENIM_BUILD_IMAGE_VERSION}" #OPENIM_BUILD_IMAGE_TAG="${OPENIM_BUILD_IMAGE_TAG_BASE}-${OPENIM_BUILD_IMAGE_VERSION}"
#OPENIM_BUILD_IMAGE="${OPENIM_BUILD_IMAGE_REPO}:${OPENIM_BUILD_IMAGE_TAG}" #OPENIM_BUILD_IMAGE="${OPENIM_BUILD_IMAGE_REPO}:${OPENIM_BUILD_IMAGE_TAG}"

@ -18,9 +18,9 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
version="${VERSION}" version="${VERSION}"
if [ "${version}" == "" ];then if [ "${version}" == "" ];then
version=v`${OPENIM_ROOT}/_output/tools/gsemver bump` version=v$(${OPENIM_ROOT}/_output/tools/gsemver bump)
fi fi
if [ -z "`git tag -l ${version}`" ];then if [ -z "$(git tag -l ${version})" ];then
git tag -a -m "release version ${version}" ${version} git tag -a -m "release version ${version}" ${version}
fi fi

@ -67,7 +67,7 @@ echo -e "=== any\nRepresents an untyped JSON map - see the description of the fi
asciidoctor definitions.adoc asciidoctor definitions.adoc
asciidoctor paths.adoc asciidoctor paths.adoc
cp ${OPENIM_OUTPUT_TMP}/definitions.html ${OPENIM_OUTPUT_TMP}/_output/ cp "$OPENIM_OUTPUT_TMP/definitions.html" "$OPENIM_OUTPUT_TMP/_output/"
cp ${OPENIM_OUTPUT_TMP}/paths.html ${OPENIM_OUTPUT_TMP}/_output/operations.html cp "$OPENIM_OUTPUT_TMP/paths.html" "$OPENIM_OUTPUT_TMP/_output/operations.html"
success "SUCCESS" success "SUCCESS"

@ -25,7 +25,7 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${OPENIM_ROOT}/scripts/lib/init.sh" source "${OPENIM_ROOT}/scripts/lib/init.sh"
if [ $# -ne 2 ];then if [ $# -ne 2 ];then
openim::log::error "Usage: scripts/genconfig.sh scripts/environment.sh configs/openim-api.yaml" openim::log::error "Usage: scripts/genconfig.sh scripts/environment.sh configs/config.yaml"
exit 1 exit 1
fi fi
@ -47,7 +47,7 @@ do
done done
if [ "${missing}" ];then if [ "${missing}" ];then
openim::log::error 'You may run `source scripts/environment.sh` to set these environment' openim::log::error "You may run 'source scripts/environment.sh' to set these environment"
exit 1 exit 1
fi fi

@ -38,7 +38,7 @@ printError() {
printMessage "Running local OpenIM pre-push hook." printMessage "Running local OpenIM pre-push hook."
if [[ `git status --porcelain` ]]; then if [[ $(git status --porcelain) ]]; then
printError "This scripts needs to run against committed code only. Please commit or stash you changes." printError "This scripts needs to run against committed code only. Please commit or stash you changes."
exit 1 exit 1
fi fi

@ -31,7 +31,7 @@ readonly ENV_FILE=${ENV_FILE:-"${OPENIM_ROOT}/scripts/install/environment.sh"}
# Templates for configuration files # Templates for configuration files
declare -A TEMPLATES=( declare -A TEMPLATES=(
["${OPENIM_ROOT}/deployments/templates/env-template.yaml"]="${OPENIM_ROOT}/.env" ["${OPENIM_ROOT}/deployments/templates/env-template.yaml"]="${OPENIM_ROOT}/.env"
["${OPENIM_ROOT}/deployments/templates/openim.yaml"]="${OPENIM_ROOT}/config/config.yaml" ["${OPENIM_ROOT}/deployments/templates/config.yaml"]="${OPENIM_ROOT}/config/config.yaml"
["${OPENIM_ROOT}/deployments/templates/prometheus.yml"]="${OPENIM_ROOT}/config/prometheus.yml" ["${OPENIM_ROOT}/deployments/templates/prometheus.yml"]="${OPENIM_ROOT}/config/prometheus.yml"
["${OPENIM_ROOT}/deployments/templates/alertmanager.yml"]="${OPENIM_ROOT}/config/alertmanager.yml" ["${OPENIM_ROOT}/deployments/templates/alertmanager.yml"]="${OPENIM_ROOT}/config/alertmanager.yml"
) )
@ -39,7 +39,7 @@ declare -A TEMPLATES=(
# Templates for example files # Templates for example files
declare -A EXAMPLES=( declare -A EXAMPLES=(
["${OPENIM_ROOT}/deployments/templates/env-template.yaml"]="${OPENIM_ROOT}/config/templates/env.template" ["${OPENIM_ROOT}/deployments/templates/env-template.yaml"]="${OPENIM_ROOT}/config/templates/env.template"
["${OPENIM_ROOT}/deployments/templates/openim.yaml"]="${OPENIM_ROOT}/config/templates/config.yaml.template" ["${OPENIM_ROOT}/deployments/templates/config.yaml"]="${OPENIM_ROOT}/config/templates/config.yaml.template"
["${OPENIM_ROOT}/deployments/templates/prometheus.yml"]="${OPENIM_ROOT}/config/templates/prometheus.yml.template" ["${OPENIM_ROOT}/deployments/templates/prometheus.yml"]="${OPENIM_ROOT}/config/templates/prometheus.yml.template"
["${OPENIM_ROOT}/deployments/templates/alertmanager.yml"]="${OPENIM_ROOT}/config/templates/alertmanager.yml.template" ["${OPENIM_ROOT}/deployments/templates/alertmanager.yml"]="${OPENIM_ROOT}/config/templates/alertmanager.yml.template"
) )
@ -95,6 +95,10 @@ generate_config_files() {
# Function to generate example files # Function to generate example files
generate_example_files() { generate_example_files() {
env_cmd="env -i" env_cmd="env -i"
env_vars["OPENIM_IP"]="127.0.0.1"
env_vars["LOG_STORAGE_LOCATION"]="../../"
for var in "${!env_vars[@]}"; do for var in "${!env_vars[@]}"; do
env_cmd+=" $var='${env_vars[$var]}'" env_cmd+=" $var='${env_vars[$var]}'"
done done
@ -110,7 +114,6 @@ generate_example_files() {
local example_file="${COPY_EXAMPLES[$template]}" local example_file="${COPY_EXAMPLES[$template]}"
process_file "$template" "$example_file" false process_file "$template" "$example_file" false
done done
} }
# Function to process a single file, either by generating or copying # Function to process a single file, either by generating or copying
@ -181,7 +184,6 @@ clean_config_files() {
# Function to clean example files # Function to clean example files
clean_example_files() { clean_example_files() {
# 合并 EXAMPLES 和 COPY_EXAMPLES 数组
local all_examples=("${EXAMPLES[@]}" "${COPY_EXAMPLES[@]}") local all_examples=("${EXAMPLES[@]}" "${COPY_EXAMPLES[@]}")
for example_file in "${all_examples[@]}"; do for example_file in "${all_examples[@]}"; do

@ -50,7 +50,7 @@ help_info() {
} }
delete_hooks() { delete_hooks() {
for file in ${OPENIM_ROOT}/scripts/githooks/*.sh; do for file in "${OPENIM_ROOT}"/scripts/githooks/*.sh; do
hook_name=$(basename "$file" .sh) # This removes the .sh extension hook_name=$(basename "$file" .sh) # This removes the .sh extension
rm -f "$HOOKS_DIR/$hook_name" rm -f "$HOOKS_DIR/$hook_name"
done done

@ -34,7 +34,7 @@ docker run -d \
-e wiredTigerCacheSizeGB=1 \ -e wiredTigerCacheSizeGB=1 \
-e MONGO_INITDB_ROOT_USERNAME=${OPENIM_USER} \ -e MONGO_INITDB_ROOT_USERNAME=${OPENIM_USER} \
-e MONGO_INITDB_ROOT_PASSWORD=${PASSWORD} \ -e MONGO_INITDB_ROOT_PASSWORD=${PASSWORD} \
-e MONGO_INITDB_DATABASE=openIM \ -e MONGO_INITDB_DATABASE=openim_v3 \
-e MONGO_OPENIM_USERNAME=${OPENIM_USER} \ -e MONGO_OPENIM_USERNAME=${OPENIM_USER} \
-e MONGO_OPENIM_PASSWORD=${PASSWORD} \ -e MONGO_OPENIM_PASSWORD=${PASSWORD} \
--restart always \ --restart always \

@ -52,7 +52,7 @@ def "OPENIM_USER" "root"
readonly PASSWORD=${PASSWORD:-'openIM123'} readonly PASSWORD=${PASSWORD:-'openIM123'}
# 设置统一的数据库名称,方便管理 # 设置统一的数据库名称,方便管理
def "DATABASE_NAME" "openIM_v3" def "DATABASE_NAME" "openim_v3"
# Linux系统 openim 用户 # Linux系统 openim 用户
def "LINUX_USERNAME" "openim" def "LINUX_USERNAME" "openim"

@ -76,7 +76,7 @@ function openim::install::install_openim() {
openim::log::info "check openim dependency" openim::log::info "check openim dependency"
openim::common::sudo "cp -r ${OPENIM_ROOT}/config/* ${OPENIM_CONFIG_DIR}/" openim::common::sudo "cp -r ${OPENIM_ROOT}/config/* ${OPENIM_CONFIG_DIR}/"
${OPENIM_ROOT}/scripts/genconfig.sh ${ENV_FILE} ${OPENIM_ROOT}/deployments/templates/openim.yaml > ${OPENIM_CONFIG_DIR}/config.yaml ${OPENIM_ROOT}/scripts/genconfig.sh ${ENV_FILE} ${OPENIM_ROOT}/deployments/templates/config.yaml > ${OPENIM_CONFIG_DIR}/config.yaml
${OPENIM_ROOT}/scripts/genconfig.sh ${ENV_FILE} ${OPENIM_ROOT}/deployments/templates/prometheus.yml > ${OPENIM_CONFIG_DIR}/prometheus.yml ${OPENIM_ROOT}/scripts/genconfig.sh ${ENV_FILE} ${OPENIM_ROOT}/deployments/templates/prometheus.yml > ${OPENIM_CONFIG_DIR}/prometheus.yml
openim::util::check_ports ${OPENIM_DEPENDENCY_PORT_LISTARIES[@]} openim::util::check_ports ${OPENIM_DEPENDENCY_PORT_LISTARIES[@]}

@ -139,7 +139,7 @@ function openim::rpc::start() {
done done
done done
sleep 1 sleep 5
openim::util::check_ports ${OPENIM_RPC_PORT_TARGETS[@]} openim::util::check_ports ${OPENIM_RPC_PORT_TARGETS[@]}
# openim::util::check_ports ${OPENIM_RPC_PROM_PORT_TARGETS[@]} # openim::util::check_ports ${OPENIM_RPC_PROM_PORT_TARGETS[@]}

@ -104,12 +104,7 @@ function openim::tools::start_service() {
cmd="${cmd} --prometheus_port ${prometheus_port}" cmd="${cmd} --prometheus_port ${prometheus_port}"
fi fi
openim::log::status "Starting ${binary_name}..." openim::log::status "Starting ${binary_name}..."
# Later, after discarding Docker, the Docker keyword is unreliable, and Kubepods is used
if grep -qE 'docker|kubepods' /proc/1/cgroup || [ -f /.dockerenv ]; then
${cmd} >> "${LOG_FILE}" 2>&1
else
${cmd} | tee -a "${LOG_FILE}" ${cmd} | tee -a "${LOG_FILE}"
fi
} }
function openim::tools::start() { function openim::tools::start() {

@ -73,20 +73,22 @@ function openim::test::auth() {
# Define a function to get a token for a specific user # Define a function to get a token for a specific user
openim::test::get_token() { openim::test::get_token() {
local user_id="${1:-openIM123456}" # Default user ID if not provided local user_id="${1:-openIM123456}" # Default user ID if not provided
token_response=$(${CCURL} "${OperationID}" "${Header}" ${INSECURE_OPENIMAPI}/auth/user_token \ token_response=$(
-d'{"secret": "'"$SECRET"'","platformID": 1,"userID": "'$user_id'"}') ${CCURL} "${OperationID}" "${Header}" ${INSECURE_OPENIMAPI}/auth/user_token \
-d'{"secret": "'"$SECRET"'","platformID": 1,"userID": "'$user_id'"}'
)
token=$(echo $token_response | grep -Po 'token[" :]+\K[^"]+') token=$(echo $token_response | grep -Po 'token[" :]+\K[^"]+')
echo "$token" echo "$token"
} }
Header="-HContent-Type: application/json" Header="-HContent-Type: application/json"
OperationID="-HoperationID: 1646445464564" OperationID="-HoperationID: 1646445464564"
Token="-Htoken: $(openim::test::get_token)" Token="-Htoken: $(openim::test::get_token)"
# Forces a user to log out from the specified platform by user ID. # Forces a user to log out from the specified platform by user ID.
openim::test::force_logout() { openim::test::force_logout() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"platformID": 2, "platformID": 2,
"userID": "4950983283" "userID": "4950983283"
@ -100,7 +102,6 @@ EOF
openim::test::check_error "$response" openim::test::check_error "$response"
} }
#################################### User Module #################################### #################################### User Module ####################################
# Registers a new user with provided user ID, nickname, and face URL using the API. # Registers a new user with provided user ID, nickname, and face URL using the API.
@ -111,7 +112,8 @@ openim::test::user_register() {
local face_url="${3:-https://github.com/cubxxw}" local face_url="${3:-https://github.com/cubxxw}"
# Create the request body using the provided or default values # Create the request body using the provided or default values
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"secret": "${SECRET}", "secret": "${SECRET}",
"users": [ "users": [
@ -136,7 +138,8 @@ EOF
# Checks if the provided list of user IDs exist in the system. # Checks if the provided list of user IDs exist in the system.
openim::test::check_user_account() { openim::test::check_user_account() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"checkUserIDs": [ "checkUserIDs": [
"${1}", "${1}",
@ -156,7 +159,8 @@ EOF
# Retrieves a list of users with pagination, limited to a specific number per page. # Retrieves a list of users with pagination, limited to a specific number per page.
openim::test::get_users() { openim::test::get_users() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"pagination": { "pagination": {
"pageNumber": 1, "pageNumber": 1,
@ -174,7 +178,8 @@ EOF
# Obtains detailed information for a list of user IDs. # Obtains detailed information for a list of user IDs.
openim::test::get_users_info() { openim::test::get_users_info() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userIDs": [ "userIDs": [
"${1}", "${1}",
@ -192,7 +197,8 @@ EOF
# Retrieves the online status for a list of user IDs. # Retrieves the online status for a list of user IDs.
openim::test::get_users_online_status() { openim::test::get_users_online_status() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userIDs": [ "userIDs": [
"${TEST_USER_ID}", "${TEST_USER_ID}",
@ -212,7 +218,8 @@ EOF
# Updates the information for a user, such as nickname and face URL. # Updates the information for a user, such as nickname and face URL.
openim::test::update_user_info() { openim::test::update_user_info() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userInfo": { "userInfo": {
"userID": "${TEST_USER_ID}", "userID": "${TEST_USER_ID}",
@ -231,7 +238,8 @@ EOF
# Gets the online status for users that a particular user has subscribed to. # Gets the online status for users that a particular user has subscribed to.
openim::test::get_subscribe_users_status() { openim::test::get_subscribe_users_status() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userID": "${TEST_USER_ID}" "userID": "${TEST_USER_ID}"
} }
@ -246,7 +254,8 @@ EOF
# Subscribes to the online status of a list of users for a particular user ID. # Subscribes to the online status of a list of users for a particular user ID.
openim::test::subscribe_users_status() { openim::test::subscribe_users_status() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userID": "9168684795", "userID": "9168684795",
"userIDs": [ "userIDs": [
@ -267,7 +276,8 @@ EOF
# Sets the global message receiving option for a user, determining their messaging preferences. # Sets the global message receiving option for a user, determining their messaging preferences.
openim::test::set_global_msg_recv_opt() { openim::test::set_global_msg_recv_opt() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userID": "${TEST_USER_ID}", "userID": "${TEST_USER_ID}",
"globalRecvMsgOpt": 0 "globalRecvMsgOpt": 0
@ -322,7 +332,8 @@ function openim::test::user() {
# Checks if two users are friends. # Checks if two users are friends.
openim::test::is_friend() { openim::test::is_friend() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userID1": "${1}", "userID1": "${1}",
"userID2": "${2}" "userID2": "${2}"
@ -338,7 +349,8 @@ EOF
# Deletes a friend for a user. # Deletes a friend for a user.
openim::test::delete_friend() { openim::test::delete_friend() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"ownerUserID":"${1}", "ownerUserID":"${1}",
"friendUserID":"${2}" "friendUserID":"${2}"
@ -354,7 +366,8 @@ EOF
# Gets the friend application list for a user. # Gets the friend application list for a user.
openim::test::get_friend_apply_list() { openim::test::get_friend_apply_list() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userID": "${MANAGER_USERID_1}", "userID": "${MANAGER_USERID_1}",
"pagination": { "pagination": {
@ -373,7 +386,8 @@ EOF
# Gets the friend list for a user. # Gets the friend list for a user.
openim::test::get_friend_list() { openim::test::get_friend_list() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userID": "${1}", "userID": "${1}",
"pagination": { "pagination": {
@ -392,7 +406,8 @@ EOF
# Sets a remark for a friend. # Sets a remark for a friend.
openim::test::set_friend_remark() { openim::test::set_friend_remark() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"ownerUserID": "${1}", "ownerUserID": "${1}",
"friendUserID": "${2}", "friendUserID": "${2}",
@ -409,7 +424,8 @@ EOF
# Adds a friend request. # Adds a friend request.
openim::test::add_friend() { openim::test::add_friend() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"fromUserID": "${1}", "fromUserID": "${1}",
"toUserID": "${2}", "toUserID": "${2}",
@ -429,7 +445,8 @@ EOF
openim::test::import_friend() { openim::test::import_friend() {
local friend_ids=$(printf ', "%s"' "${@:2}") local friend_ids=$(printf ', "%s"' "${@:2}")
friend_ids=${friend_ids:2} friend_ids=${friend_ids:2}
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"ownerUserID": "${1}", "ownerUserID": "${1}",
"friendUserIDs": [${friend_ids}] "friendUserIDs": [${friend_ids}]
@ -443,10 +460,10 @@ EOF
openim::test::check_error "$response" openim::test::check_error "$response"
} }
# Responds to a friend request. # Responds to a friend request.
openim::test::add_friend_response() { openim::test::add_friend_response() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"fromUserID": "${1}", "fromUserID": "${1}",
"toUserID": "${2}", "toUserID": "${2}",
@ -464,7 +481,8 @@ EOF
# Retrieves the friend application list that the user has applied for. # Retrieves the friend application list that the user has applied for.
openim::test::get_self_friend_apply_list() { openim::test::get_self_friend_apply_list() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userID": "${1}", "userID": "${1}",
"pagination": { "pagination": {
@ -483,7 +501,8 @@ EOF
# Adds a user to the blacklist. # Adds a user to the blacklist.
openim::test::add_black() { openim::test::add_black() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"ownerUserID": "${1}", "ownerUserID": "${1}",
"blackUserID": "${2}" "blackUserID": "${2}"
@ -499,7 +518,8 @@ EOF
# Removes a user from the blacklist. # Removes a user from the blacklist.
openim::test::remove_black() { openim::test::remove_black() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"ownerUserID": "${1}", "ownerUserID": "${1}",
"blackUserID": "${2}" "blackUserID": "${2}"
@ -515,7 +535,8 @@ EOF
# Retrieves the blacklist for a user. # Retrieves the blacklist for a user.
openim::test::get_black_list() { openim::test::get_black_list() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userID": "${1}", "userID": "${1}",
"pagination": { "pagination": {
@ -544,9 +565,13 @@ openim::test::update_pin_status() {
for friendUserID in "$@"; do for friendUserID in "$@"; do
friendUserIDsArray+=("\"${friendUserID}\"") friendUserIDsArray+=("\"${friendUserID}\"")
done done
local friendUserIDs=$(IFS=,; echo "${friendUserIDsArray[*]}") local friendUserIDs=$(
IFS=,
echo "${friendUserIDsArray[*]}"
)
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"ownerUserID": "${ownerUserID}", "ownerUserID": "${ownerUserID}",
"friendUserIDs": [${friendUserIDs}], "friendUserIDs": [${friendUserIDs}],
@ -561,7 +586,6 @@ EOF
openim::test::check_error "$response" openim::test::check_error "$response"
} }
# [openim::test::friend function description] # [openim::test::friend function description]
# The `openim::test::friend` function serves as a test suite for friend-related operations. # The `openim::test::friend` function serves as a test suite for friend-related operations.
# It sequentially invokes all friend-related test functions to ensure the API's friend operations are functioning correctly. # It sequentially invokes all friend-related test functions to ensure the API's friend operations are functioning correctly.
@ -631,12 +655,12 @@ function openim::test::friend() {
openim::log::success "Friend test suite completed successfully." openim::log::success "Friend test suite completed successfully."
} }
#################################### Group Module #################################### #################################### Group Module ####################################
# Creates a new group. # Creates a new group.
openim::test::create_group() { openim::test::create_group() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"memberUserIDs": [ "memberUserIDs": [
"${1}" "${1}"
@ -669,7 +693,8 @@ EOF
# Invites a user to join a group. # Invites a user to join a group.
openim::test::invite_user_to_group() { openim::test::invite_user_to_group() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupID": "${1}", "groupID": "${1}",
"invitedUserIDs": [ "invitedUserIDs": [
@ -689,7 +714,8 @@ EOF
# Transfers the ownership of a group to another user. # Transfers the ownership of a group to another user.
openim::test::transfer_group() { openim::test::transfer_group() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupID":"${1}", "groupID":"${1}",
"oldOwnerUserID":"${2}", "oldOwnerUserID":"${2}",
@ -706,7 +732,8 @@ EOF
# Retrieves information about multiple groups. # Retrieves information about multiple groups.
openim::test::get_groups_info() { openim::test::get_groups_info() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupIDs": ["${1}", "${2}"] "groupIDs": ["${1}", "${2}"]
} }
@ -721,7 +748,8 @@ EOF
# Removes a user from a group. # Removes a user from a group.
openim::test::kick_group() { openim::test::kick_group() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupID": "${1}", "groupID": "${1}",
"kickedUserIDs": [ "kickedUserIDs": [
@ -740,7 +768,8 @@ EOF
# Retrieves information about group members. # Retrieves information about group members.
openim::test::get_group_members_info() { openim::test::get_group_members_info() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupID": "${1}", "groupID": "${1}",
"userIDs": ["${2}"] "userIDs": ["${2}"]
@ -756,7 +785,8 @@ EOF
# Retrieves a list of group members. # Retrieves a list of group members.
openim::test::get_group_member_list() { openim::test::get_group_member_list() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupID": "${1}", "groupID": "${1}",
"pagination": { "pagination": {
@ -775,7 +805,8 @@ EOF
# Retrieves a list of groups that a user has joined. # Retrieves a list of groups that a user has joined.
openim::test::get_joined_group_list() { openim::test::get_joined_group_list() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"fromUserID": "${1}", "fromUserID": "${1}",
"pagination": { "pagination": {
@ -792,10 +823,10 @@ EOF
openim::test::check_error "$response" openim::test::check_error "$response"
} }
# Sets group member information. # Sets group member information.
openim::test::set_group_member_info() { openim::test::set_group_member_info() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"members": [ "members": [
{ {
@ -819,7 +850,8 @@ EOF
# Mutes a group. # Mutes a group.
openim::test::mute_group() { openim::test::mute_group() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupID": "${1}" "groupID": "${1}"
} }
@ -834,7 +866,8 @@ EOF
# Cancels the muting of a group. # Cancels the muting of a group.
openim::test::cancel_mute_group() { openim::test::cancel_mute_group() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupID": "${1}" "groupID": "${1}"
} }
@ -849,7 +882,8 @@ EOF
# Dismisses a group. # Dismisses a group.
openim::test::dismiss_group() { openim::test::dismiss_group() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupID":"${1}" "groupID":"${1}"
} }
@ -864,7 +898,8 @@ EOF
# Cancels muting a group member. # Cancels muting a group member.
openim::test::cancel_mute_group_member() { openim::test::cancel_mute_group_member() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupID": "${1}", "groupID": "${1}",
"userID": "${2}" "userID": "${2}"
@ -880,7 +915,8 @@ EOF
# Allows a user to join a group. # Allows a user to join a group.
openim::test::join_group() { openim::test::join_group() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupID": "${1}", "groupID": "${1}",
"reqMessage": "req msg join group", "reqMessage": "req msg join group",
@ -898,7 +934,8 @@ EOF
# Sets group information. # Sets group information.
openim::test::set_group_info() { openim::test::set_group_info() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupInfoForSet": { "groupInfoForSet": {
"groupID": "${1}", "groupID": "${1}",
@ -921,10 +958,10 @@ EOF
openim::test::check_error "$response" openim::test::check_error "$response"
} }
# Allows a user to quit a group. # Allows a user to quit a group.
openim::test::quit_group() { openim::test::quit_group() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupID": "${1}", "groupID": "${1}",
"userID": "${2}" "userID": "${2}"
@ -940,7 +977,8 @@ EOF
# Retrieves the list of group applications received by the user. # Retrieves the list of group applications received by the user.
openim::test::get_recv_group_applicationList() { openim::test::get_recv_group_applicationList() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"fromUserID": "${1}", "fromUserID": "${1}",
"pagination": { "pagination": {
@ -959,7 +997,8 @@ EOF
# Responds to a group application. # Responds to a group application.
openim::test::group_application_response() { openim::test::group_application_response() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupID": "${1}", "groupID": "${1}",
"fromUserID": "${2}", "fromUserID": "${2}",
@ -977,7 +1016,8 @@ EOF
# Retrieves the list of group applications made by the user. # Retrieves the list of group applications made by the user.
openim::test::get_user_req_group_applicationList() { openim::test::get_user_req_group_applicationList() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userID": "${1}", "userID": "${1}",
"pagination": { "pagination": {
@ -996,7 +1036,8 @@ EOF
# Mutes a group member for a specified duration. # Mutes a group member for a specified duration.
openim::test::mute_group_member() { openim::test::mute_group_member() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupID": "${1}", "groupID": "${1}",
"userID": "${2}", "userID": "${2}",
@ -1013,7 +1054,8 @@ EOF
# Retrieves a list of group applications from specific users. # Retrieves a list of group applications from specific users.
openim::test::get_group_users_req_application_list() { openim::test::get_group_users_req_application_list() {
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"groupID": "${1}", "groupID": "${1}",
"userIDs": [ "userIDs": [
@ -1121,11 +1163,13 @@ function openim::test::group() {
# Define a function to register a user # Define a function to register a user
openim::register_user() { openim::register_user() {
user_register_response=$(${CCURL} "${Header}" ${INSECURE_OPENIMAPI}/user/user_register \ user_register_response=$(
${CCURL} "${Header}" ${INSECURE_OPENIMAPI}/user/user_register \
-d'{ -d'{
"secret": "openIM123", "secret": "openIM123",
"users": [{"userID": "11111112","nickname": "yourNickname","faceURL": "yourFaceURL"}] "users": [{"userID": "11111112","nickname": "yourNickname","faceURL": "yourFaceURL"}]
}') }'
)
echo "$user_register_response" echo "$user_register_response"
} }
@ -1133,10 +1177,12 @@ openim::register_user() {
# Define a function to check the account # Define a function to check the account
openim::test::check_account() { openim::test::check_account() {
local token=$1 local token=$1
account_check_response=$(${CCURL} "${Header}" -H"operationID: 1646445464564" -H"token: ${token}" ${INSECURE_OPENIMAPI}/user/account_check \ account_check_response=$(
${CCURL} "${Header}" -H"operationID: 1646445464564" -H"token: ${token}" ${INSECURE_OPENIMAPI}/user/account_check \
-d'{ -d'{
"checkUserIDs": ["11111111","11111112"] "checkUserIDs": ["11111111","11111112"]
}') }'
)
echo "$account_check_response" echo "$account_check_response"
} }
@ -1179,7 +1225,8 @@ openim::test::send_msg() {
local recvID="${2}" local recvID="${2}"
local groupID="${3}" local groupID="${3}"
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"sendID": "${sendID}", "sendID": "${sendID}",
"recvID": "${recvID}", "recvID": "${recvID}",
@ -1223,7 +1270,8 @@ openim::test::search_msg() {
local showNumber="${7}" local showNumber="${7}"
# Construct the request body # Construct the request body
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"sendID": "${sendID}", "sendID": "${sendID}",
"recvID": "${recvID}", "recvID": "${recvID}",
@ -1256,7 +1304,8 @@ openim::test::pull_msg_by_seq() {
local order="${6}" # Assuming 0 for ascending, 1 for descending local order="${6}" # Assuming 0 for ascending, 1 for descending
# Construct the request body # Construct the request body
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userID": "${userID}", "userID": "${userID}",
"seqRanges": [ "seqRanges": [
@ -1286,7 +1335,8 @@ openim::test::revoke_msg() {
local conversationID="${2}" local conversationID="${2}"
local seq="${3}" local seq="${3}"
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userID": "${userID}", "userID": "${userID}",
"conversationID": "${conversationID}", "conversationID": "${conversationID}",
@ -1301,12 +1351,12 @@ EOF
openim::test::check_error "$response" openim::test::check_error "$response"
} }
# Clears all messages for a user. # Clears all messages for a user.
openim::test::user_clear_all_msg() { openim::test::user_clear_all_msg() {
local userID="${1}" local userID="${1}"
local request_body=$(cat <<EOF local request_body=$(
cat <<EOF
{ {
"userID": "${userID}" "userID": "${userID}"
} }
@ -1322,8 +1372,7 @@ EOF
# [openim::test::msg function description] # [openim::test::msg function description]
# The `openim::test::msg` function serves as a test suite for message-related operations. # The `openim::test::msg` function serves as a test suite for message-related operations.
# It sequentially invokes all message-related test functions to ensure the API's message operations are functioning correctly. # It sequentially invokes all message-related test functions to ensure the API's message operations are functioning correctly.
function openim::test::msg() function openim::test::msg() {
{
local SEND_USER_ID="${MANAGER_USERID_1}" # This should be the sender's userID local SEND_USER_ID="${MANAGER_USERID_1}" # This should be the sender's userID
local GROUP_ID="" # GroupID if it's a group message local GROUP_ID="" # GroupID if it's a group message
local USER_ID="$RANDOM" local USER_ID="$RANDOM"
@ -1352,7 +1401,6 @@ function openim::test::msg()
local ORDER=0 # Assuming 0 for ascending order local ORDER=0 # Assuming 0 for ascending order
openim::test::pull_msg_by_seq "${RECV_USER_ID}" "${CONVERSATION_ID}" "${BEGIN_SEQ}" "${END_SEQ}" "${NUM}" "${ORDER}" openim::test::pull_msg_by_seq "${RECV_USER_ID}" "${CONVERSATION_ID}" "${BEGIN_SEQ}" "${END_SEQ}" "${NUM}" "${ORDER}"
# Assuming message sending was successful and returned a sequence number. # Assuming message sending was successful and returned a sequence number.
local SEQ_NUMBER=1 # This should be the actual sequence number of the message sent. local SEQ_NUMBER=1 # This should be the actual sequence number of the message sent.
@ -1375,7 +1423,6 @@ openim::test::man() {
openim::log::info "TODO: openim test man" openim::log::info "TODO: openim test man"
} }
#################################### Build Module #################################### #################################### Build Module ####################################
# Function: openim::test::smoke # Function: openim::test::smoke

@ -1086,7 +1086,7 @@ function openim::util::ensure-install-nginx {
exit 1 exit 1
fi fi
for port in 80 for port in "80"
do do
if echo |telnet 127.0.0.1 $port 2>&1|grep refused &>/dev/null;then if echo |telnet 127.0.0.1 $port 2>&1|grep refused &>/dev/null;then
exit 1 exit 1
@ -2320,7 +2320,7 @@ function openim::util::ensure-install-nginx {
exit 1 exit 1
fi fi
for port in 80 for port in "80"
do do
if echo |telnet 127.0.0.1 $port 2>&1|grep refused &>/dev/null;then if echo |telnet 127.0.0.1 $port 2>&1|grep refused &>/dev/null;then
exit 1 exit 1
@ -2467,7 +2467,7 @@ function openim::util::desc() {
} }
function openim::util:run::prompt() { function openim::util:run::prompt() {
echo -n "$yellow\$ $reset" echo -n "${yellow}\$ ${reset}"
} }
started="" started=""
@ -2488,7 +2488,7 @@ function openim::util::run() {
if [ -n "$DEMO_RUN_FAST" ]; then if [ -n "$DEMO_RUN_FAST" ]; then
rate=1000 rate=1000
fi fi
echo "$green$1$reset" | pv -qL $rate echo "${green}$1${reset}" | pv -qL "$rate"
if [ -n "$DEMO_RUN_FAST" ]; then if [ -n "$DEMO_RUN_FAST" ]; then
sleep 0.5 sleep 0.5
fi fi

@ -126,7 +126,7 @@ APIROOT=$(ROOT_DIR)/pkg/proto
# Linux command settings # Linux command settings
# TODO: Whether you need to join utils? # TODO: Whether you need to join utils?
FIND := find . ! -path './utils/*' ! -path './vendor/*' ! -path './third_party/*' FIND := find . ! -path './utils/*' ! -path './vendor/*' ! -path './third_party/*' ! -path './components/*' ! -path './logs/*'
XARGS := xargs -r --no-run-if-empty XARGS := xargs -r --no-run-if-empty
# Linux command settings-CODE DIRS Copyright # Linux command settings-CODE DIRS Copyright

@ -244,7 +244,7 @@ go.imports: tools.verify.goimports
## go.verify: execute all verity scripts. ## go.verify: execute all verity scripts.
.PHONY: go.verify .PHONY: go.verify
go.verify: go.verify: tools.verify.misspell
@echo "Starting verification..." @echo "Starting verification..."
@scripts_list=$$(find $(ROOT_DIR)/scripts -type f -name 'verify-*' | sort); \ @scripts_list=$$(find $(ROOT_DIR)/scripts -type f -name 'verify-*' | sort); \
for script in $$scripts_list; do \ for script in $$scripts_list; do \

@ -217,6 +217,11 @@ install.depth:
install.go-callvis: install.go-callvis:
@$(GO) install github.com/ofabry/go-callvis@latest @$(GO) install github.com/ofabry/go-callvis@latest
## install.misspell
.PHONY: install.misspell
install.misspell:
@$(GO) install github.com/client9/misspell/cmd/misspell@latest
## install.gothanks: Install gothanks, used to thank go dependencies ## install.gothanks: Install gothanks, used to thank go dependencies
.PHONY: install.gothanks .PHONY: install.gothanks
install.gothanks: install.gothanks:

@ -43,6 +43,54 @@ disabled=(
1091 1091
# this lint prefers command -v to which, they are not the same # this lint prefers command -v to which, they are not the same
2230 2230
# Error SC2155 indicates that you should separate variable declaration and assignment to avoid masking the return value of the command.
# In Bash scripts, when you declare and assign a local variable at the same time a command is executed, you only get the output of the command, but not the exit status (return value) of the command. #
2155
# ShellCheck issues SC2086 warnings when you refer to a variable in a script but don't put it in double quotes.This can lead to unexpected behavior when scripts encounter Spaces,
# newlines, and wildcards in file names or other data.
2086
2206
# TODO: 需要修复,然后开启
2034
2048
2148
2059
2214
2145
2128
2550
2046
2181
1102
2045
2068
2145
2207
2231
2013
2154
2120
1083
2001
2012
2016
2164
2223
2166
2119
2162
2295
2002
2004
2202
2178
2064
2260
2043
2178
2044
2153
) )
# comma separate for passing to shellcheck # comma separate for passing to shellcheck
join_by() { join_by() {
@ -70,9 +118,13 @@ done < <(find . -name "*.sh" \
-not \( \ -not \( \
-path ./_\* -o \ -path ./_\* -o \
-path ./.git\* -o \ -path ./.git\* -o \
-path ./Godeps\* -o \
-path ./_output\* -o \
-path ./components\* -o \
-path ./logs\* -o \
-path ./vendor\* -o \ -path ./vendor\* -o \
\( -path ./third_party\* -a -not -path ./third_party/forked\* \) \ \( -path ./third_party\* -a -not -path ./third_party/forked\* \) \
\)) \) -print 2>/dev/null)
# detect if the host machine has the required shellcheck version installed # detect if the host machine has the required shellcheck version installed
# if so, we will use that instead. # if so, we will use that instead.
@ -113,7 +165,7 @@ if ${HAVE_SHELLCHECK}; then
else else
openim::log::info "Using shellcheck ${SHELLCHECK_VERSION} docker image." openim::log::info "Using shellcheck ${SHELLCHECK_VERSION} docker image."
"${DOCKER}" run \ "${DOCKER}" run \
--rm -v "${OPENIM_ROOT}:"${OPENIM_ROOT}"" -w "${OPENIM_ROOT}" \ --rm -v "${OPENIM_ROOT}:${OPENIM_ROOT}" -w "${OPENIM_ROOT}" \
"${SHELLCHECK_IMAGE}" \ "${SHELLCHECK_IMAGE}" \
shellcheck "${SHELLCHECK_OPTIONS[@]}" "${all_shell_scripts[@]}" >&2 || res=$? shellcheck "${SHELLCHECK_OPTIONS[@]}" "${all_shell_scripts[@]}" >&2 || res=$?
fi fi

@ -25,17 +25,8 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
export OPENIM_ROOT export OPENIM_ROOT
source "${OPENIM_ROOT}/scripts/lib/init.sh" source "${OPENIM_ROOT}/scripts/lib/init.sh"
# Ensure that we find the binaries we build before anything else.
export GOBIN="${KUBE_OUTPUT_BINPATH}"
PATH="${GOBIN}:${PATH}"
# Install tools we need
pushd "${OPENIM_ROOT}/tools" >/dev/null
GO111MODULE=on go install github.com/client9/misspell/cmd/misspell
popd >/dev/null
# Spell checking # Spell checking
# All the skipping files are defined in scripts/.spelling_failures # All the skipping files are defined in scripts/.spelling_failures
skipping_file="${OPENIM_ROOT}/scripts/.spelling_failures" skipping_file="${OPENIM_ROOT}/scripts/.spelling_failures"
failing_packages=$(sed "s| | -e |g" "${skipping_file}") failing_packages=$(sed "s| | -e |g" "${skipping_file}")
git ls-files | grep -v -e "${failing_packages}" | xargs misspell -i "Creater,creater,ect" -error -o stderr git ls-files | grep -v -e "${failing_packages}" | xargs "$OPENIM_ROOT/_output/tools/misspell" -i "Creater,creater,ect" -error -o stderr

@ -1,27 +1,52 @@
# OpenIM Typecheck # OpenIM Typecheck: Cross-Platform Source Code Type Checking for Go
OpenIM Typecheck 为所有 Go 构建平台进行跨平台源代码类型检查。 ## Introduction
## 优点 OpenIM Typecheck is a robust tool designed for cross-platform source code type checking across all Go build platforms. This utility leverages Gos built-in parsing and type-check libraries (`go/parser` and `go/types`) to deliver efficient and reliable code analysis.
- **速度**OpenIM 完整编译大约需要 3 分钟,而使用 Typecheck 只需数秒。 ## Advantages
- **资源消耗**:与需要 >40GB 的 RAM 不同Typecheck 只需 <8GB RAM
## 实现 - **Speed**: A complete compilation with OpenIM can take approximately 3 minutes. In contrast, OpenIM Typecheck achieves this in mere seconds, significantly enhancing productivity.
- **Resource Efficiency**: Unlike the typical requirement of over 40GB of RAM for standard processes, Typecheck operates effectively with less than 8GB of RAM. This reduction in resource consumption makes it highly suitable for a variety of systems, reducing overheads and facilitating smoother operations.
OpenIM Typecheck 使用 Go 内置的解析和类型检查库 (`go/parser` 和 `go/types`)。然而,这些库并不是 go 编译器所使用的。偶尔会出现不匹配的情况,但总的来说,它们是相当接近的。 ## Implementation
## 错误处理 OpenIM Typecheck employs Go's native parsing and type-checking libraries (`go/parser` and `go/types`). However, it's important to note that these libraries aren't identical to those used by the Go compiler. While occasional mismatches may occur, these libraries generally provide close approximations to the compiler's functionality, offering a reliable basis for type checking.
如果错误不会阻止构建,可以忽略。 ## Error Handling
**`go/types` 报告的错误,但 `go build` 不会** Typecheck's approach to error handling is pragmatic, focusing on practicality and build continuity.
- **真正的错误**(根据规范):
- 应尽量修复。如果无法修复或正在进行中(例如,已被外部引用的代码),则可以忽略。
- 例如:闭包中的未使用变量
- **不真实的错误**
- 应忽略并在适当的情况下向上游报告。
- 例如staging 和 generated 类型之间的类型检查不匹配
**`go build` 报告的错误,但我们不会** **Errors reported by `go/types` but not by `go build`**:
- CGo 错误,包括语法和链接器错误。 - **Actual Errors** (as per the specification):
- These should ideally be rectified. If rectification is not feasible, such as in cases of ongoing work or external dependencies in the code, these errors can be overlooked.
- Example: Unused variables within a closure.
- **False Positives**:
- These errors should be ignored and, where appropriate, reported upstream for resolution.
- Example: Type mismatches between staging and generated types.
**Errors reported by `go build` but not by us**:
- CGo-related errors, including both syntax and linker issues, are outside our scope.
## Usage
### Locally
To run Typecheck locally, simply use the following command:
```bash
make verify
```
### Continuous Integration (CI)
In CI environments, Typecheck can be integrated into the workflow as follows:
```yaml
- name: Typecheck
run: make verify
```
This streamlined process facilitates efficient error detection and resolution, ensuring a robust and reliable build pipeline.
More to learn about typecheck [share blog](https://nsddd.top/posts/concurrent-type-checking-and-cross-platform-development-in-go/)

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// do a fast type check of kubernetes code, for all platforms. // do a fast type check of openim code, for all platforms.
package main package main
import ( import (
@ -47,14 +47,12 @@ var (
crossPlatforms = []string{ crossPlatforms = []string{
"linux/amd64", "windows/386", "linux/amd64", "windows/386",
"darwin/amd64", "darwin/arm64", "darwin/amd64", "darwin/arm64",
"linux/386", "linux/386", "linux/arm",
"windows/amd64", "linux/arm64", "windows/amd64", "linux/arm64",
"linux/ppc64le", "linux/s390x", "linux/ppc64le", "linux/s390x",
"windows/arm64", "windows/arm64",
} }
// "linux/arm",
// directories we always ignore // directories we always ignore
standardIgnoreDirs = []string{ standardIgnoreDirs = []string{
// Staging code is symlinked from vendor/k8s.io, and uses import // Staging code is symlinked from vendor/k8s.io, and uses import
@ -62,17 +60,14 @@ var (
// inside of staging/, but works when typechecked as part of vendor/. // inside of staging/, but works when typechecked as part of vendor/.
"staging", "staging",
"components", "components",
"logs",
// OS-specific vendor code tends to be imported by OS-specific // OS-specific vendor code tends to be imported by OS-specific
// packages. We recursively typecheck imported vendored packages for // packages. We recursively typecheck imported vendored packages for
// each OS, but don't typecheck everything for every OS. // each OS, but don't typecheck everything for every OS.
"vendor", "vendor",
"test",
"_output", "_output",
"OpenIMSKD/tools", "*/mw/rpc_server_interceptor.go",
// This is a weird one. /testdata/ is *mostly* ignored by Go,
// and this translates to kubernetes/vendor not working.
// edit/record.go doesn't compile without gopkg.in/yaml.v2
// in $GOSRC/$GOROOT (both typecheck and the shell script).
"pkg/kubectl/cmd/testdata/edit",
// Tools we use for maintaining the code base but not necessarily // Tools we use for maintaining the code base but not necessarily
// ship as part of the release // ship as part of the release
"sopenim::golang::setup_env:tools/yamlfmt/yamlfmt.go:tools", "sopenim::golang::setup_env:tools/yamlfmt/yamlfmt.go:tools",

@ -34,7 +34,7 @@ openim_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
wrkdir="${openim_root}/_output/wrk" wrkdir="${openim_root}/_output/wrk"
jobname="openim-api" jobname="openim-api"
duration="300s" duration="300s"
threads=$((3 * `grep -c processor /proc/cpuinfo`)) threads=$((3 * $(grep -c processor /proc/cpuinfo)))
source "${openim_root}/scripts/lib/color.sh" source "${openim_root}/scripts/lib/color.sh"
@ -122,7 +122,7 @@ if (s ~ "s") {
# Remove existing data file # Remove existing data file
function openim::wrk::prepare() { function openim::wrk::prepare() {
rm -f ${wrkdir}/${datfile} rm -f "${wrkdir}"/"${datfile}"
} }
# Plot according to gunplot data file # Plot according to gunplot data file
@ -216,7 +216,7 @@ openim::wrk::start_performance_test() {
do do
wrkcmd="${cmd} -c ${c} $1" wrkcmd="${cmd} -c ${c} $1"
echo "Running wrk command: ${wrkcmd}" echo "Running wrk command: ${wrkcmd}"
result=`eval ${wrkcmd}` result=$(eval "${wrkcmd}")
openim::wrk::convert_plot_data "${result}" openim::wrk::convert_plot_data "${result}"
done done
@ -241,9 +241,10 @@ while getopts "hd:n:" opt;do
esac esac
done done
shift $(($OPTIND-1)) shift $((OPTIND-1))
mkdir -p "${wrkdir}"
mkdir -p ${wrkdir}
case $1 in case $1 in
"diff") "diff")
if [ "$#" -lt 3 ];then if [ "$#" -lt 3 ];then
@ -255,7 +256,7 @@ case $1 in
t2=$(basename $3|sed 's/.dat//g') # 对比图中粉色线条名称 t2=$(basename $3|sed 's/.dat//g') # 对比图中粉色线条名称
join $2 $3 > /tmp/plot_diff.dat join $2 $3 > /tmp/plot_diff.dat
openim::wrk::plot_diff `basename $2` `basename $3` openim::wrk::plot_diff "$(basename "$2")" "$(basename "$3")"
exit 0 exit 0
;; ;;
*) *)

@ -31,7 +31,7 @@ var (
usernameV3 = "root" usernameV3 = "root"
passwordV3 = "openIM123" passwordV3 = "openIM123"
addrV3 = "127.0.0.1:13306" addrV3 = "127.0.0.1:13306"
databaseV3 = "openIM_v3" databaseV3 = "openim_v3"
) )
``` ```

@ -38,7 +38,7 @@ func main() {
usernameV3 = "root" // v3版本mysql用户名 usernameV3 = "root" // v3版本mysql用户名
passwordV3 = "openIM123" // v3版本mysql密码 passwordV3 = "openIM123" // v3版本mysql密码
addrV3 = "127.0.0.1:13306" // v3版本mysql地址 addrV3 = "127.0.0.1:13306" // v3版本mysql地址
databaseV3 = "openIM_v3" // v3版本mysql数据库名字 databaseV3 = "openim_v3" // v3版本mysql数据库名字
) )
var concurrency = 1 // 并发数量 var concurrency = 1 // 并发数量

@ -44,7 +44,7 @@ const (
UsernameV3 = "root" UsernameV3 = "root"
PasswordV3 = "openIM123" PasswordV3 = "openIM123"
IpV3 = "43.134.63.160:13306" IpV3 = "43.134.63.160:13306"
DatabaseV3 = "openIM_v3" DatabaseV3 = "openim_v3"
) )
// V3 chat. // V3 chat.

@ -38,7 +38,7 @@ func Cmd() {
usernameV3 = "root" usernameV3 = "root"
passwordV3 = "openIM123" passwordV3 = "openIM123"
addrV3 = "203.56.175.233:13306" addrV3 = "203.56.175.233:13306"
databaseV3 = "openIM_v3" databaseV3 = "openim_v3"
) )
log.SetFlags(log.LstdFlags | log.Llongfile) log.SetFlags(log.LstdFlags | log.Llongfile)
dsnV2 := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=True&loc=Local", usernameV2, passwordV2, addrV2, databaseV2) dsnV2 := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=True&loc=Local", usernameV2, passwordV2, addrV2, databaseV2)

@ -1,3 +1,17 @@
// Copyright © 2024 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 checker package checker
import ( import (

@ -1,3 +1,17 @@
// Copyright © 2024 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 config package config
import ( import (

@ -1,3 +1,17 @@
// Copyright © 2024 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 main package main
import ( import (

@ -36,20 +36,6 @@ config/config.yaml
.env .env
./.env ./.env
### OpenIM deploy ###
deploy/openim_demo
deploy/openim-api
deploy/openim-rpc-msg_gateway
deploy/openim-msgtransfer
deploy/openim-push
deploy/openim_timer_task
deploy/openim-rpc-user
deploy/openim-rpc-friend
deploy/openim-rpc-group
deploy/openim-rpc-msg
deploy/openim-rpc-auth
deploy/Open-IM-SDK-Core
# files used by the developer # files used by the developer
.idea.md .idea.md
.todo.md .todo.md

@ -1,3 +1,17 @@
// Copyright © 2024 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 main package main
import "fmt" import "fmt"

Loading…
Cancel
Save