Compare commits
29 Commits
v3.5.1-rc.
...
cubxxw-pat
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a8198573b | ||
|
|
8729f90d02 | ||
|
|
854f8dbd2f | ||
|
|
af878a96cf | ||
|
|
f551b50e79 | ||
|
|
bb862bd207 | ||
|
|
c55e03dc70 | ||
|
|
55ca661d13 | ||
|
|
551781a0ee | ||
|
|
4c0121849d | ||
|
|
42a3084a6f | ||
|
|
c205013436 | ||
|
|
18047859b8 | ||
|
|
4ded2cffed | ||
|
|
0a245df2f8 | ||
|
|
bd9e50d9e0 | ||
|
|
32cd79044b | ||
|
|
f94d8af737 | ||
|
|
34551a82a2 | ||
|
|
b14c0475d2 | ||
|
|
1d5732c97e | ||
|
|
7ef32bf8a0 | ||
|
|
19ffde3196 | ||
|
|
e79532aa93 | ||
|
|
c86df88b59 | ||
|
|
e2650add40 | ||
|
|
05e66e9f8d | ||
|
|
9527278239 | ||
|
|
d356f7a035 |
@@ -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",
|
||||||
|
|||||||
1
.github/workflows/help-comment-issue.yml
vendored
1
.github/workflows/help-comment-issue.yml
vendored
@@ -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'
|
||||||
|
|||||||
15
.github/workflows/openimci.yml
vendored
15
.github/workflows/openimci.yml
vendored
@@ -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)"
|
||||||
|
|||||||
55
.github/workflows/pull-request.yml
vendored
55
.github/workflows/pull-request.yml
vendored
@@ -14,12 +14,6 @@
|
|||||||
|
|
||||||
name: Github Pull Request
|
name: Github Pull Request
|
||||||
on:
|
on:
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
paths-ignore:
|
|
||||||
- 'README.md'
|
|
||||||
- 'CONTRIBUTING.md'
|
|
||||||
- 'docs/**'
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 2 * * *'
|
- cron: '0 2 * * *'
|
||||||
@@ -37,24 +31,18 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Get League branch Patch
|
|
||||||
run: |
|
|
||||||
git config user.name 'openimbot'
|
|
||||||
git config user.email 'openimsdk@qq.com'
|
|
||||||
BRANCH_NAME="auto-pr-$(date +'%Y%m%d%H%M%S')"
|
|
||||||
git checkout -b $BRANCH_NAME
|
|
||||||
|
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
- name: Run go modules tidy
|
- name: Run go modules tidy
|
||||||
run: |
|
run: |
|
||||||
|
sudo apt-get install jq
|
||||||
sudo make tidy
|
sudo make tidy
|
||||||
sudo make tools.verify.go-gitlint
|
sudo make tools.verify.go-gitlint
|
||||||
echo "Run go modules tidy successfully"
|
echo "Run go modules tidy successfully"
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
- name: Run go format
|
- name: Run go format and lint
|
||||||
run: |
|
run: |
|
||||||
sudo make format
|
sudo make format
|
||||||
echo "Run go format successfully"
|
echo "Run go format successfully"
|
||||||
@@ -72,18 +60,28 @@ jobs:
|
|||||||
echo "Generate all necessary files successfully"
|
echo "Generate all necessary files successfully"
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: make init
|
||||||
|
run: |
|
||||||
|
export OPENIM_IP=127.0.0.1
|
||||||
|
export LOG_STORAGE_LOCATION="../logs/"
|
||||||
|
./scripts/init-config.sh --examples --force
|
||||||
|
echo "Generate all necessary files successfully"
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Generate Vertions
|
||||||
|
run: |
|
||||||
|
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1` | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
|
||||||
|
echo $latest_tag > pkg/common/config/version
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
- name: Run unit test and get test coverage
|
- name: Run unit test and get test coverage
|
||||||
run: |
|
run: |
|
||||||
make cover
|
make cover
|
||||||
echo "Run unit test and get test coverage successfully"
|
echo "Run unit test and get test coverage successfully"
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
|
||||||
uses: github/codeql-action/analyze@v2
|
|
||||||
|
|
||||||
- name: OpenIM verify copyright
|
- name: OpenIM verify copyright
|
||||||
run: |
|
run: |
|
||||||
sudo make verify-copyright
|
|
||||||
sudo make add-copyright
|
sudo make add-copyright
|
||||||
echo "OpenIM verify successfully"
|
echo "OpenIM verify successfully"
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
@@ -93,22 +91,27 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
token: ${{ secrets.BOT_GITHUB_TOKEN }}
|
token: ${{ secrets.BOT_GITHUB_TOKEN }}
|
||||||
commit-message: "cicd: bump League Patch"
|
commit-message: "cicd: bump League Patch"
|
||||||
author: kubbot <kubbot@3293172751ysy@gmail.com>
|
author: kubbot <3293172751ysy@gmail.com>
|
||||||
signoff: false
|
committer: kubbot <3293172751ysy@gmail.com>
|
||||||
draft: false
|
# signoff: false
|
||||||
branch: ''
|
# draft: false
|
||||||
|
branch: "asf-auto-updates"
|
||||||
assignees: cubxxw
|
assignees: cubxxw
|
||||||
reviewers: cubxxw
|
reviewers: cubxxw
|
||||||
delete-branch: true
|
title: "[Auto PR 🤖] Bump League Patch auto PR"
|
||||||
title: "Bump League Patch auto PR: $(date +'%Y%m%d')"
|
|
||||||
body: |
|
body: |
|
||||||
|
I am a PR generated by robot automation.
|
||||||
|
|
||||||
Review criteria:
|
Review criteria:
|
||||||
|
|
||||||
- [ ] Disenchanter can connect and issue actions
|
- [ ] Disenchanter can connect and issue actions
|
||||||
|
|
||||||
This is an automated PR. @ $(date +'%Y%m%d')
|
Github Actions Status:
|
||||||
|
|
||||||
|
[](https://github.com/openimsdk/open-im-server/actions/workflows/pull-request.yml)
|
||||||
|
|
||||||
|
This is an automated PR.
|
||||||
<sub>[workflow](https://github.com/openimsdk/open-im-server/blob/main/.github/workflows/pull-request.yml).</sub>
|
<sub>[workflow](https://github.com/openimsdk/open-im-server/blob/main/.github/workflows/pull-request.yml).</sub>
|
||||||
base: main
|
|
||||||
labels: |
|
labels: |
|
||||||
kind/documentation
|
kind/documentation
|
||||||
enhancement
|
enhancement
|
||||||
|
|||||||
3
.github/workflows/sync-release.yml
vendored
3
.github/workflows/sync-release.yml
vendored
@@ -3,7 +3,7 @@
|
|||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
|
||||||
# https://github.com/BetaHuhn/repo-file-sync-action
|
# https://github.com/BetaHuhn/repo-file-sync-action
|
||||||
name: Synchronize kubecub public code to other repositories
|
name: Synchronize OpenIM Release Branch Public Code To Other Repositories
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
paths:
|
paths:
|
||||||
@@ -41,3 +41,4 @@ jobs:
|
|||||||
automerge
|
automerge
|
||||||
ASSIGNEES: |
|
ASSIGNEES: |
|
||||||
kubbot
|
kubbot
|
||||||
|
continue-on-error: true
|
||||||
3
.github/workflows/sync.yml
vendored
3
.github/workflows/sync.yml
vendored
@@ -3,7 +3,7 @@
|
|||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
|
||||||
# https://github.com/BetaHuhn/repo-file-sync-action
|
# https://github.com/BetaHuhn/repo-file-sync-action
|
||||||
name: Synchronize kubecub public code to other repositories
|
name: Synchronize OpenIM Main Branch Public Code To Other Repositories
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
@@ -37,3 +37,4 @@ jobs:
|
|||||||
automerge
|
automerge
|
||||||
ASSIGNEES: |
|
ASSIGNEES: |
|
||||||
kubbot
|
kubbot
|
||||||
|
continue-on-error: true
|
||||||
1
.gitignore
vendored
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
|
|
||||||
33
CONTRIBUTING-zh_CN.md
Normal file
33
CONTRIBUTING-zh_CN.md
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# How do I contribute code to OpenIM
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="./CONTRIBUTING.md">Englist</a> ·
|
||||||
|
<a href="./CONTRIBUTING-zh_CN.md">中文</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-UA.md">Українська</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-CS.md">Česky</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-HU.md">Magyar</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-ES.md">Español</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-FA.md">فارسی</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-FR.md">Français</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-DE.md">Deutsch</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-PL.md">Polski</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-ID.md">Indonesian</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-FI.md">Suomi</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-ML.md">മലയാളം</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-JP.md">日本語</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-NL.md">Nederlands</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-IT.md">Italiano</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-RU.md">Русский</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-PTBR.md">Português (Brasil)</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-EO.md">Esperanto</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-KR.md">한국어</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-AR.md">العربي</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-VN.md">Tiếng Việt</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-DA.md">Dansk</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-GR.md">Ελληνικά</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-TR.md">Türkçe</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</p>
|
||||||
209
CONTRIBUTING.md
209
CONTRIBUTING.md
@@ -1,6 +1,38 @@
|
|||||||
# Contributing to Open-IM-Server
|
# How do I contribute code to OpenIM
|
||||||
|
|
||||||
So, you want to hack on Open-IM-Server? Yay!
|
<p align="center">
|
||||||
|
<a href="./CONTRIBUTING.md">Englist</a> ·
|
||||||
|
<a href="./CONTRIBUTING-zh_CN.md">中文</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-UA.md">Українська</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-CS.md">Česky</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-HU.md">Magyar</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-ES.md">Español</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-FA.md">فارسی</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-FR.md">Français</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-DE.md">Deutsch</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-PL.md">Polski</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-ID.md">Indonesian</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-FI.md">Suomi</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-ML.md">മലയാളം</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-JP.md">日本語</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-NL.md">Nederlands</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-IT.md">Italiano</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-RU.md">Русский</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-PTBR.md">Português (Brasil)</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-EO.md">Esperanto</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-KR.md">한국어</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-AR.md">العربي</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-VN.md">Tiếng Việt</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-DA.md">Dansk</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-GR.md">Ελληνικά</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-TR.md">Türkçe</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
So, you want to hack on open-im-server? Yay!
|
||||||
|
|
||||||
First of all, thank you for considering contributing to our project! We appreciate your time and effort, and we value any contribution, whether it's reporting a bug, suggesting a new feature, or submitting a pull request.
|
First of all, thank you for considering contributing to our project! We appreciate your time and effort, and we value any contribution, whether it's reporting a bug, suggesting a new feature, or submitting a pull request.
|
||||||
|
|
||||||
@@ -12,7 +44,7 @@ This document provides guidelines and best practices to help you contribute effe
|
|||||||
|
|
||||||
## 📇Topics
|
## 📇Topics
|
||||||
|
|
||||||
- [Contributing to Open-IM-Server](#contributing-to-open-im-server)
|
- [How do I contribute code to OpenIM](#how-do-i-contribute-code-to-openim)
|
||||||
- [📇Topics](#topics)
|
- [📇Topics](#topics)
|
||||||
- [What we expect of you](#what-we-expect-of-you)
|
- [What we expect of you](#what-we-expect-of-you)
|
||||||
- [Code of ConductCode of Conduct](#code-of-conductcode-of-conduct)
|
- [Code of ConductCode of Conduct](#code-of-conductcode-of-conduct)
|
||||||
@@ -32,13 +64,13 @@ This document provides guidelines and best practices to help you contribute effe
|
|||||||
|
|
||||||
## What we expect of you
|
## What we expect of you
|
||||||
|
|
||||||
We hope that anyone can join Open-IM-Server , even if you are a student, writer, translator
|
We hope that anyone can join open-im-server , even if you are a student, writer, translator
|
||||||
|
|
||||||
Please meet the minimum version of the Go language published in [go.mod](./go.mod). If you want to manage the Go language version, we provide tools to install [gvm](https://github.com/moovweb/gvm) in our [Makefile](./Makefile)
|
Please meet the minimum version of the Go language published in [go.mod](./go.mod). If you want to manage the Go language version, we provide tools tHow do I contribute code to OpenIMo install [gvm](https://github.com/moovweb/gvm) in our [Makefile](./Makefile)
|
||||||
|
|
||||||
You'd better use Linux OR WSL as the development environment, Linux with [Makefile](./Makefile) can help you quickly build and test Open-IM-Server project.
|
You'd better use Linux OR WSL as the development environment, Linux with [Makefile](./Makefile) can help you quickly build and test open-im-server project.
|
||||||
|
|
||||||
If you are familiar with [Makefile](./Makefile) , you can easily see the clever design of the Open-IM-Server Makefile. Storing the necessary tools such as golangci in the `/tools` directory can avoid some tool version issues.
|
If you are familiar with [Makefile](./Makefile) , you can easily see the clever design of the open-im-server Makefile. Storing the necessary tools such as golangci in the `/tools` directory can avoid some tool version issues.
|
||||||
|
|
||||||
The [Makefile](./Makefile) is for every developer, even if you don't know how to use the Makefile tool, don't worry, we provide two great commands to get you up to speed with the Makefile architecture, `make help` and `make help-all`, it can reduce problems of the developing environment.
|
The [Makefile](./Makefile) is for every developer, even if you don't know how to use the Makefile tool, don't worry, we provide two great commands to get you up to speed with the Makefile architecture, `make help` and `make help-all`, it can reduce problems of the developing environment.
|
||||||
|
|
||||||
@@ -52,7 +84,7 @@ In accordance with the naming conventions adopted by OpenIM and drawing referenc
|
|||||||
|
|
||||||
#### Code and doc contribution
|
#### Code and doc contribution
|
||||||
|
|
||||||
Every action to make project Open-IM-Server better is encouraged. On GitHub, every improvement for Open-IM-Server could be via a [PR](https://github.com/openimsdk/open-im-server/pulls) (short for pull request).
|
Every action to make project open-im-server better is encouraged. On GitHub, every improvement for open-im-server could be via a [PR](https://github.com/openimsdk/open-im-server/pulls) (short for pull request).
|
||||||
|
|
||||||
+ If you find a typo, try to fix it!
|
+ If you find a typo, try to fix it!
|
||||||
+ If you find a bug, try to fix it!
|
+ If you find a bug, try to fix it!
|
||||||
@@ -67,8 +99,8 @@ Every action to make project Open-IM-Server better is encouraged. On GitHub, eve
|
|||||||
|
|
||||||
#### Where should I start?
|
#### Where should I start?
|
||||||
|
|
||||||
+ If you are new to the project, don't know how to contribute Open-IM-Server, please check out the [good first issue](https://github.com/openimsdk/open-im-server/issues?q=is%3Aopen+label%3A"good+first+issue"+sort%3Aupdated-desc) label.
|
+ If you are new to the project, don't know how to contribute open-im-server, please check out the [good first issue](https://github.com/openimsdk/open-im-server/issues?q=is%3Aopen+label%3A"good+first+issue"+sort%3Aupdated-desc) label.
|
||||||
+ You should be good at filtering the Open-IM-Server issue tags and finding the ones you like, such as [RFC](https://github.com/openimsdk/open-im-server/issues?q=is%3Aissue+is%3Aopen+RFC+label%3ARFC) for big initiatives, features for [feature](https://github.com/openimsdk/open-im-server/issues?q=is%3Aissue+label%3Afeature) proposals, and [bug](https://github.com/openimsdk/open-im-server/issues?q=is%3Aissue+label%3Abug+) fixes.
|
+ You should be good at filtering the open-im-server issue tags and finding the ones you like, such as [RFC](https://github.com/openimsdk/open-im-server/issues?q=is%3Aissue+is%3Aopen+RFC+label%3ARFC) for big initiatives, features for [feature](https://github.com/openimsdk/open-im-server/issues?q=is%3Aissue+label%3Afeature) proposals, and [bug](https://github.com/openimsdk/open-im-server/issues?q=is%3Aissue+label%3Abug+) fixes.
|
||||||
+ If you are looking for something to work on, check out our [open issues](https://github.com/openimsdk/open-im-server/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc).
|
+ If you are looking for something to work on, check out our [open issues](https://github.com/openimsdk/open-im-server/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc).
|
||||||
+ If you have an idea for a new feature, please [open an issue](https://github.com/openimsdk/open-im-server/issues/new/choose), and we can discuss it.
|
+ If you have an idea for a new feature, please [open an issue](https://github.com/openimsdk/open-im-server/issues/new/choose), and we can discuss it.
|
||||||
|
|
||||||
@@ -85,7 +117,7 @@ When documenting a new design, we recommend a 2-step approach:
|
|||||||
1. Use the short-form RFC template to outline your ideas and get early feedback.
|
1. Use the short-form RFC template to outline your ideas and get early feedback.
|
||||||
2. Once you have received sufficient feedback and consensus, you may use the longer-form design doc template to specify and discuss your design in more details.
|
2. Once you have received sufficient feedback and consensus, you may use the longer-form design doc template to specify and discuss your design in more details.
|
||||||
|
|
||||||
In order to contribute a feature to Open-IM-Server you'll need to go through the following steps:
|
In order to contribute a feature to open-im-server you'll need to go through the following steps:
|
||||||
|
|
||||||
+ Discuss your idea with the appropriate [working groups](https://join.slack.com/t/openimsdk/shared_invite/zt-22720d66b-o_FvKxMTGXtcnnnHiMqe9Q) on the working group's Slack channel.
|
+ Discuss your idea with the appropriate [working groups](https://join.slack.com/t/openimsdk/shared_invite/zt-22720d66b-o_FvKxMTGXtcnnnHiMqe9Q) on the working group's Slack channel.
|
||||||
+ Once there is general agreement that the feature is useful, create a GitHub issue to track the discussion. The issue should include information about the requirements and use cases that it is trying to address.
|
+ Once there is general agreement that the feature is useful, create a GitHub issue to track the discussion. The issue should include information about the requirements and use cases that it is trying to address.
|
||||||
@@ -95,13 +127,27 @@ But keep in mind that there is no guarantee of it being accepted and so it is us
|
|||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
To propose PR for the Open-IM-Server item, we assume you have registered a GitHub ID. Then you could finish the preparation in the following steps:
|
To propose PR for the open-im-server item, we assume you have registered a GitHub ID. Then you could finish the preparation in the following steps:
|
||||||
|
|
||||||
1. Fork the repository(Open-IM-Server)
|
1. Fork the repository(open-im-server)
|
||||||
|
|
||||||
2. **CLONE** your own repository to main locally. Use `git clone https://github.com/<your-username>/Open-IM-Server.git` to clone repository to your local machine. Then you can create new branches to finish the change you wish to make.
|
2. **CLONE** your own repository to main locally. Use `git clone https://github.com/<your-username>/open-im-server.git` to clone repository to your local machine. Then you can create new branches to finish the change you wish to make.
|
||||||
|
|
||||||
3. **Set Remote** upstream to be `https://github.com/openimsdk/open-im-server.git` using the following two commands:
|
3. **Initialize Git Hooks with `make init-githooks`**
|
||||||
|
|
||||||
|
After cloning the repository, it's recommended to set up Git hooks to streamline your workflow and ensure your contributions adhere to OpenIM's community standards. Git hooks are scripts that run automatically every time a particular event occurs in a Git repository, such as before a commit or push. To initialize Git hooks for the OpenIM server repository, use the `make init-githooks` command.
|
||||||
|
|
||||||
|
- **Enabling Git Hooks Mode**: By running `make init-githooks` and entering `1` when prompted, you enable Git hooks mode. This action will generate a series of hooks within the `.git/hooks/` directory. These hooks impose certain checks on your commits and pushes, ensuring they meet the quality and standards expected by the OpenIM community. For instance, commit hooks might enforce a specific commit message format, while push hooks could check for code style or linting issues.
|
||||||
|
|
||||||
|
- **Benefits for First-Time Contributors**: This setup is especially beneficial for new contributors. It guides you to make professional, community-standard-compliant Pull Requests (PRs) and PR descriptions right from your first contribution. By automating checks and balances, it reduces the chances of common mistakes and speeds up the review process.
|
||||||
|
|
||||||
|
- **Disabling Git Hooks**: If for any reason you wish to remove the Git hooks, simply run `make init-githooks` again and enter `2` when prompted. This will delete the existing Git hooks, removing the automatic checks and constraints from your Git operations. However, keep in mind that manually ensuring your contributions adhere to community standards without the aid of Git hooks requires diligence.
|
||||||
|
|
||||||
|
> [!NOTE] Utilizing Git hooks through the `make init-githooks` command is a straightforward yet powerful way to ensure your contributions are consistent and high-quality. It's a step towards fostering a professional and efficient development environment in the OpenIM project.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
4. **Set Remote** upstream to be `https://github.com/openimsdk/open-im-server.git` using the following two commands:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
❯ git remote add upstream https://github.com/openimsdk/open-im-server.git
|
❯ git remote add upstream https://github.com/openimsdk/open-im-server.git
|
||||||
@@ -112,18 +158,18 @@ To propose PR for the Open-IM-Server item, we assume you have registered a GitHu
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
❯ git remote -v
|
❯ git remote -v
|
||||||
origin https://github.com/<your-username>/Open-IM-Server.git (fetch)
|
origin https://github.com/<your-username>/open-im-server.git (fetch)
|
||||||
origin https://github.com/<your-username>/Open-IM-Server.git (push)
|
origin https://github.com/<your-username>/open-im-server.git (push)
|
||||||
upstream https://github.com/openimsdk/open-im-server.git (fetch)
|
upstream https://github.com/openimsdk/open-im-server.git (fetch)
|
||||||
upstream no-pushing (push)
|
upstream no-pushing (push)
|
||||||
```
|
```
|
||||||
|
|
||||||
Adding this, we can easily synchronize local branches with upstream branches.
|
Adding this, we can easily synchronize local branches with upstream branches.
|
||||||
|
|
||||||
4. Create a new branch for your changes (use a descriptive name, such as `fix-bug-123` or `add-new-feature`).
|
5. Create a new branch for your changes (use a descriptive name, such as `fix-bug-123` or `add-new-feature`).
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
❯ cd Open-IM-Server
|
❯ cd open-im-server
|
||||||
❯ git fetch upstream
|
❯ git fetch upstream
|
||||||
❯ git checkout upstream/main
|
❯ git checkout upstream/main
|
||||||
```
|
```
|
||||||
@@ -136,7 +182,8 @@ To propose PR for the Open-IM-Server item, we assume you have registered a GitHu
|
|||||||
|
|
||||||
Make any change on the `new-branch` then use [Makefile](./Makefile) build and test your codes.
|
Make any change on the `new-branch` then use [Makefile](./Makefile) build and test your codes.
|
||||||
|
|
||||||
5. **Commit your changes** to your local branch, lint before committing and commit with sign-off
|
|
||||||
|
6. **Commit your changes** to your local branch, lint before committing and commit with sign-off
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
❯ git rebase upstream/main
|
❯ git rebase upstream/main
|
||||||
@@ -145,7 +192,7 @@ To propose PR for the Open-IM-Server item, we assume you have registered a GitHu
|
|||||||
❯ git commit -a -s -m "message for your changes" # -s adds a Signed-off-by trailer
|
❯ git commit -a -s -m "message for your changes" # -s adds a Signed-off-by trailer
|
||||||
```
|
```
|
||||||
|
|
||||||
6. **Push your branch** to your forked repository, it is recommended to have only one commit for a PR.
|
7. **Push your branch** to your forked repository, it is recommended to have only one commit for a PR.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# sync up with upstream
|
# sync up with upstream
|
||||||
@@ -177,28 +224,94 @@ To propose PR for the Open-IM-Server item, we assume you have registered a GitHu
|
|||||||
❯ git rebase upstream/main # rebase the current branch to upstream/main branch
|
❯ git rebase upstream/main # rebase the current branch to upstream/main branch
|
||||||
❯ git add -A
|
❯ git add -A
|
||||||
❯ git commit -m -s "feat: feature two"
|
❯ git commit -m -s "feat: feature two"
|
||||||
# then create pull request, and merge
|
|
||||||
```
|
```
|
||||||
|
|
||||||
7. **Open a pull request** to `openimsdk/open-im-server:main`
|
**Verifying Your Pull Request with `make all` Command**
|
||||||
|
|
||||||
|
Before verifying, you may need to complete the basic deployment of OpenIM to get familiar with the deployment status of OpenIM. Please read [this deployment document](https://docs.openim.io/zh-Hans/guides/gettingStarted/imSourceCodeDeployment), which will tell you how to deploy OpenIM middleware and OpenIM services in detail
|
||||||
|
|
||||||
|
Before submitting your Pull Request (PR), it's crucial to ensure that it passes all the necessary checks and verifications to maintain the quality and integrity of the OpenIM server project. To facilitate this process, we have encapsulated a series of validation steps into the `make all` command.
|
||||||
|
|
||||||
|
- **Purpose of `make all` Command**: The `make all` command serves as a comprehensive pre-PR verification tool. It sequentially executes a variety of tasks designed to scrutinize your changes from multiple angles, ensuring they are ready for submission.
|
||||||
|
|
||||||
|
- **Included Commands**:
|
||||||
|
- `tidy`: Cleans up the module by removing unused dependencies.
|
||||||
|
- `gen`: Generates necessary files from templates or specifications, ensuring that your codebase is up-to-date with its dependencies.
|
||||||
|
- `add-copyright`: Checks for and adds copyright notices to files, ensuring compliance with legal requirements.
|
||||||
|
- `verify`: Verifies the integrity and consistency of the code, dependencies, and various checks.
|
||||||
|
- `test-api`: Runs API tests to ensure that your changes do not break any existing functionality and adhere to the expected behaviors.
|
||||||
|
- `lint`: Analyzes the code for potential stylistic or programming errors, enforcing the project's coding standards.
|
||||||
|
- `cover`: Measures the code coverage of tests, helping you understand how much of the code is being tested.
|
||||||
|
- `restart`: (Optionally) restarts services or applications to ensure that changes are correctly applied and functioning in a live environment.
|
||||||
|
|
||||||
|
- **Executing the Command**: To run the `make all` command, simply navigate to the root directory of your cloned repository in your terminal and execute:
|
||||||
|
```bash
|
||||||
|
make all
|
||||||
|
```
|
||||||
|
This command will sequentially perform all the listed actions, outputting any warnings or errors encountered during the process. It's a vital step to catch any issues early and ensure your contribution meets the quality standards set by the OpenIM community.
|
||||||
|
|
||||||
|
- **Benefits**: By using `make all` for pre-PR verification, you significantly increase the likelihood of your PR being accepted on the first review. It not only demonstrates your commitment to quality but also streamlines the review process by minimizing back-and-forth due to common issues that can be caught automatically.
|
||||||
|
|
||||||
|
|
||||||
|
**Troubleshooting Git Push Failures**
|
||||||
|
|
||||||
|
When working with Git, encountering errors during push operations is not uncommon. Two primary reasons you might face push failures are due to firewall restrictions or authentication issues. Here’s how you can troubleshoot and resolve these problems.
|
||||||
|
|
||||||
|
**Firewall Errors**
|
||||||
|
|
||||||
|
If you're behind a corporate firewall or your network restricts certain types of traffic, you might encounter issues when trying to push your changes via HTTPS. This is because firewalls can block the ports used by the HTTPS protocol. To resolve this issue, you can configure Git to use a proxy.
|
||||||
|
|
||||||
|
If you have a local proxy server set up, you can direct Git to use it by setting the `https_proxy` and `http_proxy` environment variables. Open your terminal or command prompt and run the following commands:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export https_proxy="http://127.0.0.1:7890"
|
||||||
|
export http_proxy="http://127.0.0.1:7890"
|
||||||
|
```
|
||||||
|
|
||||||
|
Replace `127.0.0.1:7890` with the address and port of your proxy server. These commands set the proxy for the current session. If you want to make these changes permanent, add them to your `.bashrc`, `.bash_profile`, or equivalent shell configuration file.
|
||||||
|
|
||||||
|
**Using SSH Instead of HTTPS**
|
||||||
|
|
||||||
|
An alternative to using HTTPS is to set up an SSH connection for Git operations. SSH connections are often not blocked by firewalls and do not require proxy settings. Additionally, SSH provides a secure channel and can simplify the authentication process since it relies on SSH keys rather than username and password credentials.
|
||||||
|
|
||||||
|
To use SSH with Git, you first need to generate an SSH key pair and add the public key to your GitHub account (or another Git hosting service).
|
||||||
|
|
||||||
|
1. **Generate SSH Key Pair**: Open your terminal and run `ssh-keygen -t rsa -b 4096 -C "your_email@example.com"`, replacing `your_email@example.com` with your email. Press enter to accept the default file location and passphrase prompts.
|
||||||
|
|
||||||
|
2. **Add SSH Key to SSH-Agent**: Ensure the ssh-agent is running with `eval "$(ssh-agent -s)"` and then add your SSH private key to the ssh-agent using `ssh-add ~/.ssh/id_rsa`.
|
||||||
|
|
||||||
|
3. **Add SSH Key to GitHub**: Copy your SSH public key to your clipboard with `cat ~/.ssh/id_rsa.pub | clip` (Windows) or `pbcopy < ~/.ssh/id_rsa.pub` (Mac). Go to GitHub, navigate to Settings > SSH and GPG keys, and add a new SSH key, pasting your key into the field provided.
|
||||||
|
|
||||||
|
4. **Switch to SSH in Your Repository**: Change your repository's remote URL from HTTPS to SSH. You can find the SSH URL in your repository settings on GitHub and use `git remote set-url origin git@github.com:username/repository.git` to switch.
|
||||||
|
|
||||||
|
**Authentication Errors**
|
||||||
|
|
||||||
|
If you're experiencing authentication errors, it might be due to missing or incorrect credentials. Ensure you have added your SSH key to your Git hosting service. You can test your SSH connection with `ssh -T git@github.com` (replace `github.com` with your Git hosting service's domain). If successful, you'll receive a welcome message.
|
||||||
|
|
||||||
|
For HTTPS users, check that your username and password (or personal access token for services like GitHub that no longer accept password authentication for Git operations) are correct.
|
||||||
|
|
||||||
|
8. **Open a pull request** to `openimsdk/open-im-server:main`
|
||||||
|
|
||||||
It is recommended to review your changes before filing a pull request. Check if your code doesn't conflict with the main branch and no redundant code is included.
|
It is recommended to review your changes before filing a pull request. Check if your code doesn't conflict with the main branch and no redundant code is included.
|
||||||
|
|
||||||
|
> [!TIP] There is a [good blog post documenting](https://nsddd.top/posts/participating-in-this-project/) the entire push contribution process.
|
||||||
|
|
||||||
|
|
||||||
## Style and Specification
|
## Style and Specification
|
||||||
|
|
||||||
We divide the problem into security and general problems:
|
We divide the problem into security and general problems:
|
||||||
|
|
||||||
#### Reporting security issues
|
#### Reporting security issues
|
||||||
|
|
||||||
Security issues are always treated seriously. As our usual principle, we discourage anyone to spread security issues. If you find a security issue of Open-IM-Server, please do not discuss it in public and even do not open a public issue.
|
Security issues are always treated seriously. As our usual principle, we discourage anyone to spread security issues. If you find a security issue of open-im-server, please do not discuss it in public and even do not open a public issue.
|
||||||
|
|
||||||
Instead we encourage you to send us a private email to info@openim.io to report this.
|
Instead we encourage you to send us a private email to info@openim.io to report this.
|
||||||
|
|
||||||
#### Reporting general issues
|
#### Reporting general issues
|
||||||
|
|
||||||
To be honest, we regard every user of Open-IM-Serveras a very kind contributor. After experiencing Open-IM-Server, you may have some feedback for the project. Then feel free to open an issue via [NEW ISSUE](https://github.com/openimsdk/open-im-server/issues/new/choose).
|
To be honest, we regard every user of open-im-serveras a very kind contributor. After experiencing open-im-server, you may have some feedback for the project. Then feel free to open an issue via [NEW ISSUE](https://github.com/openimsdk/open-im-server/issues/new/choose).
|
||||||
|
|
||||||
Since we collaborate project Open-IM-Server in a distributed way, we appreciate **WELL-WRITTEN**, **DETAILED**, **EXPLICIT** issue reports. To make the communication more efficient, we wish everyone could search if your issue is an existing one in the searching list. If you find it existing, please add your details in comments under the existing issue instead of opening a brand new one.
|
Since we collaborate project open-im-server in a distributed way, we appreciate **WELL-WRITTEN**, **DETAILED**, **EXPLICIT** issue reports. To make the communication more efficient, we wish everyone could search if your issue is an existing one in the searching list. If you find it existing, please add your details in comments under the existing issue instead of opening a brand new one.
|
||||||
|
|
||||||
To make the issue details as standard as possible, we setup an [ISSUE TEMPLATE](https://github.com/OpenIMSDK/.github/tree/main/.github/ISSUE_TEMPLATE) for issue reporters. You can find three kinds of issue templates there: question, bug report and feature request. Please **BE SURE** to follow the instructions to fill fields in template.
|
To make the issue details as standard as possible, we setup an [ISSUE TEMPLATE](https://github.com/OpenIMSDK/.github/tree/main/.github/ISSUE_TEMPLATE) for issue reporters. You can find three kinds of issue templates there: question, bug report and feature request. Please **BE SURE** to follow the instructions to fill fields in template.
|
||||||
|
|
||||||
@@ -206,20 +319,20 @@ To make the issue details as standard as possible, we setup an [ISSUE TEMPLATE](
|
|||||||
|
|
||||||
+ bug report
|
+ bug report
|
||||||
+ feature request
|
+ feature request
|
||||||
+ Open-IM-Server performance issues
|
+ open-im-server performance issues
|
||||||
+ feature proposal
|
+ feature proposal
|
||||||
+ feature design
|
+ feature design
|
||||||
+ help wanted
|
+ help wanted
|
||||||
+ doc incomplete
|
+ doc incomplete
|
||||||
+ test improvement
|
+ test improvement
|
||||||
+ any questions on Open-IM-Server project
|
+ any questions on open-im-server project
|
||||||
+ and so on
|
+ and so on
|
||||||
|
|
||||||
Also, we must be reminded when submitting a new question about Open-IM-Server, please remember to remove the sensitive data from your post. Sensitive data could be password, secret key, network locations, private business data and so on.
|
Also, we must be reminded when submitting a new question about open-im-server, please remember to remove the sensitive data from your post. Sensitive data could be password, secret key, network locations, private business data and so on.
|
||||||
|
|
||||||
#### Commit Rules
|
#### Commit Rules
|
||||||
|
|
||||||
Actually in Open-IM-Server, we take two rules serious when committing:
|
Actually in open-im-server, we take two rules serious when committing:
|
||||||
|
|
||||||
**🥇 Commit Message:**
|
**🥇 Commit Message:**
|
||||||
|
|
||||||
@@ -262,7 +375,7 @@ An example for this could be:
|
|||||||
|
|
||||||
#### PR Description
|
#### PR Description
|
||||||
|
|
||||||
PR is the only way to make change to Open-IM-Server project files. To help reviewers better get your purpose, PR description could not be too detailed. We encourage contributors to follow the [PR template](https://github.com/OpenIMSDK/.github/tree/main/.github/PULL_REQUEST_TEMPLATE.md) to finish the pull request.
|
PR is the only way to make change to open-im-server project files. To help reviewers better get your purpose, PR description could not be too detailed. We encourage contributors to follow the [PR template](https://github.com/OpenIMSDK/.github/tree/main/.github/PULL_REQUEST_TEMPLATE.md) to finish the pull request.
|
||||||
|
|
||||||
You can find some very formal PR in [RFC](https://github.com/openimsdk/open-im-server/issues?q=is%3Aissue+is%3Aopen+RFC+label%3ARFC) issues and learn about them.
|
You can find some very formal PR in [RFC](https://github.com/openimsdk/open-im-server/issues?q=is%3Aissue+is%3Aopen+RFC+label%3ARFC) issues and learn about them.
|
||||||
|
|
||||||
@@ -311,11 +424,11 @@ git() {
|
|||||||
|
|
||||||
#### Docs Contribution
|
#### Docs Contribution
|
||||||
|
|
||||||
The documentation for Open-IM-Server includes:
|
The documentation for open-im-server includes:
|
||||||
|
|
||||||
+ [README.md](https://github.com/openimsdk/open-im-server/blob/main/README.md): This file includes the basic information and instructions for getting started with Open-IM-Server.
|
+ [README.md](https://github.com/openimsdk/open-im-server/blob/main/README.md): This file includes the basic information and instructions for getting started with open-im-server.
|
||||||
+ [CONTRIBUTING.md](https://github.com/openimsdk/open-im-server/blob/main/CONTRIBUTING.md): This file contains guidelines for contributing to Open-IM-Server's codebase, such as how to submit issues, pull requests, and code reviews.
|
+ [CONTRIBUTING.md](https://github.com/openimsdk/open-im-server/blob/main/CONTRIBUTING.md): This file contains guidelines for contributing to open-im-server's codebase, such as how to submit issues, pull requests, and code reviews.
|
||||||
+ [Official Documentation](https://doc.rentsoft.cn/): This is the official documentation for Open-IM-Server, which includes comprehensive information on all of its features, configuration options, and troubleshooting tips.
|
+ [Official Documentation](https://doc.rentsoft.cn/): This is the official documentation for open-im-server, which includes comprehensive information on all of its features, configuration options, and troubleshooting tips.
|
||||||
|
|
||||||
Please obey the following rules to better format the docs, which would greatly improve the reading experience.
|
Please obey the following rules to better format the docs, which would greatly improve the reading experience.
|
||||||
|
|
||||||
@@ -328,20 +441,20 @@ Please obey the following rules to better format the docs, which would greatly i
|
|||||||
|
|
||||||
## Engage to help anything
|
## Engage to help anything
|
||||||
|
|
||||||
We choose GitHub as the primary place for Open-IM-Server to collaborate. So the latest updates of Open-IM-Server are always here. Although contributions via PR is an explicit way to help, we still call for any other ways.
|
We choose GitHub as the primary place for open-im-server to collaborate. So the latest updates of open-im-server are always here. Although contributions via PR is an explicit way to help, we still call for any other ways.
|
||||||
|
|
||||||
+ reply to other's [issues](https://github.com/openimsdk/open-im-server/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc) if you could;
|
+ reply to other's [issues](https://github.com/openimsdk/open-im-server/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc) if you could;
|
||||||
+ help solve other user's problems;
|
+ help solve other user's problems;
|
||||||
+ help review other's [PR](https://github.com/openimsdk/open-im-server/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-desc) design;
|
+ help review other's [PR](https://github.com/openimsdk/open-im-server/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-desc) design;
|
||||||
+ discuss about Open-IM-Server to make things clearer;
|
+ discuss about open-im-server to make things clearer;
|
||||||
+ advocate [Open-IM-Server](https://google.com/search?q=Open-IM-Server) technology beyond GitHub;
|
+ advocate [open-im-server](https://google.com/search?q=open-im-server) technology beyond GitHub;
|
||||||
+ write blogs on Open-IM-Server and so on.
|
+ write blogs on open-im-server and so on.
|
||||||
|
|
||||||
In a word, **ANY HELP IS CONTRIBUTION.**
|
In a word, **ANY HELP IS CONTRIBUTION.**
|
||||||
|
|
||||||
## Release version
|
## Release version
|
||||||
|
|
||||||
Releases of Open-IM-Server are done using [Release Please](https://github.com/googleapis/release-please) and [GoReleaser](https://goreleaser.com/). The workflow looks like this:
|
Releases of open-im-server are done using [Release Please](https://github.com/googleapis/release-please) and [GoReleaser](https://goreleaser.com/). The workflow looks like this:
|
||||||
|
|
||||||
🎯 A PR is merged to the `main` branch:
|
🎯 A PR is merged to the `main` branch:
|
||||||
|
|
||||||
@@ -366,17 +479,23 @@ Such a commit can get produced as follows:
|
|||||||
❯ git commit --allow-empty -m "chore: release 0.0.3" -m "Release-As: 0.0.3
|
❯ git commit --allow-empty -m "chore: release 0.0.3" -m "Release-As: 0.0.3
|
||||||
````
|
````
|
||||||
|
|
||||||
|
For the complex release process, in fact, and encapsulation as CICD, you only need to tag locally, and then publish the tag to OpenIM github to complete the entire OpenIM release process.
|
||||||
|
|
||||||
|
In addition to CICD, we also do a complex release command locally, which can help you complete the full platform compilation, testing, and release to Minio, just by using the `make release` command.
|
||||||
|
Please [read the detailed documents](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/release.md)
|
||||||
|
|
||||||
|
|
||||||
## Contact Us
|
## Contact Us
|
||||||
|
|
||||||
We value close connections with our users, developers, and contributors here at Open-IM-Server. With a large community and maintainer team, we're always here to help and support you. Whether you're looking to join our community or have any questions or suggestions, we welcome you to get in touch with us.
|
We value close connections with our users, developers, and contributors here at open-im-server. With a large community and maintainer team, we're always here to help and support you. Whether you're looking to join our community or have any questions or suggestions, we welcome you to get in touch with us.
|
||||||
|
|
||||||
Our most recommended way to get in touch is through [Slack](https://join.slack.com/t/openimsdk/shared_invite/zt-22720d66b-o_FvKxMTGXtcnnnHiMqe9Q). Even if you're in China, Slack is usually not blocked by firewalls, making it an easy way to connect with us. Our Slack community is the ideal place to discuss and share ideas and suggestions with other users and developers of Open-IM-Server. You can ask technical questions, seek help, or share your experiences with other users of Open-IM-Server.
|
Our most recommended way to get in touch is through [Slack](https://join.slack.com/t/openimsdk/shared_invite/zt-22720d66b-o_FvKxMTGXtcnnnHiMqe9Q). Even if you're in China, Slack is usually not blocked by firewalls, making it an easy way to connect with us. Our Slack community is the ideal place to discuss and share ideas and suggestions with other users and developers of open-im-server. You can ask technical questions, seek help, or share your experiences with other users of open-im-server.
|
||||||
|
|
||||||
In addition to Slack, we also offer the following ways to get in touch:
|
In addition to Slack, we also offer the following ways to get in touch:
|
||||||
|
|
||||||
+ <a href="https://join.slack.com/t/openimsdk/shared_invite/zt-22720d66b-o_FvKxMTGXtcnnnHiMqe9Q" target="_blank"><img src="https://img.shields.io/badge/slack-%40OpenIMSDKCore-informational?logo=slack&style=flat-square"></a>: We also have Slack channels for you to communicate and discuss. To join, visit https://slack.com/ and join our [👀 Open-IM-Server slack](https://join.slack.com/t/openimsdk/shared_invite/zt-22720d66b-o_FvKxMTGXtcnnnHiMqe9Q) team channel.
|
+ <a href="https://join.slack.com/t/openimsdk/shared_invite/zt-22720d66b-o_FvKxMTGXtcnnnHiMqe9Q" target="_blank"><img src="https://img.shields.io/badge/slack-%40OpenIMSDKCore-informational?logo=slack&style=flat-square"></a>: We also have Slack channels for you to communicate and discuss. To join, visit https://slack.com/ and join our [👀 open-im-server slack](https://join.slack.com/t/openimsdk/shared_invite/zt-22720d66b-o_FvKxMTGXtcnnnHiMqe9Q) team channel.
|
||||||
+ <a href="https://mail.google.com/mail/u/0/?fs=1&tf=cm&to=4closetool3@gmail.com" target="_blank"><img src="https://img.shields.io/badge/gmail-%40OOpenIMSDKCore?style=social&logo=gmail"></a>: Get in touch with us on [Gmail](info@openim.io). If you have any questions or issues that need resolving, or any suggestions and feedback for our open source projects, please feel free to contact us via email.
|
+ <a href="https://mail.google.com/mail/u/0/?fs=1&tf=cm&to=4closetool3@gmail.com" target="_blank"><img src="https://img.shields.io/badge/gmail-%40OOpenIMSDKCore?style=social&logo=gmail"></a>: Get in touch with us on [Gmail](info@openim.io). If you have any questions or issues that need resolving, or any suggestions and feedback for our open source projects, please feel free to contact us via email.
|
||||||
+ <a href="https://doc.rentsoft.cn/" target="_blank"><img src="https://img.shields.io/badge/%E5%8D%9A%E5%AE%A2-%40OpenIMSDKCore-blue?style=social&logo=Octopus%20Deploy"></a>: Read our [blog](https://doc.rentsoft.cn/). Our blog is a great place to stay up-to-date with Open-IM-Server projects and trends. On the blog, we share our latest developments, tech trends, and other interesting information.
|
+ <a href="https://doc.rentsoft.cn/" target="_blank"><img src="https://img.shields.io/badge/%E5%8D%9A%E5%AE%A2-%40OpenIMSDKCore-blue?style=social&logo=Octopus%20Deploy"></a>: Read our [blog](https://doc.rentsoft.cn/). Our blog is a great place to stay up-to-date with open-im-server projects and trends. On the blog, we share our latest developments, tech trends, and other interesting information.
|
||||||
+ <a href="https://github.com/OpenIMSDK/OpenIM-Docs/blob/main/docs/images/WechatIMG20.jpeg" target="_blank"><img src="https://img.shields.io/badge/%E5%BE%AE%E4%BF%A1-OpenIMSDKCore-brightgreen?logo=wechat&style=flat-square"></a>: Add [Wechat](https://github.com/OpenIMSDK/OpenIM-Docs/blob/main/docs/images/WechatIMG20.jpeg) and indicate that you are a user or developer of Open-IM-Server. We will process your request as soon as possible.
|
+ <a href="https://github.com/OpenIMSDK/OpenIM-Docs/blob/main/docs/images/WechatIMG20.jpeg" target="_blank"><img src="https://img.shields.io/badge/%E5%BE%AE%E4%BF%A1-OpenIMSDKCore-brightgreen?logo=wechat&style=flat-square"></a>: Add [Wechat](https://github.com/OpenIMSDK/OpenIM-Docs/blob/main/docs/images/WechatIMG20.jpeg) and indicate that you are a user or developer of open-im-server. We will process your request as soon as possible.
|
||||||
|
|
||||||
Whether you're looking to join our community or have any questions or suggestions, we welcome you to get in touch with us.
|
Whether you're looking to join our community or have any questions or suggestions, we welcome you to get in touch with us.
|
||||||
|
|||||||
@@ -4,29 +4,51 @@
|
|||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h3 align="center" style="border-bottom: none">
|
<div align="center">
|
||||||
⭐️ Open source Instant Messaging Server ⭐️ <br>
|
|
||||||
<h3>
|
|
||||||
|
|
||||||
|
[](https://github.com/openimsdk/open-im-server/stargazers)
|
||||||
|
[](https://github.com/openimsdk/open-im-server/network/members)
|
||||||
|
[](https://app.codecov.io/gh/openimsdk/open-im-server)
|
||||||
|
[](https://goreportcard.com/report/github.com/openimsdk/open-im-server)
|
||||||
|
[](https://pkg.go.dev/github.com/openimsdk/open-im-server/v3)
|
||||||
|
[](https://github.com/openimsdk/open-im-server/blob/main/LICENSE)
|
||||||
|
[](https://join.slack.com/t/openimsdk/shared_invite/zt-22720d66b-o_FvKxMTGXtcnnnHiMqe9Q)
|
||||||
|
[](https://www.bestpractices.dev/projects/8045)
|
||||||
|
[](https://github.com/openimsdk/open-im-server/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22good+first+issue%22)
|
||||||
|
[](https://golang.org/)
|
||||||
|
|
||||||
<p align=center>
|
|
||||||
<a href="https://goreportcard.com/report/github.com/openimsdk/open-im-server"><img src="https://goreportcard.com/badge/github.com/openimsdk/open-im-server" alt="A+"></a>
|
|
||||||
<a href="https://github.com/openimsdk/open-im-server/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22good+first+issue%22"><img src="https://img.shields.io/github/issues/openimsdk/open-im-server/good%20first%20issue?logo=%22github%22" alt="good first"></a>
|
|
||||||
<a href="https://github.com/openimsdk/open-im-server"><img src="https://img.shields.io/github/stars/openimsdk/open-im-server.svg?style=flat&logo=github&colorB=deeppink&label=stars"></a>
|
|
||||||
<a href="https://join.slack.com/t/openimsdk/shared_invite/zt-22720d66b-o_FvKxMTGXtcnnnHiMqe9Q"><img src="https://img.shields.io/badge/Slack-300%2B-blueviolet?logo=slack&logoColor=white"></a>
|
|
||||||
<a href="https://github.com/openimsdk/open-im-server/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-green"></a>
|
|
||||||
<a href="https://golang.org/"><img src="https://img.shields.io/badge/Language-Go-blue.svg"></a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="./README.md"><b> English </b></a> •
|
<a href="./README.md">Englist</a> ·
|
||||||
<a href="./README-zh_CN.md"><b> 简体中文 </b></a> •
|
<a href="./README-zh_CN.md">中文</a> ·
|
||||||
<a href="https://openim.io/en"><b> Docs </b></a>
|
<a href="docs/readme/README-UA.md">Українська</a> ·
|
||||||
|
<a href="docs/readme/README-CS.md">Česky</a> ·
|
||||||
|
<a href="docs/readme/README-HU.md">Magyar</a> ·
|
||||||
|
<a href="docs/readme/README-ES.md">Español</a> ·
|
||||||
|
<a href="docs/readme/README-FA.md">فارسی</a> ·
|
||||||
|
<a href="docs/readme/README-FR.md">Français</a> ·
|
||||||
|
<a href="docs/readme/README-DE.md">Deutsch</a> ·
|
||||||
|
<a href="docs/readme/README-PL.md">Polski</a> ·
|
||||||
|
<a href="docs/readme/README-ID.md">Indonesian</a> ·
|
||||||
|
<a href="docs/readme/README-FI.md">Suomi</a> ·
|
||||||
|
<a href="docs/readme/README-ML.md">മലയാളം</a> ·
|
||||||
|
<a href="docs/readme/README-JP.md">日本語</a> ·
|
||||||
|
<a href="docs/readme/README-NL.md">Nederlands</a> ·
|
||||||
|
<a href="docs/readme/README-IT.md">Italiano</a> ·
|
||||||
|
<a href="docs/readme/README-RU.md">Русский</a> ·
|
||||||
|
<a href="docs/readme/README-PTBR.md">Português (Brasil)</a> ·
|
||||||
|
<a href="docs/readme/README-EO.md">Esperanto</a> ·
|
||||||
|
<a href="docs/readme/README-KR.md">한국어</a> ·
|
||||||
|
<a href="docs/readme/README-AR.md">العربي</a> ·
|
||||||
|
<a href="docs/readme/README-VN.md">Tiếng Việt</a> ·
|
||||||
|
<a href="docs/readme/README-DA.md">Dansk</a> ·
|
||||||
|
<a href="docs/readme/README-GR.md">Ελληνικά</a> ·
|
||||||
|
<a href="docs/readme/README-TR.md">Türkçe</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
## 🟢 扫描微信进群交流
|
## 🟢 扫描微信进群交流
|
||||||
@@ -39,8 +61,6 @@ OpenIM 是一个专门设计用于在应用程序中集成聊天、音视频通
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## 🚀 关于 OpenIMSDK
|
## 🚀 关于 OpenIMSDK
|
||||||
|
|||||||
46
README.md
46
README.md
@@ -17,9 +17,35 @@
|
|||||||
[](https://github.com/openimsdk/open-im-server/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22good+first+issue%22)
|
[](https://github.com/openimsdk/open-im-server/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22good+first+issue%22)
|
||||||
[](https://golang.org/)
|
[](https://golang.org/)
|
||||||
|
|
||||||
[**English**](./README.md) •
|
|
||||||
[**简体中文**](./README-zh_CN.md) •
|
<p align="center">
|
||||||
[**Docs**](https://openim.io/en)
|
<a href="./README.md">Englist</a> ·
|
||||||
|
<a href="./README-zh_CN.md">中文</a> ·
|
||||||
|
<a href="docs/readme/README-UA.md">Українська</a> ·
|
||||||
|
<a href="docs/readme/README-CS.md">Česky</a> ·
|
||||||
|
<a href="docs/readme/README-HU.md">Magyar</a> ·
|
||||||
|
<a href="docs/readme/README-ES.md">Español</a> ·
|
||||||
|
<a href="docs/readme/README-FA.md">فارسی</a> ·
|
||||||
|
<a href="docs/readme/README-FR.md">Français</a> ·
|
||||||
|
<a href="docs/readme/README-DE.md">Deutsch</a> ·
|
||||||
|
<a href="docs/readme/README-PL.md">Polski</a> ·
|
||||||
|
<a href="docs/readme/README-ID.md">Indonesian</a> ·
|
||||||
|
<a href="docs/readme/README-FI.md">Suomi</a> ·
|
||||||
|
<a href="docs/readme/README-ML.md">മലയാളം</a> ·
|
||||||
|
<a href="docs/readme/README-JP.md">日本語</a> ·
|
||||||
|
<a href="docs/readme/README-NL.md">Nederlands</a> ·
|
||||||
|
<a href="docs/readme/README-IT.md">Italiano</a> ·
|
||||||
|
<a href="docs/readme/README-RU.md">Русский</a> ·
|
||||||
|
<a href="docs/readme/README-PTBR.md">Português (Brasil)</a> ·
|
||||||
|
<a href="docs/readme/README-EO.md">Esperanto</a> ·
|
||||||
|
<a href="docs/readme/README-KR.md">한국어</a> ·
|
||||||
|
<a href="docs/readme/README-AR.md">العربي</a> ·
|
||||||
|
<a href="docs/readme/README-VN.md">Tiếng Việt</a> ·
|
||||||
|
<a href="docs/readme/README-DA.md">Dansk</a> ·
|
||||||
|
<a href="docs/readme/README-GR.md">Ελληνικά</a> ·
|
||||||
|
<a href="docs/readme/README-TR.md">Türkçe</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -42,7 +68,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
|
||||||
@@ -68,13 +94,25 @@ It is built using Golang and supports cross-platform deployment, ensuring a cons
|
|||||||
|
|
||||||
👉 **[Learn more](https://docs.openim.io/guides/introduction/product)**
|
👉 **[Learn more](https://docs.openim.io/guides/introduction/product)**
|
||||||
|
|
||||||
|
## :building_construction: Overall Architecture
|
||||||
|
|
||||||
|
Delve into the heart of Open-IM-Server's functionality with our architecture diagram.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
## :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
|
||||||
|
|
||||||
|
|||||||
@@ -26,9 +26,10 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
"github.com/OpenIMSDK/tools/discoveryregistry"
|
"github.com/OpenIMSDK/tools/discoveryregistry"
|
||||||
"github.com/OpenIMSDK/tools/log"
|
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/internal/api"
|
"github.com/openimsdk/open-im-server/v3/internal/api"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
||||||
@@ -44,55 +45,43 @@ func main() {
|
|||||||
apiCmd.AddPortFlag()
|
apiCmd.AddPortFlag()
|
||||||
apiCmd.AddApi(run)
|
apiCmd.AddApi(run)
|
||||||
if err := apiCmd.Execute(); err != nil {
|
if err := apiCmd.Execute(); err != nil {
|
||||||
log.ZError(context.Background(), "API command execution failed", err)
|
fmt.Fprintf(os.Stderr, "\n\nexit -1: \n%+v\n\n", err)
|
||||||
panic(err.Error())
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func run(port int, proPort int) error {
|
func run(port int, proPort int) error {
|
||||||
log.ZInfo(context.Background(), "Openim api port:", "port", port, "proPort", proPort)
|
|
||||||
|
|
||||||
if port == 0 || proPort == 0 {
|
if port == 0 || proPort == 0 {
|
||||||
err := "port or proPort is empty:" + strconv.Itoa(port) + "," + strconv.Itoa(proPort)
|
err := "port or proPort is empty:" + strconv.Itoa(port) + "," + strconv.Itoa(proPort)
|
||||||
log.ZError(context.Background(), err, nil)
|
return errs.Wrap(fmt.Errorf(err))
|
||||||
return fmt.Errorf(err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rdb, err := cache.NewRedis()
|
rdb, err := cache.NewRedis()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(context.Background(), "Failed to initialize Redis", err)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.ZInfo(context.Background(), "api start init discov client")
|
|
||||||
|
|
||||||
var client discoveryregistry.SvcDiscoveryRegistry
|
var client discoveryregistry.SvcDiscoveryRegistry
|
||||||
|
|
||||||
// Determine whether zk is passed according to whether it is a clustered deployment
|
// Determine whether zk is passed according to whether it is a clustered deployment
|
||||||
client, err = kdisc.NewDiscoveryRegister(config.Config.Envs.Discovery)
|
client, err = kdisc.NewDiscoveryRegister(config.Config.Envs.Discovery)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(context.Background(), "Failed to initialize discovery register", err)
|
return errs.Wrap(err, "register discovery err")
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = client.CreateRpcRootNodes(config.Config.GetServiceNames()); err != nil {
|
if err = client.CreateRpcRootNodes(config.Config.GetServiceNames()); err != nil {
|
||||||
log.ZError(context.Background(), "Failed to create RPC root nodes", err)
|
return errs.Wrap(err, "create rpc root nodes error")
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.ZInfo(context.Background(), "api register public config to discov")
|
|
||||||
if err = client.RegisterConf2Registry(constant.OpenIMCommonConfigKey, config.Config.EncodeConfig()); err != nil {
|
if err = client.RegisterConf2Registry(constant.OpenIMCommonConfigKey, config.Config.EncodeConfig()); err != nil {
|
||||||
log.ZError(context.Background(), "Failed to register public config to discov", err)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.ZInfo(context.Background(), "api register public config to discov success")
|
|
||||||
router := api.NewGinRouter(client, rdb)
|
router := api.NewGinRouter(client, rdb)
|
||||||
if config.Config.Prometheus.Enable {
|
if config.Config.Prometheus.Enable {
|
||||||
p := ginprom.NewPrometheus("app", prommetrics.GetGinCusMetrics("Api"))
|
p := ginprom.NewPrometheus("app", prommetrics.GetGinCusMetrics("Api"))
|
||||||
p.SetListenAddress(fmt.Sprintf(":%d", proPort))
|
p.SetListenAddress(fmt.Sprintf(":%d", proPort))
|
||||||
p.Use(router)
|
p.Use(router)
|
||||||
}
|
}
|
||||||
log.ZInfo(context.Background(), "api init router success")
|
|
||||||
|
|
||||||
var address string
|
var address string
|
||||||
if config.Config.Api.ListenIP != "" {
|
if config.Config.Api.ListenIP != "" {
|
||||||
@@ -100,13 +89,11 @@ func run(port int, proPort int) error {
|
|||||||
} else {
|
} else {
|
||||||
address = net.JoinHostPort("0.0.0.0", strconv.Itoa(port))
|
address = net.JoinHostPort("0.0.0.0", strconv.Itoa(port))
|
||||||
}
|
}
|
||||||
log.ZInfo(context.Background(), "start api server", "address", address, "OpenIM version", config.Version)
|
|
||||||
|
|
||||||
server := http.Server{Addr: address, Handler: router}
|
server := http.Server{Addr: address, Handler: router}
|
||||||
go func() {
|
go func() {
|
||||||
err = server.ListenAndServe()
|
err = server.ListenAndServe()
|
||||||
if err != nil && err != http.ErrServerClosed {
|
if err != nil && err != http.ErrServerClosed {
|
||||||
log.ZError(context.Background(), "api run failed", err, "address", address)
|
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@@ -120,7 +107,6 @@ func run(port int, proPort int) error {
|
|||||||
|
|
||||||
// graceful shutdown operation.
|
// graceful shutdown operation.
|
||||||
if err := server.Shutdown(ctx); err != nil {
|
if err := server.Shutdown(ctx); err != nil {
|
||||||
log.ZError(context.Background(), "failed to api-server shutdown", err)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -54,6 +57,7 @@ func main() {
|
|||||||
// openIM clear msg --clearAll
|
// openIM clear msg --clearAll
|
||||||
msgUtilsCmd.AddCommand(&getCmd.Command, &fixCmd.Command, &clearCmd.Command)
|
msgUtilsCmd.AddCommand(&getCmd.Command, &fixCmd.Command, &clearCmd.Command)
|
||||||
if err := msgUtilsCmd.Execute(); err != nil {
|
if err := msgUtilsCmd.Execute(); err != nil {
|
||||||
panic(err)
|
fmt.Fprintf(os.Stderr, "\n\nexit -1: \n%+v\n\n", err)
|
||||||
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/internal/tools"
|
"github.com/openimsdk/open-im-server/v3/internal/tools"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
||||||
)
|
)
|
||||||
@@ -22,6 +25,7 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
cronTaskCmd := cmd.NewCronTaskCmd()
|
cronTaskCmd := cmd.NewCronTaskCmd()
|
||||||
if err := cronTaskCmd.Exec(tools.StartTask); err != nil {
|
if err := cronTaskCmd.Exec(tools.StartTask); err != nil {
|
||||||
panic(err.Error())
|
fmt.Fprintf(os.Stderr, "\n\nexit -1: \n%+v\n\n", err)
|
||||||
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -25,6 +28,7 @@ func main() {
|
|||||||
msgGatewayCmd.AddPrometheusPortFlag()
|
msgGatewayCmd.AddPrometheusPortFlag()
|
||||||
|
|
||||||
if err := msgGatewayCmd.Exec(); err != nil {
|
if err := msgGatewayCmd.Exec(); err != nil {
|
||||||
panic(err.Error())
|
fmt.Fprintf(os.Stderr, "\n\nexit -1: \n%+v\n\n", err)
|
||||||
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -23,6 +26,7 @@ func main() {
|
|||||||
msgTransferCmd.AddPrometheusPortFlag()
|
msgTransferCmd.AddPrometheusPortFlag()
|
||||||
msgTransferCmd.AddTransferProgressFlag()
|
msgTransferCmd.AddTransferProgressFlag()
|
||||||
if err := msgTransferCmd.Exec(); err != nil {
|
if err := msgTransferCmd.Exec(); err != nil {
|
||||||
panic(err.Error())
|
fmt.Fprintf(os.Stderr, "\n\nexit -1: \n%+v\n\n", err)
|
||||||
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/internal/push"
|
"github.com/openimsdk/open-im-server/v3/internal/push"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
@@ -28,6 +31,7 @@ func main() {
|
|||||||
panic(err.Error())
|
panic(err.Error())
|
||||||
}
|
}
|
||||||
if err := pushCmd.StartSvr(config.Config.RpcRegisterName.OpenImPushName, push.Start); err != nil {
|
if err := pushCmd.StartSvr(config.Config.RpcRegisterName.OpenImPushName, push.Start); err != nil {
|
||||||
panic(err.Error())
|
fmt.Fprintf(os.Stderr, "\n\nexit -1: \n%+v\n\n", err)
|
||||||
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/internal/rpc/auth"
|
"github.com/openimsdk/open-im-server/v3/internal/rpc/auth"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
@@ -28,6 +31,7 @@ func main() {
|
|||||||
panic(err.Error())
|
panic(err.Error())
|
||||||
}
|
}
|
||||||
if err := authCmd.StartSvr(config.Config.RpcRegisterName.OpenImAuthName, auth.Start); err != nil {
|
if err := authCmd.StartSvr(config.Config.RpcRegisterName.OpenImAuthName, auth.Start); err != nil {
|
||||||
panic(err.Error())
|
fmt.Fprintf(os.Stderr, "\n\nexit -1: \n%+v\n\n", err)
|
||||||
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/internal/rpc/conversation"
|
"github.com/openimsdk/open-im-server/v3/internal/rpc/conversation"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
@@ -28,6 +31,7 @@ func main() {
|
|||||||
panic(err.Error())
|
panic(err.Error())
|
||||||
}
|
}
|
||||||
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImConversationName, conversation.Start); err != nil {
|
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImConversationName, conversation.Start); err != nil {
|
||||||
panic(err.Error())
|
fmt.Fprintf(os.Stderr, "\n\nexit -1: \n%+v\n\n", err)
|
||||||
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/internal/rpc/friend"
|
"github.com/openimsdk/open-im-server/v3/internal/rpc/friend"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
@@ -28,6 +31,7 @@ func main() {
|
|||||||
panic(err.Error())
|
panic(err.Error())
|
||||||
}
|
}
|
||||||
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImFriendName, friend.Start); err != nil {
|
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImFriendName, friend.Start); err != nil {
|
||||||
panic(err.Error())
|
fmt.Fprintf(os.Stderr, "\n\nexit -1: \n%+v\n\n", err)
|
||||||
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/internal/rpc/group"
|
"github.com/openimsdk/open-im-server/v3/internal/rpc/group"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
@@ -28,6 +31,7 @@ func main() {
|
|||||||
panic(err.Error())
|
panic(err.Error())
|
||||||
}
|
}
|
||||||
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImGroupName, group.Start); err != nil {
|
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImGroupName, group.Start); err != nil {
|
||||||
panic(err.Error())
|
fmt.Fprintf(os.Stderr, "\n\nexit -1: \n%+v\n\n", err)
|
||||||
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/internal/rpc/msg"
|
"github.com/openimsdk/open-im-server/v3/internal/rpc/msg"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
@@ -28,6 +31,7 @@ func main() {
|
|||||||
panic(err.Error())
|
panic(err.Error())
|
||||||
}
|
}
|
||||||
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImMsgName, msg.Start); err != nil {
|
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImMsgName, msg.Start); err != nil {
|
||||||
panic(err.Error())
|
fmt.Fprintf(os.Stderr, "\n\nexit -1: \n%+v\n\n", err)
|
||||||
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/internal/rpc/third"
|
"github.com/openimsdk/open-im-server/v3/internal/rpc/third"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
@@ -28,6 +31,7 @@ func main() {
|
|||||||
panic(err.Error())
|
panic(err.Error())
|
||||||
}
|
}
|
||||||
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImThirdName, third.Start); err != nil {
|
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImThirdName, third.Start); err != nil {
|
||||||
panic(err.Error())
|
fmt.Fprintf(os.Stderr, "\n\nexit -1: \n%+v\n\n", err)
|
||||||
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/internal/rpc/user"
|
"github.com/openimsdk/open-im-server/v3/internal/rpc/user"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
@@ -28,6 +31,7 @@ func main() {
|
|||||||
panic(err.Error())
|
panic(err.Error())
|
||||||
}
|
}
|
||||||
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImUserName, user.Start); err != nil {
|
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImUserName, user.Start); err != nil {
|
||||||
panic(err.Error())
|
fmt.Fprintf(os.Stderr, "\n\nexit -1: \n%+v\n\n", err)
|
||||||
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,21 +315,21 @@ 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
|
||||||
failedContinue: true
|
failedContinue: true
|
||||||
beforeUpdateUserInfoEx:
|
beforeUpdateUserInfoEx:
|
||||||
enable: false
|
enable: false
|
||||||
timeout: 5
|
timeout: 5
|
||||||
failedContinue: true
|
failedContinue: true
|
||||||
afterUpdateUserInfoEx:
|
afterUpdateUserInfoEx:
|
||||||
enable: false
|
enable: false
|
||||||
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
|
||||||
|
# and settings in this .env file exist, the environment variables take precedence.
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# ==========================
|
||||||
|
# General Configuration
|
||||||
|
# ==========================
|
||||||
|
# These settings apply to the overall environment.
|
||||||
|
|
||||||
# The user for authentication or system operations.
|
# Data storage directory for persistent data.
|
||||||
# Default: OPENIM_USER=root
|
# Example: DATA_DIR=/path/to/data
|
||||||
USER=root
|
DATA_DIR=/workspaces/open-im-server
|
||||||
|
|
||||||
# Password associated with the specified user for authentication.
|
# Docker image registry. Uncomment the preferred one.
|
||||||
# Default: PASSWORD=openIM123
|
# Options: ghcr.io/openimsdk, openim, registry.cn-hangzhou.aliyuncs.com/openimsdk
|
||||||
PASSWORD=openIM123
|
# IMAGE_REGISTRY="ghcr.io/openimsdk"
|
||||||
|
# IMAGE_REGISTRY="openim"
|
||||||
# Base URL for the application programming interface (API).
|
# IMAGE_REGISTRY="registry.cn-hangzhou.aliyuncs.com/openimsdk"
|
||||||
# Default: API_URL=http://172.28.0.1:10002
|
|
||||||
API_URL=http://14.155.64.202:10002
|
|
||||||
|
|
||||||
# Directory path for storing data files or related information.
|
|
||||||
# Default: DATA_DIR=./
|
|
||||||
DATA_DIR=/data/workspaces/open-im-server
|
|
||||||
|
|
||||||
# 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
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
@@ -243,9 +243,10 @@ push:
|
|||||||
#
|
#
|
||||||
# Built-in app manager user IDs
|
# Built-in app manager user IDs
|
||||||
# Built-in app manager nicknames
|
# Built-in app manager nicknames
|
||||||
|
# Attention, this configure is discarded. If you have used him before, configure your own
|
||||||
manager:
|
manager:
|
||||||
userID: [ "${MANAGER_USERID_1}", "${MANAGER_USERID_2}", "${MANAGER_USERID_3}" ]
|
userID:
|
||||||
nickname: [ "${NICKNAME_1}", "${NICKNAME_2}", "${NICKNAME_3}" ]
|
nickname:
|
||||||
|
|
||||||
# chatAdmin, use for send notification
|
# chatAdmin, use for send notification
|
||||||
#
|
#
|
||||||
@@ -329,7 +330,7 @@ callback:
|
|||||||
timeout: ${CALLBACK_TIMEOUT}
|
timeout: ${CALLBACK_TIMEOUT}
|
||||||
failedContinue: ${CALLBACK_FAILED_CONTINUE}
|
failedContinue: ${CALLBACK_FAILED_CONTINUE}
|
||||||
afterSendSingleMsg:
|
afterSendSingleMsg:
|
||||||
enable: true
|
enable: ${CALLBACK_ENABLE}
|
||||||
timeout: ${CALLBACK_TIMEOUT}
|
timeout: ${CALLBACK_TIMEOUT}
|
||||||
failedContinue: ${CALLBACK_FAILED_CONTINUE}
|
failedContinue: ${CALLBACK_FAILED_CONTINUE}
|
||||||
beforeSendGroupMsg:
|
beforeSendGroupMsg:
|
||||||
@@ -100,7 +100,7 @@ ZOOKEEPER_PORT=${ZOOKEEPER_PORT}
|
|||||||
|
|
||||||
# MongoDB service port configuration.
|
# MongoDB service port configuration.
|
||||||
# Default: MONGO_PORT=37017
|
# Default: MONGO_PORT=37017
|
||||||
# MONGO_PORT=${MONGO_PORT}
|
MONGO_PORT=${MONGO_PORT}
|
||||||
|
|
||||||
# Password for MongoDB admin user. Used for service authentication.
|
# Password for MongoDB admin user. Used for service authentication.
|
||||||
# Default: MONGO_PASSWORD=openIM123
|
# Default: MONGO_PASSWORD=openIM123
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ Welcome to the OpenIM Documentation hub! This center provides a comprehensive ra
|
|||||||
1. [Contrib](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib) - Guidance on contributing and configurations for developers
|
1. [Contrib](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib) - Guidance on contributing and configurations for developers
|
||||||
2. [Conversions](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib) - Coding conventions, logging policies, and other transformation tools
|
2. [Conversions](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib) - Coding conventions, logging policies, and other transformation tools
|
||||||
|
|
||||||
------
|
|
||||||
|
|
||||||
## Contrib
|
## Contrib
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
@@ -305,13 +305,14 @@ Feel free to explore the MinIO documentation for more advanced configurations an
|
|||||||
|
|
||||||
This section involves setting up MongoDB, including its port, address, and credentials.
|
This section involves setting up MongoDB, including its port, address, and credentials.
|
||||||
|
|
||||||
|
|
||||||
| Parameter | Example Value | Description |
|
| Parameter | Example Value | Description |
|
||||||
| -------------- | -------------- | ----------------------- |
|
| -------------- | -------------- | ----------------------- |
|
||||||
| MONGO_PORT | "27017" | Port used by MongoDB. |
|
| MONGO_PORT | "27017" | Port used by MongoDB. |
|
||||||
| MONGO_ADDRESS | [Generated IP] | IP address for MongoDB. |
|
| MONGO_ADDRESS | [Generated IP] | IP address for MongoDB. |
|
||||||
| MONGO_USERNAME | [User Defined] | Admin Username for MongoDB. |
|
| MONGO_USERNAME | [User Defined] | Admin Username for MongoDB. |
|
||||||
| MONGO_PASSWORD | [User Defined] | Admin Password for MongoDB. |
|
| MONGO_PASSWORD | [User Defined] | Admin Password for MongoDB. |
|
||||||
| MONGO_OPENIM_PASSWORD | [User Defined] | OpenIM Username for MongoDB. |
|
| MONGO_OPENIM_USERNAME | [User Defined] | OpenIM Username for MongoDB. |
|
||||||
| MONGO_OPENIM_PASSWORD | [User Defined] | OpenIM Password for MongoDB. |
|
| MONGO_OPENIM_PASSWORD | [User Defined] | OpenIM Password for MongoDB. |
|
||||||
|
|
||||||
### 2.8. <a name='TencentCloudCOSConfiguration'></a>Tencent Cloud COS Configuration
|
### 2.8. <a name='TencentCloudCOSConfiguration'></a>Tencent Cloud COS Configuration
|
||||||
@@ -477,12 +478,6 @@ This section involves setting up additional configuration variables for Websocke
|
|||||||
| JPNS_MASTER_SECRET | [User Defined] | JPNS Master Secret |
|
| JPNS_MASTER_SECRET | [User Defined] | JPNS Master Secret |
|
||||||
| JPNS_PUSH_URL | [User Defined] | JPNS Push Notification URL |
|
| JPNS_PUSH_URL | [User Defined] | JPNS Push Notification URL |
|
||||||
| JPNS_PUSH_INTENT | [User Defined] | JPNS Push Intent |
|
| JPNS_PUSH_INTENT | [User Defined] | JPNS Push Intent |
|
||||||
| MANAGER_USERID_1 | "openIM123456" | Administrator ID 1 |
|
|
||||||
| MANAGER_USERID_2 | "openIM654321" | Administrator ID 2 |
|
|
||||||
| MANAGER_USERID_3 | "openIMAdmin" | Administrator ID 3 |
|
|
||||||
| NICKNAME_1 | "system1" | Nickname 1 |
|
|
||||||
| NICKNAME_2 | "system2" | Nickname 2 |
|
|
||||||
| NICKNAME_3 | "system3" | Nickname 3 |
|
|
||||||
| IM_ADMIN_USERID | "imAdmin" | IM Administrator ID |
|
| IM_ADMIN_USERID | "imAdmin" | IM Administrator ID |
|
||||||
| IM_ADMIN_NAME | "imAdmin" | IM Administrator Nickname |
|
| IM_ADMIN_NAME | "imAdmin" | IM Administrator Nickname |
|
||||||
| MULTILOGIN_POLICY | "1" | Multi-login Policy |
|
| MULTILOGIN_POLICY | "1" | Multi-login Policy |
|
||||||
|
|||||||
@@ -45,60 +45,6 @@ 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
|
|
||||||
|
|
||||||
To optimize and add logic to your instructions, particularly regarding deploying on a Mac, you can modify them as follows:
|
|
||||||
|
|
||||||
1. **Fork the OpenIM Repository**: Fork the OpenIM repository on GitHub to your account.
|
|
||||||
|
|
||||||
2. **Clone Your Fork to Your Local Machine**:
|
|
||||||
Open your terminal and execute the following commands:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# Clone the repository
|
|
||||||
git clone https://github.com/<your-username>/open-im-server.git
|
|
||||||
|
|
||||||
# Set Docker bridging network mode for Mac
|
|
||||||
export DOCKER_BRIDGE_SUBNET=127.0.0.0/16
|
|
||||||
|
|
||||||
# Set OpenIM IP
|
|
||||||
export OPENIM_IP=<your-ip>
|
|
||||||
|
|
||||||
# Initialize configuration
|
|
||||||
make init
|
|
||||||
|
|
||||||
# Start components using Docker
|
|
||||||
docker compose up -d
|
|
||||||
|
|
||||||
# Start OpenIM Server
|
|
||||||
make start
|
|
||||||
```
|
|
||||||
|
|
||||||
3. **Additional Steps for Mac Deployment**:
|
|
||||||
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:
|
|
||||||
|
|
||||||
- Open the `docker-compose.yml` file in a text editor.
|
|
||||||
- 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**:
|
|
||||||
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:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# Update and restart services
|
|
||||||
docker compose up -d
|
|
||||||
|
|
||||||
# Check openim-chat start
|
|
||||||
docker compose logs openim-chat
|
|
||||||
```
|
|
||||||
|
|
||||||
This command will re-read the `docker-compose.yml` file, apply the new configuration, and restart the necessary containers.
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
### Setting Up the Devcontainer
|
### Setting Up the Devcontainer
|
||||||
|
|
||||||
`Devcontainers` provide a Docker-based isolated development environment.
|
`Devcontainers` provide a Docker-based isolated development environment.
|
||||||
@@ -126,6 +72,136 @@ Ensure the version of Go is compatible with the version required by OpenIM (refe
|
|||||||
|
|
||||||
Install other required tools like Docker, Vagrant, and necessary GNU utils as described in the main documentation.
|
Install other required tools like Docker, Vagrant, and necessary GNU utils as described in the main documentation.
|
||||||
|
|
||||||
|
## Mac Deployment openim-chat and 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:
|
||||||
|
|
||||||
|
### 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
|
||||||
|
```
|
||||||
|
|
||||||
|
Before deploying openim-server, modify the Kafka logic in the docker-compose.yml file. Replace:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092,EXTERNAL://${DOCKER_BRIDGE_GATEWAY:-172.28.0.1}:${KAFKA_PORT:-19094}
|
||||||
|
```
|
||||||
|
|
||||||
|
With:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092,EXTERNAL://127.0.0.1:${KAFKA_PORT:-19094}
|
||||||
|
```
|
||||||
|
|
||||||
|
Then start the service:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
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:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make start
|
||||||
|
```
|
||||||
|
|
||||||
|
To check the startup:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make check
|
||||||
|
```
|
||||||
|
|
||||||
|
<aside>
|
||||||
|
🚧 To avoid mishaps, it's best to wait five minutes before running `make check` again.
|
||||||
|
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
#### Deploying openim-chat
|
||||||
|
|
||||||
|
There are several ways to deploy openim-chat, either by source code or using Docker.
|
||||||
|
|
||||||
|
Navigate back to the parent directory:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd ..
|
||||||
|
```
|
||||||
|
|
||||||
|
First, let's look at deploying chat from source:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/openimsdk/chat
|
||||||
|
cd chat
|
||||||
|
make init # Generates configuration files
|
||||||
|
```
|
||||||
|
|
||||||
|
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
|
||||||
|
```
|
||||||
|
|
||||||
|
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`:
|
||||||
|
|
||||||
|
```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
|
||||||
|
|
||||||
### Creating a New Branch
|
### Creating a New Branch
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
# OpenIM Offline Deployment Design
|
# OpenIM Offline Deployment Design
|
||||||
|
|
||||||
## 1. Base Images
|
## 1. Base Images
|
||||||
@@ -10,7 +8,7 @@ Below are the base images and their versions you'll need:
|
|||||||
- [ ] redis:7.0.0
|
- [ ] redis:7.0.0
|
||||||
- [ ] mongo:6.0.2
|
- [ ] mongo:6.0.2
|
||||||
- [ ] bitnami/zookeeper:3.8
|
- [ ] bitnami/zookeeper:3.8
|
||||||
- [ ] minio/minio:latest
|
- [ ] minio/minio:RELEASE.2024-01-11T07-46-16Z
|
||||||
|
|
||||||
> [!IMPORTANT]
|
> [!IMPORTANT]
|
||||||
> It is important to note that OpenIM removed mysql components from versions v3.5.0 (release-v3.5) and above, so mysql can be deployed without this requirement or above
|
> It is important to note that OpenIM removed mysql components from versions v3.5.0 (release-v3.5) and above, so mysql can be deployed without this requirement or above
|
||||||
@@ -22,10 +20,10 @@ OpenIM:
|
|||||||
> [!TIP]
|
> [!TIP]
|
||||||
> If you need to install more IM components or monitoring products [images.md](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/images.md)
|
> If you need to install more IM components or monitoring products [images.md](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/images.md)
|
||||||
|
|
||||||
- [ ] ghcr.io/openimsdk/openim-web:latest
|
- [ ] ghcr.io/openimsdk/openim-web:<version-name>
|
||||||
- [ ] ghcr.io/openimsdk/openim-admin:latest
|
- [ ] ghcr.io/openimsdk/openim-admin:<version-name>
|
||||||
- [ ] ghcr.io/openimsdk/openim-chat:latest
|
- [ ] ghcr.io/openimsdk/openim-chat:<version-name>
|
||||||
- [ ] ghcr.io/openimsdk/openim-server:latest
|
- [ ] ghcr.io/openimsdk/openim-server:<version-name>
|
||||||
|
|
||||||
|
|
||||||
Monitoring:
|
Monitoring:
|
||||||
@@ -42,9 +40,9 @@ Use the following commands to pull these base images:
|
|||||||
docker pull bitnami/kafka:3.5.1
|
docker pull bitnami/kafka:3.5.1
|
||||||
docker pull redis:7.0.0
|
docker pull redis:7.0.0
|
||||||
docker pull mongo:6.0.2
|
docker pull mongo:6.0.2
|
||||||
docker pull mysql:5.7
|
docker pull mariadb:10.6
|
||||||
docker pull bitnami/zookeeper:3.8
|
docker pull bitnami/zookeeper:3.8
|
||||||
docker pull minio/minio:latest
|
docker pull minio/minio:2024-01-11T07-46-16Z
|
||||||
```
|
```
|
||||||
|
|
||||||
If you need to install more IM components or monitoring products:
|
If you need to install more IM components or monitoring products:
|
||||||
|
|||||||
33
docs/contributing/CONTRIBUTING-JP.md
Normal file
33
docs/contributing/CONTRIBUTING-JP.md
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# How do I contribute code to OpenIM
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="./CONTRIBUTING.md">Englist</a> ·
|
||||||
|
<a href="./CONTRIBUTING-zh_CN.md">中文</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-UA.md">Українська</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-CS.md">Česky</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-HU.md">Magyar</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-ES.md">Español</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-FA.md">فارسی</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-FR.md">Français</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-DE.md">Deutsch</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-PL.md">Polski</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-ID.md">Indonesian</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-FI.md">Suomi</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-ML.md">മലയാളം</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-JP.md">日本語</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-NL.md">Nederlands</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-IT.md">Italiano</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-RU.md">Русский</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-PTBR.md">Português (Brasil)</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-EO.md">Esperanto</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-KR.md">한국어</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-AR.md">العربي</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-VN.md">Tiếng Việt</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-DA.md">Dansk</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-GR.md">Ελληνικά</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-TR.md">Türkçe</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</p>
|
||||||
33
docs/contributing/CONTRIBUTING-PL.md
Normal file
33
docs/contributing/CONTRIBUTING-PL.md
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# How do I contribute code to OpenIM
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="./CONTRIBUTING.md">Englist</a> ·
|
||||||
|
<a href="./CONTRIBUTING-zh_CN.md">中文</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-UA.md">Українська</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-CS.md">Česky</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-HU.md">Magyar</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-ES.md">Español</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-FA.md">فارسی</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-FR.md">Français</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-DE.md">Deutsch</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-PL.md">Polski</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-ID.md">Indonesian</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-FI.md">Suomi</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-ML.md">മലയാളം</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-JP.md">日本語</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-NL.md">Nederlands</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-IT.md">Italiano</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-RU.md">Русский</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-PTBR.md">Português (Brasil)</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-EO.md">Esperanto</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-KR.md">한국어</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-AR.md">العربي</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-VN.md">Tiếng Việt</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-DA.md">Dansk</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-GR.md">Ελληνικά</a> ·
|
||||||
|
<a href="docs/contributing/CONTRIBUTING-TR.md">Türkçe</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</p>
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 21 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 9.9 KiB |
BIN
docs/images/architecture-layers.png
Normal file
BIN
docs/images/architecture-layers.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 286 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 61 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 57 KiB |
7
docs/readme/README-UA.md
Normal file
7
docs/readme/README-UA.md
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<p align="center">
|
||||||
|
<a href="https://openim.io">
|
||||||
|
<img src="./assets/logo-gif/openim-logo.gif" width="60%" height="30%"/>
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
17
go.mod
17
go.mod
@@ -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.33
|
||||||
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
|
||||||
@@ -31,16 +31,16 @@ require (
|
|||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
)
|
)
|
||||||
|
|
||||||
require github.com/google/uuid v1.3.1
|
require github.com/google/uuid v1.5.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/IBM/sarama v1.41.3
|
github.com/IBM/sarama v1.41.3
|
||||||
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
|
|
||||||
golang.org/x/sync v0.4.0
|
golang.org/x/sync v0.4.0
|
||||||
gopkg.in/src-d/go-git.v4 v4.13.1
|
gopkg.in/src-d/go-git.v4 v4.13.1
|
||||||
gotest.tools v2.2.0+incompatible
|
gotest.tools v2.2.0+incompatible
|
||||||
@@ -93,8 +93,8 @@ require (
|
|||||||
github.com/jinzhu/now v1.1.5 // indirect
|
github.com/jinzhu/now v1.1.5 // indirect
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd // indirect
|
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd // indirect
|
||||||
github.com/klauspost/compress v1.16.7 // indirect
|
github.com/klauspost/compress v1.17.4 // indirect
|
||||||
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
|
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
|
||||||
github.com/leodido/go-urn v1.2.4 // indirect
|
github.com/leodido/go-urn v1.2.4 // indirect
|
||||||
github.com/lithammer/shortuuid v3.0.0+incompatible // indirect
|
github.com/lithammer/shortuuid v3.0.0+incompatible // indirect
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
|
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
|
||||||
@@ -116,7 +116,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
|
||||||
@@ -127,9 +126,9 @@ require (
|
|||||||
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
|
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
|
||||||
go.opencensus.io v0.24.0 // indirect
|
go.opencensus.io v0.24.0 // indirect
|
||||||
go.uber.org/atomic v1.7.0 // indirect
|
go.uber.org/atomic v1.7.0 // indirect
|
||||||
go.uber.org/multierr v1.6.0 // indirect
|
go.uber.org/multierr v1.11.0 // indirect
|
||||||
golang.org/x/arch v0.3.0 // indirect
|
golang.org/x/arch v0.3.0 // indirect
|
||||||
golang.org/x/net v0.17.0 // indirect
|
golang.org/x/net v0.19.0 // indirect
|
||||||
golang.org/x/oauth2 v0.13.0 // indirect
|
golang.org/x/oauth2 v0.13.0 // indirect
|
||||||
golang.org/x/sys v0.15.0 // indirect
|
golang.org/x/sys v0.15.0 // indirect
|
||||||
golang.org/x/text v0.14.0 // indirect
|
golang.org/x/text v0.14.0 // indirect
|
||||||
@@ -141,7 +140,7 @@ require (
|
|||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231012201019-e917dd12ba7a // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20231012201019-e917dd12ba7a // indirect
|
||||||
gopkg.in/src-d/go-billy.v4 v4.3.2 // indirect
|
gopkg.in/src-d/go-billy.v4 v4.3.2 // indirect
|
||||||
gopkg.in/warnings.v0 v0.1.2 // indirect
|
gopkg.in/warnings.v0 v0.1.2 // indirect
|
||||||
gorm.io/gorm v1.23.8 // indirect
|
gorm.io/gorm v1.25.4 // indirect
|
||||||
stathat.com/c/consistent v1.0.0 // indirect
|
stathat.com/c/consistent v1.0.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
36
go.sum
36
go.sum
@@ -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.33 h1:rvFCxXaXxLv1MJFC4qcoWRGwKBnV+hR68UN2N0/zZhE=
|
||||||
|
github.com/OpenIMSDK/tools v0.0.33/go.mod h1:wBfR5CYmEyvxl03QJbTkhz1CluK6J4/lX0lviu8JAjE=
|
||||||
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=
|
||||||
@@ -152,8 +152,8 @@ github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o=
|
|||||||
github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw=
|
github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw=
|
||||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
|
github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=
|
||||||
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/googleapis/enterprise-certificate-proxy v0.3.1 h1:SBWmZhjUDRorQxrN0nwzf+AHBxnbFjViHQS4P0yVpmQ=
|
github.com/googleapis/enterprise-certificate-proxy v0.3.1 h1:SBWmZhjUDRorQxrN0nwzf+AHBxnbFjViHQS4P0yVpmQ=
|
||||||
github.com/googleapis/enterprise-certificate-proxy v0.3.1/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0=
|
github.com/googleapis/enterprise-certificate-proxy v0.3.1/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0=
|
||||||
github.com/googleapis/gax-go/v2 v2.12.0 h1:A+gCJKdRfqXkr+BIRGtZLibNXf0m1f9E4HG56etFpas=
|
github.com/googleapis/gax-go/v2 v2.12.0 h1:A+gCJKdRfqXkr+BIRGtZLibNXf0m1f9E4HG56etFpas=
|
||||||
@@ -194,7 +194,6 @@ github.com/jinzhu/copier v0.3.5 h1:GlvfUwHk62RokgqVNvYsku0TATCF7bAHVwEXoBh3iJg=
|
|||||||
github.com/jinzhu/copier v0.3.5/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
|
github.com/jinzhu/copier v0.3.5/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
|
||||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||||
github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
|
||||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||||
github.com/jonboulle/clockwork v0.4.0 h1:p4Cf1aMWXnXAUh8lVfewRBx1zaTSYKrKMF2g3ST4RZ4=
|
github.com/jonboulle/clockwork v0.4.0 h1:p4Cf1aMWXnXAUh8lVfewRBx1zaTSYKrKMF2g3ST4RZ4=
|
||||||
@@ -205,12 +204,12 @@ github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT
|
|||||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
||||||
github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I=
|
github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4=
|
||||||
github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
|
github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
|
||||||
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||||
github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg=
|
github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc=
|
||||||
github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
@@ -278,7 +277,6 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
|||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
|
|
||||||
github.com/prometheus/client_golang v1.17.0 h1:rl2sfwZMtSthVU752MqfjQozy7blglC+1SOtjMAMh+Q=
|
github.com/prometheus/client_golang v1.17.0 h1:rl2sfwZMtSthVU752MqfjQozy7blglC+1SOtjMAMh+Q=
|
||||||
github.com/prometheus/client_golang v1.17.0/go.mod h1:VeL+gMmOAxkS2IqfCq0ZmHSL+LjWfWDUmp1mBz9JgUY=
|
github.com/prometheus/client_golang v1.17.0/go.mod h1:VeL+gMmOAxkS2IqfCq0ZmHSL+LjWfWDUmp1mBz9JgUY=
|
||||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
@@ -353,11 +351,9 @@ go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
|
|||||||
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
|
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
|
||||||
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
|
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
|
||||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||||
go.uber.org/automaxprocs v1.5.3 h1:kWazyxZUrS3Gs4qUpbwo5kEIMGe/DAvi5Z4tl2NW4j8=
|
|
||||||
go.uber.org/automaxprocs v1.5.3/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0=
|
|
||||||
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
|
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
|
||||||
go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=
|
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||||
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||||
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
|
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
|
||||||
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
|
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
|
||||||
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
||||||
@@ -402,8 +398,8 @@ golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qx
|
|||||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
|
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
|
||||||
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.13.0 h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY=
|
golang.org/x/oauth2 v0.13.0 h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY=
|
||||||
golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0=
|
golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0=
|
||||||
@@ -531,8 +527,8 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
|||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gorm.io/gorm v1.23.8 h1:h8sGJ+biDgBA1AD1Ha9gFCx7h8npU7AsLdlkX0n2TpE=
|
gorm.io/gorm v1.25.4 h1:iyNd8fNAe8W9dvtlgeRI5zSVZPsq3OpcTu37cYcpCmw=
|
||||||
gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
|
gorm.io/gorm v1.25.4/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
|
||||||
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
|
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
|
||||||
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
|
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
|
||||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
@@ -43,7 +44,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.UniversalClient) *gin.Engine {
|
func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.UniversalClient) *gin.Engine {
|
||||||
discov.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials())) // 默认RPC中间件
|
discov.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, "round_robin"))) // 默认RPC中间件
|
||||||
gin.SetMode(gin.ReleaseMode)
|
gin.SetMode(gin.ReleaseMode)
|
||||||
r := gin.New()
|
r := gin.New()
|
||||||
if v, ok := binding.Validator.Engine().(*validator.Validate); ok {
|
if v, ok := binding.Validator.Engine().(*validator.Validate); ok {
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|||||||
@@ -15,12 +15,15 @@
|
|||||||
package msgtransfer
|
package msgtransfer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/tools/mw"
|
"github.com/OpenIMSDK/tools/mw"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/prometheus/client_golang/prometheus/collectors"
|
"github.com/prometheus/client_golang/prometheus/collectors"
|
||||||
@@ -66,43 +69,50 @@ func StartTransfer(prometheusPort int) error {
|
|||||||
if err := client.CreateRpcRootNodes(config.Config.GetServiceNames()); err != nil {
|
if err := client.CreateRpcRootNodes(config.Config.GetServiceNames()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
client.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
client.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, "round_robin")))
|
||||||
msgModel := cache.NewMsgCacheModel(rdb)
|
msgModel := cache.NewMsgCacheModel(rdb)
|
||||||
msgDocModel := unrelation.NewMsgMongoDriver(mongo.GetDatabase())
|
msgDocModel := unrelation.NewMsgMongoDriver(mongo.GetDatabase())
|
||||||
msgDatabase := controller.NewCommonMsgDatabase(msgDocModel, msgModel)
|
msgDatabase, err := controller.NewCommonMsgDatabase(msgDocModel, msgModel)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
conversationRpcClient := rpcclient.NewConversationRpcClient(client)
|
conversationRpcClient := rpcclient.NewConversationRpcClient(client)
|
||||||
groupRpcClient := rpcclient.NewGroupRpcClient(client)
|
groupRpcClient := rpcclient.NewGroupRpcClient(client)
|
||||||
msgTransfer := NewMsgTransfer(msgDatabase, &conversationRpcClient, &groupRpcClient)
|
msgTransfer, err := NewMsgTransfer(msgDatabase, &conversationRpcClient, &groupRpcClient)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return msgTransfer.Start(prometheusPort)
|
return msgTransfer.Start(prometheusPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMsgTransfer(msgDatabase controller.CommonMsgDatabase, conversationRpcClient *rpcclient.ConversationRpcClient, groupRpcClient *rpcclient.GroupRpcClient) *MsgTransfer {
|
func NewMsgTransfer(msgDatabase controller.CommonMsgDatabase, conversationRpcClient *rpcclient.ConversationRpcClient, groupRpcClient *rpcclient.GroupRpcClient) (*MsgTransfer, error) {
|
||||||
return &MsgTransfer{
|
historyCH, err := NewOnlineHistoryRedisConsumerHandler(msgDatabase, conversationRpcClient, groupRpcClient)
|
||||||
historyCH: NewOnlineHistoryRedisConsumerHandler(msgDatabase, conversationRpcClient, groupRpcClient),
|
if err != nil {
|
||||||
historyMongoCH: NewOnlineHistoryMongoConsumerHandler(msgDatabase),
|
return nil, err
|
||||||
}
|
}
|
||||||
|
historyMongoCH, err := NewOnlineHistoryMongoConsumerHandler(msgDatabase)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &MsgTransfer{
|
||||||
|
historyCH: historyCH,
|
||||||
|
historyMongoCH: historyMongoCH,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MsgTransfer) Start(prometheusPort int) error {
|
func (m *MsgTransfer) Start(prometheusPort int) error {
|
||||||
|
ctx := context.Background()
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
fmt.Println("start msg transfer", "prometheusPort:", prometheusPort)
|
fmt.Println("start msg transfer", "prometheusPort:", prometheusPort)
|
||||||
if prometheusPort <= 0 {
|
if prometheusPort <= 0 {
|
||||||
return errors.New("prometheusPort not correct")
|
return errs.Wrap(errors.New("prometheusPort not correct"))
|
||||||
}
|
}
|
||||||
if config.Config.ChatPersistenceMysql {
|
|
||||||
// go m.persistentCH.persistentConsumerGroup.RegisterHandleAndConsumer(m.persistentCH)
|
go m.historyCH.historyConsumerGroup.RegisterHandleAndConsumer(ctx, m.historyCH)
|
||||||
} else {
|
go m.historyMongoCH.historyConsumerGroup.RegisterHandleAndConsumer(ctx, m.historyMongoCH)
|
||||||
fmt.Println("msg transfer not start mysql consumer")
|
|
||||||
}
|
|
||||||
go m.historyCH.historyConsumerGroup.RegisterHandleAndConsumer(m.historyCH)
|
|
||||||
go m.historyMongoCH.historyConsumerGroup.RegisterHandleAndConsumer(m.historyMongoCH)
|
|
||||||
// go m.modifyCH.modifyMsgConsumerGroup.RegisterHandleAndConsumer(m.modifyCH)
|
|
||||||
/*err := prome.StartPrometheusSrv(prometheusPort)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}*/
|
|
||||||
////////////////////////////
|
|
||||||
if config.Config.Prometheus.Enable {
|
if config.Config.Prometheus.Enable {
|
||||||
reg := prometheus.NewRegistry()
|
reg := prometheus.NewRegistry()
|
||||||
reg.MustRegister(
|
reg.MustRegister(
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ func NewOnlineHistoryRedisConsumerHandler(
|
|||||||
database controller.CommonMsgDatabase,
|
database controller.CommonMsgDatabase,
|
||||||
conversationRpcClient *rpcclient.ConversationRpcClient,
|
conversationRpcClient *rpcclient.ConversationRpcClient,
|
||||||
groupRpcClient *rpcclient.GroupRpcClient,
|
groupRpcClient *rpcclient.GroupRpcClient,
|
||||||
) *OnlineHistoryRedisConsumerHandler {
|
) (*OnlineHistoryRedisConsumerHandler, error) {
|
||||||
var och OnlineHistoryRedisConsumerHandler
|
var och OnlineHistoryRedisConsumerHandler
|
||||||
och.msgDatabase = database
|
och.msgDatabase = database
|
||||||
och.msgDistributionCh = make(chan Cmd2Value) // no buffer channel
|
och.msgDistributionCh = make(chan Cmd2Value) // no buffer channel
|
||||||
@@ -98,14 +98,15 @@ func NewOnlineHistoryRedisConsumerHandler(
|
|||||||
}
|
}
|
||||||
och.conversationRpcClient = conversationRpcClient
|
och.conversationRpcClient = conversationRpcClient
|
||||||
och.groupRpcClient = groupRpcClient
|
och.groupRpcClient = groupRpcClient
|
||||||
och.historyConsumerGroup = kafka.NewMConsumerGroup(&kafka.MConsumerGroupConfig{
|
var err error
|
||||||
|
och.historyConsumerGroup, err = kafka.NewMConsumerGroup(&kafka.MConsumerGroupConfig{
|
||||||
KafkaVersion: sarama.V2_0_0_0,
|
KafkaVersion: sarama.V2_0_0_0,
|
||||||
OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false,
|
OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false,
|
||||||
}, []string{config.Config.Kafka.LatestMsgToRedis.Topic},
|
}, []string{config.Config.Kafka.LatestMsgToRedis.Topic},
|
||||||
config.Config.Kafka.Addr, config.Config.Kafka.ConsumerGroupID.MsgToRedis)
|
config.Config.Kafka.Addr, config.Config.Kafka.ConsumerGroupID.MsgToRedis)
|
||||||
// statistics.NewStatistics(&och.singleMsgSuccessCount, config.Config.ModuleName.MsgTransferName, fmt.Sprintf("%d
|
// statistics.NewStatistics(&och.singleMsgSuccessCount, config.Config.ModuleName.MsgTransferName, fmt.Sprintf("%d
|
||||||
// second singleMsgCount insert to mongo", constant.StatisticsTimeInterval), constant.StatisticsTimeInterval)
|
// second singleMsgCount insert to mongo", constant.StatisticsTimeInterval), constant.StatisticsTimeInterval)
|
||||||
return &och
|
return &och, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (och *OnlineHistoryRedisConsumerHandler) Run(channelID int) {
|
func (och *OnlineHistoryRedisConsumerHandler) Run(channelID int) {
|
||||||
|
|||||||
@@ -34,16 +34,21 @@ type OnlineHistoryMongoConsumerHandler struct {
|
|||||||
msgDatabase controller.CommonMsgDatabase
|
msgDatabase controller.CommonMsgDatabase
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewOnlineHistoryMongoConsumerHandler(database controller.CommonMsgDatabase) *OnlineHistoryMongoConsumerHandler {
|
func NewOnlineHistoryMongoConsumerHandler(database controller.CommonMsgDatabase) (*OnlineHistoryMongoConsumerHandler, error) {
|
||||||
mc := &OnlineHistoryMongoConsumerHandler{
|
historyConsumerGroup, err := kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{
|
||||||
historyConsumerGroup: kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{
|
KafkaVersion: sarama.V2_0_0_0,
|
||||||
KafkaVersion: sarama.V2_0_0_0,
|
OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false,
|
||||||
OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false,
|
}, []string{config.Config.Kafka.MsgToMongo.Topic},
|
||||||
}, []string{config.Config.Kafka.MsgToMongo.Topic},
|
config.Config.Kafka.Addr, config.Config.Kafka.ConsumerGroupID.MsgToMongo)
|
||||||
config.Config.Kafka.Addr, config.Config.Kafka.ConsumerGroupID.MsgToMongo),
|
if err != nil {
|
||||||
msgDatabase: database,
|
return nil, err
|
||||||
}
|
}
|
||||||
return mc
|
|
||||||
|
mc := &OnlineHistoryMongoConsumerHandler{
|
||||||
|
historyConsumerGroup: historyConsumerGroup,
|
||||||
|
msgDatabase: database,
|
||||||
|
}
|
||||||
|
return mc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mc *OnlineHistoryMongoConsumerHandler) handleChatWs2Mongo(
|
func (mc *OnlineHistoryMongoConsumerHandler) handleChatWs2Mongo(
|
||||||
|
|||||||
@@ -14,19 +14,24 @@
|
|||||||
|
|
||||||
package push
|
package push
|
||||||
|
|
||||||
|
import "context"
|
||||||
|
|
||||||
type Consumer struct {
|
type Consumer struct {
|
||||||
pushCh ConsumerHandler
|
pushCh ConsumerHandler
|
||||||
successCount uint64
|
successCount uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConsumer(pusher *Pusher) *Consumer {
|
func NewConsumer(pusher *Pusher) (*Consumer, error) {
|
||||||
return &Consumer{
|
c, err := NewConsumerHandler(pusher)
|
||||||
pushCh: *NewConsumerHandler(pusher),
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
return &Consumer{
|
||||||
|
pushCh: *c,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Consumer) Start() {
|
func (c *Consumer) Start() {
|
||||||
// statistics.NewStatistics(&c.successCount, config.Config.ModuleName.PushName, fmt.Sprintf("%d second push to
|
|
||||||
// msg_gateway count", constant.StatisticsTimeInterval), constant.StatisticsTimeInterval)
|
go c.pushCh.pushConsumerGroup.RegisterHandleAndConsumer(context.Background(), &c.pushCh)
|
||||||
go c.pushCh.pushConsumerGroup.RegisterHandleAndConsumer(&c.pushCh)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,15 +35,19 @@ type ConsumerHandler struct {
|
|||||||
pusher *Pusher
|
pusher *Pusher
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConsumerHandler(pusher *Pusher) *ConsumerHandler {
|
func NewConsumerHandler(pusher *Pusher) (*ConsumerHandler, error) {
|
||||||
var consumerHandler ConsumerHandler
|
var consumerHandler ConsumerHandler
|
||||||
consumerHandler.pusher = pusher
|
consumerHandler.pusher = pusher
|
||||||
consumerHandler.pushConsumerGroup = kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{
|
var err error
|
||||||
|
consumerHandler.pushConsumerGroup, err = kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{
|
||||||
KafkaVersion: sarama.V2_0_0_0,
|
KafkaVersion: sarama.V2_0_0_0,
|
||||||
OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false,
|
OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false,
|
||||||
}, []string{config.Config.Kafka.MsgToPush.Topic}, config.Config.Kafka.Addr,
|
}, []string{config.Config.Kafka.MsgToPush.Topic}, config.Config.Kafka.Addr,
|
||||||
config.Config.Kafka.ConsumerGroupID.MsgToPush)
|
config.Config.Kafka.ConsumerGroupID.MsgToPush)
|
||||||
return &consumerHandler
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &consumerHandler, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConsumerHandler) handleMs2PsChat(ctx context.Context, msg []byte) {
|
func (c *ConsumerHandler) handleMs2PsChat(ctx context.Context, msg []byte) {
|
||||||
|
|||||||
@@ -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"
|
||||||
@@ -65,9 +66,12 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
|
|||||||
pusher: pusher,
|
pusher: pusher,
|
||||||
})
|
})
|
||||||
}()
|
}()
|
||||||
|
consumer, err := NewConsumer(pusher)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
consumer := NewConsumer(pusher)
|
|
||||||
consumer.Start()
|
consumer.Start()
|
||||||
}()
|
}()
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|||||||
@@ -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"
|
||||||
@@ -117,18 +118,25 @@ func (p *Pusher) Push2User(ctx context.Context, userIDs []string, msg *sdkws.Msg
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, v := range wsResults {
|
if len(wsResults) == 0 {
|
||||||
if !v.OnlinePush && msg.SendID == v.UserID {
|
return nil
|
||||||
if err = callbackOfflinePush(ctx, userIDs, msg, &[]string{}); err != nil {
|
}
|
||||||
return err
|
onlinePushSuccUserIDSet := utils.SliceSet(utils.Filter(wsResults, func(e *msggateway.SingleMsgToUserResults) (string, bool) {
|
||||||
}
|
return e.UserID, e.OnlinePush && e.UserID != ""
|
||||||
|
}))
|
||||||
|
offlinePushUserIDList := utils.Filter(wsResults, func(e *msggateway.SingleMsgToUserResults) (string, bool) {
|
||||||
|
_, exist := onlinePushSuccUserIDSet[e.UserID]
|
||||||
|
return e.UserID, !exist && e.UserID != "" && e.UserID != msg.SendID
|
||||||
|
})
|
||||||
|
|
||||||
err = p.offlinePushMsg(ctx, msg.SendID, msg, []string{v.UserID})
|
if len(offlinePushUserIDList) > 0 {
|
||||||
if err != nil {
|
if err = callbackOfflinePush(ctx, offlinePushUserIDList, msg, &[]string{}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
err = p.offlinePushMsg(ctx, msg.SendID, msg, offlinePushUserIDList)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -143,7 +151,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 {
|
||||||
|
|
||||||
@@ -230,6 +238,9 @@ func (p *Pusher) Push2SuperGroup(ctx context.Context, groupID string, msg *sdkws
|
|||||||
if len(config.Config.Manager.UserID) > 0 {
|
if len(config.Config.Manager.UserID) > 0 {
|
||||||
ctx = mcontext.WithOpUserIDContext(ctx, config.Config.Manager.UserID[0])
|
ctx = mcontext.WithOpUserIDContext(ctx, config.Config.Manager.UserID[0])
|
||||||
}
|
}
|
||||||
|
if len(config.Config.Manager.UserID) == 0 && len(config.Config.IMAdmin.UserID) > 0 {
|
||||||
|
ctx = mcontext.WithOpUserIDContext(ctx, config.Config.IMAdmin.UserID[0])
|
||||||
|
}
|
||||||
defer func(groupID string) {
|
defer func(groupID string) {
|
||||||
if err = p.groupRpcClient.DismissGroup(ctx, groupID); err != nil {
|
if err = p.groupRpcClient.DismissGroup(ctx, groupID); err != nil {
|
||||||
log.ZError(ctx, "DismissGroup Notification clear members", err, "groupID", groupID)
|
log.ZError(ctx, "DismissGroup Notification clear members", err, "groupID", groupID)
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|||||||
@@ -111,6 +111,13 @@ func (m *msgServer) RevokeMsg(ctx context.Context, req *msg.RevokeMsgReq) (*msg.
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
revokerUserID := mcontext.GetOpUserID(ctx)
|
revokerUserID := mcontext.GetOpUserID(ctx)
|
||||||
|
var flag bool
|
||||||
|
if len(config.Config.Manager.UserID) > 0 {
|
||||||
|
flag = utils.Contain(revokerUserID, config.Config.Manager.UserID...)
|
||||||
|
}
|
||||||
|
if len(config.Config.Manager.UserID) == 0 && len(config.Config.IMAdmin.UserID) > 0 {
|
||||||
|
flag = utils.Contain(revokerUserID, config.Config.IMAdmin.UserID...)
|
||||||
|
}
|
||||||
tips := sdkws.RevokeMsgTips{
|
tips := sdkws.RevokeMsgTips{
|
||||||
RevokerUserID: revokerUserID,
|
RevokerUserID: revokerUserID,
|
||||||
ClientMsgID: msgs[0].ClientMsgID,
|
ClientMsgID: msgs[0].ClientMsgID,
|
||||||
@@ -118,7 +125,7 @@ func (m *msgServer) RevokeMsg(ctx context.Context, req *msg.RevokeMsgReq) (*msg.
|
|||||||
Seq: req.Seq,
|
Seq: req.Seq,
|
||||||
SesstionType: msgs[0].SessionType,
|
SesstionType: msgs[0].SessionType,
|
||||||
ConversationID: req.ConversationID,
|
ConversationID: req.ConversationID,
|
||||||
IsAdminRevoke: utils.Contain(revokerUserID, config.Config.Manager.UserID...),
|
IsAdminRevoke: flag,
|
||||||
}
|
}
|
||||||
var recvID string
|
var recvID string
|
||||||
if msgs[0].SessionType == constant.SuperGroupChatType {
|
if msgs[0].SessionType == constant.SuperGroupChatType {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ package msg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
pbmsg "github.com/OpenIMSDK/protocol/msg"
|
pbmsg "github.com/OpenIMSDK/protocol/msg"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,10 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
|
|||||||
userRpcClient := rpcclient.NewUserRpcClient(client)
|
userRpcClient := rpcclient.NewUserRpcClient(client)
|
||||||
groupRpcClient := rpcclient.NewGroupRpcClient(client)
|
groupRpcClient := rpcclient.NewGroupRpcClient(client)
|
||||||
friendRpcClient := rpcclient.NewFriendRpcClient(client)
|
friendRpcClient := rpcclient.NewFriendRpcClient(client)
|
||||||
msgDatabase := controller.NewCommonMsgDatabase(msgDocModel, cacheModel)
|
msgDatabase, err := controller.NewCommonMsgDatabase(msgDocModel, cacheModel)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
s := &msgServer{
|
s := &msgServer{
|
||||||
Conversation: &conversationClient,
|
Conversation: &conversationClient,
|
||||||
User: &userRpcClient,
|
User: &userRpcClient,
|
||||||
|
|||||||
@@ -51,7 +51,10 @@ type MessageRevoked struct {
|
|||||||
func (m *msgServer) messageVerification(ctx context.Context, data *msg.SendMsgReq) error {
|
func (m *msgServer) messageVerification(ctx context.Context, data *msg.SendMsgReq) error {
|
||||||
switch data.MsgData.SessionType {
|
switch data.MsgData.SessionType {
|
||||||
case constant.SingleChatType:
|
case constant.SingleChatType:
|
||||||
if utils.IsContain(data.MsgData.SendID, config.Config.Manager.UserID) {
|
if len(config.Config.Manager.UserID) > 0 && utils.IsContain(data.MsgData.SendID, config.Config.Manager.UserID) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if utils.IsContain(data.MsgData.SendID, config.Config.IMAdmin.UserID) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if data.MsgData.ContentType <= constant.NotificationEnd &&
|
if data.MsgData.ContentType <= constant.NotificationEnd &&
|
||||||
@@ -88,7 +91,10 @@ func (m *msgServer) messageVerification(ctx context.Context, data *msg.SendMsgRe
|
|||||||
if groupInfo.GroupType == constant.SuperGroup {
|
if groupInfo.GroupType == constant.SuperGroup {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if utils.IsContain(data.MsgData.SendID, config.Config.Manager.UserID) {
|
if len(config.Config.Manager.UserID) > 0 && utils.IsContain(data.MsgData.SendID, config.Config.Manager.UserID) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if utils.IsContain(data.MsgData.SendID, config.Config.IMAdmin.UserID) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if data.MsgData.ContentType <= constant.NotificationEnd &&
|
if data.MsgData.ContentType <= constant.NotificationEnd &&
|
||||||
|
|||||||
@@ -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"
|
||||||
@@ -69,12 +71,6 @@ func Start(client registry.SvcDiscoveryRegistry, server *grpc.Server) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
users := make([]*tablerelation.UserModel, 0)
|
users := make([]*tablerelation.UserModel, 0)
|
||||||
if len(config.Config.Manager.UserID) != len(config.Config.Manager.Nickname) {
|
|
||||||
return errors.New("len(config.Config.Manager.AppManagerUid) != len(config.Config.Manager.Nickname)")
|
|
||||||
}
|
|
||||||
for k, v := range config.Config.Manager.UserID {
|
|
||||||
users = append(users, &tablerelation.UserModel{UserID: v, Nickname: config.Config.Manager.Nickname[k], AppMangerLevel: constant.AppAdmin})
|
|
||||||
}
|
|
||||||
if len(config.Config.IMAdmin.UserID) != len(config.Config.IMAdmin.Nickname) {
|
if len(config.Config.IMAdmin.UserID) != len(config.Config.IMAdmin.Nickname) {
|
||||||
return errors.New("len(config.Config.AppNotificationAdmin.AppManagerUid) != len(config.Config.AppNotificationAdmin.Nickname)")
|
return errors.New("len(config.Config.AppNotificationAdmin.AppManagerUid) != len(config.Config.AppNotificationAdmin.Nickname)")
|
||||||
}
|
}
|
||||||
@@ -241,6 +237,7 @@ func (s *userServer) GetPaginationUsers(ctx context.Context, req *pbuser.GetPagi
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &pbuser.GetPaginationUsersResp{Total: int32(total), Users: convert.UsersDB2Pb(users)}, err
|
return &pbuser.GetPaginationUsersResp{Total: int32(total), Users: convert.UsersDB2Pb(users)}, err
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -387,7 +384,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 +415,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 {
|
||||||
@@ -437,10 +434,11 @@ func (s *userServer) ProcessUserCommandDelete(ctx context.Context, req *pbuser.P
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
||||||
@@ -473,6 +471,7 @@ func (s *userServer) ProcessUserCommandUpdate(ctx context.Context, req *pbuser.P
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) ProcessUserCommandGet(ctx context.Context, req *pbuser.ProcessUserCommandGetReq) (*pbuser.ProcessUserCommandGetResp, error) {
|
func (s *userServer) ProcessUserCommandGet(ctx context.Context, req *pbuser.ProcessUserCommandGetReq) (*pbuser.ProcessUserCommandGetResp, error) {
|
||||||
|
|
||||||
err := authverify.CheckAccessV3(ctx, req.UserID)
|
err := authverify.CheckAccessV3(ctx, req.UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -22,17 +22,18 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
|
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
"github.com/robfig/cron/v3"
|
"github.com/robfig/cron/v3"
|
||||||
|
|
||||||
"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"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/db/cache"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/db/cache"
|
||||||
)
|
)
|
||||||
|
|
||||||
func StartTask() error {
|
func StartTask() error {
|
||||||
fmt.Println("cron task start, config", config.Config.ChatRecordsClearTime)
|
fmt.Println("cron task start, config", config.Config.ChatRecordsClearTime)
|
||||||
|
|
||||||
msgTool, err := InitMsgTool()
|
msgTool, err := InitMsgTool()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -47,18 +48,16 @@ func StartTask() error {
|
|||||||
|
|
||||||
// register cron tasks
|
// register cron tasks
|
||||||
var crontab = cron.New()
|
var crontab = cron.New()
|
||||||
log.ZInfo(context.Background(), "start chatRecordsClearTime cron task", "cron config", config.Config.ChatRecordsClearTime)
|
fmt.Println("start chatRecordsClearTime cron task", "cron config", config.Config.ChatRecordsClearTime)
|
||||||
_, err = crontab.AddFunc(config.Config.ChatRecordsClearTime, cronWrapFunc(rdb, "cron_clear_msg_and_fix_seq", msgTool.AllConversationClearMsgAndFixSeq))
|
_, err = crontab.AddFunc(config.Config.ChatRecordsClearTime, cronWrapFunc(rdb, "cron_clear_msg_and_fix_seq", msgTool.AllConversationClearMsgAndFixSeq))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(context.Background(), "start allConversationClearMsgAndFixSeq cron failed", err)
|
return errs.Wrap(err)
|
||||||
panic(err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.ZInfo(context.Background(), "start msgDestruct cron task", "cron config", config.Config.MsgDestructTime)
|
fmt.Println("start msgDestruct cron task", "cron config", config.Config.MsgDestructTime)
|
||||||
_, err = crontab.AddFunc(config.Config.MsgDestructTime, cronWrapFunc(rdb, "cron_conversations_destruct_msgs", msgTool.ConversationsDestructMsgs))
|
_, err = crontab.AddFunc(config.Config.MsgDestructTime, cronWrapFunc(rdb, "cron_conversations_destruct_msgs", msgTool.ConversationsDestructMsgs))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(context.Background(), "start conversationsDestructMsgs cron failed", err)
|
return errs.Wrap(err)
|
||||||
panic(err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// start crontab
|
// start crontab
|
||||||
|
|||||||
@@ -79,12 +79,15 @@ func InitMsgTool() (*MsgTool, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
discov.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
discov.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, "round_robin")))
|
||||||
userDB, err := mgo.NewUserMongo(mongo.GetDatabase())
|
userDB, err := mgo.NewUserMongo(mongo.GetDatabase())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
msgDatabase := controller.InitCommonMsgDatabase(rdb, mongo.GetDatabase())
|
msgDatabase, err := controller.InitCommonMsgDatabase(rdb, mongo.GetDatabase())
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
userMongoDB := unrelation.NewUserMongoDriver(mongo.GetDatabase())
|
userMongoDB := unrelation.NewUserMongoDriver(mongo.GetDatabase())
|
||||||
ctxTx := tx.NewMongo(mongo.GetClient())
|
ctxTx := tx.NewMongo(mongo.GetClient())
|
||||||
userDatabase := controller.NewUserDatabase(
|
userDatabase := controller.NewUserDatabase(
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ func Secret() jwt.Keyfunc {
|
|||||||
|
|
||||||
func CheckAccessV3(ctx context.Context, ownerUserID string) (err error) {
|
func CheckAccessV3(ctx context.Context, ownerUserID string) (err error) {
|
||||||
opUserID := mcontext.GetOpUserID(ctx)
|
opUserID := mcontext.GetOpUserID(ctx)
|
||||||
if utils.IsContain(opUserID, config.Config.Manager.UserID) {
|
if len(config.Config.Manager.UserID) > 0 && utils.IsContain(opUserID, config.Config.Manager.UserID) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if utils.IsContain(opUserID, config.Config.IMAdmin.UserID) {
|
if utils.IsContain(opUserID, config.Config.IMAdmin.UserID) {
|
||||||
@@ -48,11 +48,12 @@ func CheckAccessV3(ctx context.Context, ownerUserID string) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func IsAppManagerUid(ctx context.Context) bool {
|
func IsAppManagerUid(ctx context.Context) bool {
|
||||||
return utils.IsContain(mcontext.GetOpUserID(ctx), config.Config.Manager.UserID) || utils.IsContain(mcontext.GetOpUserID(ctx), config.Config.IMAdmin.UserID)
|
return (len(config.Config.Manager.UserID) > 0 && utils.IsContain(mcontext.GetOpUserID(ctx), config.Config.Manager.UserID)) ||
|
||||||
|
utils.IsContain(mcontext.GetOpUserID(ctx), config.Config.IMAdmin.UserID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckAdmin(ctx context.Context) error {
|
func CheckAdmin(ctx context.Context) error {
|
||||||
if utils.IsContain(mcontext.GetOpUserID(ctx), config.Config.Manager.UserID) {
|
if len(config.Config.Manager.UserID) > 0 && utils.IsContain(mcontext.GetOpUserID(ctx), config.Config.Manager.UserID) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if utils.IsContain(mcontext.GetOpUserID(ctx), config.Config.IMAdmin.UserID) {
|
if utils.IsContain(mcontext.GetOpUserID(ctx), config.Config.IMAdmin.UserID) {
|
||||||
@@ -64,7 +65,7 @@ func CheckIMAdmin(ctx context.Context) error {
|
|||||||
if utils.IsContain(mcontext.GetOpUserID(ctx), config.Config.IMAdmin.UserID) {
|
if utils.IsContain(mcontext.GetOpUserID(ctx), config.Config.IMAdmin.UserID) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if utils.IsContain(mcontext.GetOpUserID(ctx), config.Config.Manager.UserID) {
|
if len(config.Config.Manager.UserID) > 0 && utils.IsContain(mcontext.GetOpUserID(ctx), config.Config.Manager.UserID) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return errs.ErrNoPermission.Wrap(fmt.Sprintf("user %s is not CheckIMAdmin userID", mcontext.GetOpUserID(ctx)))
|
return errs.ErrNoPermission.Wrap(fmt.Sprintf("user %s is not CheckIMAdmin userID", mcontext.GetOpUserID(ctx)))
|
||||||
@@ -75,7 +76,7 @@ func ParseRedisInterfaceToken(redisToken any) (*tokenverify.Claims, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func IsManagerUserID(opUserID string) bool {
|
func IsManagerUserID(opUserID string) bool {
|
||||||
return utils.IsContain(opUserID, config.Config.Manager.UserID) || utils.IsContain(opUserID, config.Config.IMAdmin.UserID)
|
return (len(config.Config.Manager.UserID) > 0 && utils.IsContain(opUserID, config.Config.Manager.UserID)) || utils.IsContain(opUserID, config.Config.IMAdmin.UserID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func WsVerifyToken(token, userID string, platformID int) error {
|
func WsVerifyToken(token, userID string, platformID int) error {
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import (
|
|||||||
config2 "github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
config2 "github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
_ "go.uber.org/automaxprocs"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
"github.com/OpenIMSDK/tools/log"
|
"github.com/OpenIMSDK/tools/log"
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
v3.5.0
|
3.5.1
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|
||||||
|
|||||||
7
pkg/common/db/cache/init_redis.go
vendored
7
pkg/common/db/cache/init_redis.go
vendored
@@ -49,7 +49,7 @@ func NewRedis() (redis.UniversalClient, error) {
|
|||||||
overrideConfigFromEnv()
|
overrideConfigFromEnv()
|
||||||
|
|
||||||
if len(config.Config.Redis.Address) == 0 {
|
if len(config.Config.Redis.Address) == 0 {
|
||||||
return nil, errors.New("redis address is empty")
|
return nil, errs.Wrap(errors.New("redis address is empty"))
|
||||||
}
|
}
|
||||||
specialerror.AddReplace(redis.Nil, errs.ErrRecordNotFound)
|
specialerror.AddReplace(redis.Nil, errs.ErrRecordNotFound)
|
||||||
var rdb redis.UniversalClient
|
var rdb redis.UniversalClient
|
||||||
@@ -77,9 +77,10 @@ func NewRedis() (redis.UniversalClient, error) {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
err = rdb.Ping(ctx).Err()
|
err = rdb.Ping(ctx).Err()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("redis ping %w", err)
|
uriFormat := "address:%s, username:%s, password:%s, clusterMode:%t, enablePipeline:%t"
|
||||||
|
errMsg := fmt.Sprintf(uriFormat, config.Config.Redis.Address, config.Config.Redis.Username, config.Config.Redis.Password, config.Config.Redis.ClusterMode, config.Config.Redis.EnablePipeline)
|
||||||
|
return nil, errs.Wrap(err, errMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
redisClient = rdb
|
redisClient = rdb
|
||||||
return rdb, err
|
return rdb, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,21 +126,32 @@ type CommonMsgDatabase interface {
|
|||||||
ConvertMsgsDocLen(ctx context.Context, conversationIDs []string)
|
ConvertMsgsDocLen(ctx context.Context, conversationIDs []string)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCommonMsgDatabase(msgDocModel unrelationtb.MsgDocModelInterface, cacheModel cache.MsgModel) CommonMsgDatabase {
|
func NewCommonMsgDatabase(msgDocModel unrelationtb.MsgDocModelInterface, cacheModel cache.MsgModel) (CommonMsgDatabase, error) {
|
||||||
|
producerToRedis, err := kafka.NewKafkaProducer(config.Config.Kafka.Addr, config.Config.Kafka.LatestMsgToRedis.Topic)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
producerToMongo, err := kafka.NewKafkaProducer(config.Config.Kafka.Addr, config.Config.Kafka.MsgToMongo.Topic)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
producerToPush, err := kafka.NewKafkaProducer(config.Config.Kafka.Addr, config.Config.Kafka.MsgToPush.Topic)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return &commonMsgDatabase{
|
return &commonMsgDatabase{
|
||||||
msgDocDatabase: msgDocModel,
|
msgDocDatabase: msgDocModel,
|
||||||
cache: cacheModel,
|
cache: cacheModel,
|
||||||
producer: kafka.NewKafkaProducer(config.Config.Kafka.Addr, config.Config.Kafka.LatestMsgToRedis.Topic),
|
producer: producerToRedis,
|
||||||
producerToMongo: kafka.NewKafkaProducer(config.Config.Kafka.Addr, config.Config.Kafka.MsgToMongo.Topic),
|
producerToMongo: producerToMongo,
|
||||||
producerToPush: kafka.NewKafkaProducer(config.Config.Kafka.Addr, config.Config.Kafka.MsgToPush.Topic),
|
producerToPush: producerToPush,
|
||||||
}
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitCommonMsgDatabase(rdb redis.UniversalClient, database *mongo.Database) CommonMsgDatabase {
|
func InitCommonMsgDatabase(rdb redis.UniversalClient, database *mongo.Database) (CommonMsgDatabase, error) {
|
||||||
cacheModel := cache.NewMsgCacheModel(rdb)
|
cacheModel := cache.NewMsgCacheModel(rdb)
|
||||||
msgDocModel := unrelation.NewMsgMongoDriver(database)
|
msgDocModel := unrelation.NewMsgMongoDriver(database)
|
||||||
CommonMsgDatabase := NewCommonMsgDatabase(msgDocModel, cacheModel)
|
return NewCommonMsgDatabase(msgDocModel, cacheModel)
|
||||||
return CommonMsgDatabase
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type commonMsgDatabase struct {
|
type commonMsgDatabase struct {
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
"github.com/OpenIMSDK/tools/mgoutil"
|
"github.com/OpenIMSDK/tools/mgoutil"
|
||||||
"github.com/OpenIMSDK/tools/pagination"
|
"github.com/OpenIMSDK/tools/pagination"
|
||||||
@@ -38,7 +40,7 @@ func NewConversationMongo(db *mongo.Database) (*ConversationMgo, error) {
|
|||||||
Options: options.Index().SetUnique(true),
|
Options: options.Index().SetUnique(true),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, errs.Wrap(err)
|
||||||
}
|
}
|
||||||
return &ConversationMgo{coll: coll}, nil
|
return &ConversationMgo{coll: coll}, nil
|
||||||
}
|
}
|
||||||
@@ -114,7 +116,8 @@ func (c *ConversationMgo) GetAllConversationIDs(ctx context.Context) ([]string,
|
|||||||
func (c *ConversationMgo) GetAllConversationIDsNumber(ctx context.Context) (int64, error) {
|
func (c *ConversationMgo) GetAllConversationIDsNumber(ctx context.Context) (int64, error) {
|
||||||
counts, err := mgoutil.Aggregate[int64](ctx, c.coll, []bson.M{
|
counts, err := mgoutil.Aggregate[int64](ctx, c.coll, []bson.M{
|
||||||
{"$group": bson.M{"_id": "$conversation_id"}},
|
{"$group": bson.M{"_id": "$conversation_id"}},
|
||||||
{"$project": bson.M{"_id": 0, "conversation_id": "$_id"}},
|
{"$group": bson.M{"_id": nil, "count": bson.M{"$sum": 1}}},
|
||||||
|
{"$project": bson.M{"_id": 0}},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
|
|
||||||
"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/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
@@ -36,7 +38,7 @@ func NewGroupMongo(db *mongo.Database) (relation.GroupModelInterface, error) {
|
|||||||
Options: options.Index().SetUnique(true),
|
Options: options.Index().SetUnique(true),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, errs.Wrap(err)
|
||||||
}
|
}
|
||||||
return &GroupMgo{coll: coll}, nil
|
return &GroupMgo{coll: coll}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ package mgo
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
"github.com/OpenIMSDK/tools/mgoutil"
|
"github.com/OpenIMSDK/tools/mgoutil"
|
||||||
"github.com/OpenIMSDK/tools/pagination"
|
"github.com/OpenIMSDK/tools/pagination"
|
||||||
@@ -37,7 +39,7 @@ func NewGroupMember(db *mongo.Database) (relation.GroupMemberModelInterface, err
|
|||||||
Options: options.Index().SetUnique(true),
|
Options: options.Index().SetUnique(true),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, errs.Wrap(err)
|
||||||
}
|
}
|
||||||
return &GroupMemberMgo{coll: coll}, nil
|
return &GroupMemberMgo{coll: coll}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ package mgo
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
|
|
||||||
"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/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
@@ -36,7 +38,7 @@ func NewGroupRequestMgo(db *mongo.Database) (relation.GroupRequestModelInterface
|
|||||||
Options: options.Index().SetUnique(true),
|
Options: options.Index().SetUnique(true),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, errs.Wrap(err)
|
||||||
}
|
}
|
||||||
return &GroupRequestMgo{coll: coll}, nil
|
return &GroupRequestMgo{coll: coll}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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"
|
||||||
@@ -39,7 +40,7 @@ func NewUserMongo(db *mongo.Database) (relation.UserModelInterface, error) {
|
|||||||
Options: options.Index().SetUnique(true),
|
Options: options.Index().SetUnique(true),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, errs.Wrap(err)
|
||||||
}
|
}
|
||||||
return &UserMgo{coll: coll}, nil
|
return &UserMgo{coll: coll}, nil
|
||||||
}
|
}
|
||||||
@@ -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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import (
|
|||||||
|
|
||||||
"github.com/OpenIMSDK/tools/errs"
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
"github.com/OpenIMSDK/tools/mw/specialerror"
|
"github.com/OpenIMSDK/tools/mw/specialerror"
|
||||||
"github.com/OpenIMSDK/tools/utils"
|
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/db/table/unrelation"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/db/table/unrelation"
|
||||||
@@ -56,16 +55,17 @@ func NewMongo() (*Mongo, error) {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
mongoClient, err = mongo.Connect(ctx, options.Client().ApplyURI(uri))
|
mongoClient, err = mongo.Connect(ctx, options.Client().ApplyURI(uri))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
if err = mongoClient.Ping(ctx, nil); err != nil {
|
||||||
|
return nil, errs.Wrap(err, uri)
|
||||||
|
}
|
||||||
return &Mongo{db: mongoClient}, nil
|
return &Mongo{db: mongoClient}, nil
|
||||||
}
|
}
|
||||||
if shouldRetry(err) {
|
if shouldRetry(err) {
|
||||||
fmt.Printf("Failed to connect to MongoDB, retrying: %s\n", err)
|
|
||||||
time.Sleep(time.Second) // exponential backoff could be implemented here
|
time.Sleep(time.Second) // exponential backoff could be implemented here
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, errs.Wrap(err, uri)
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildMongoURI() string {
|
func buildMongoURI() string {
|
||||||
@@ -150,7 +150,7 @@ func (m *Mongo) createMongoIndex(collection string, isUnique bool, keys ...strin
|
|||||||
|
|
||||||
_, err := indexView.CreateOne(context.Background(), index, opts)
|
_, err := indexView.CreateOne(context.Background(), index, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return utils.Wrap(err, "CreateIndex")
|
return errs.Wrap(err, "CreateIndex")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
96
pkg/common/discoveryregister/direct/directResolver.go
Normal file
96
pkg/common/discoveryregister/direct/directResolver.go
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
// 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 direct
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"math/rand"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/OpenIMSDK/tools/log"
|
||||||
|
"google.golang.org/grpc/resolver"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
slashSeparator = "/"
|
||||||
|
// EndpointSepChar is the separator char in endpoints.
|
||||||
|
EndpointSepChar = ','
|
||||||
|
|
||||||
|
subsetSize = 32
|
||||||
|
scheme = "direct"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ResolverDirect struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewResolverDirect() *ResolverDirect {
|
||||||
|
return &ResolverDirect{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rd *ResolverDirect) Build(target resolver.Target, cc resolver.ClientConn, _ resolver.BuildOptions) (
|
||||||
|
resolver.Resolver, error) {
|
||||||
|
log.ZDebug(context.Background(), "Build", "target", target)
|
||||||
|
endpoints := strings.FieldsFunc(GetEndpoints(target), func(r rune) bool {
|
||||||
|
return r == EndpointSepChar
|
||||||
|
})
|
||||||
|
endpoints = subset(endpoints, subsetSize)
|
||||||
|
addrs := make([]resolver.Address, 0, len(endpoints))
|
||||||
|
|
||||||
|
for _, val := range endpoints {
|
||||||
|
addrs = append(addrs, resolver.Address{
|
||||||
|
Addr: val,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if err := cc.UpdateState(resolver.State{
|
||||||
|
Addresses: addrs,
|
||||||
|
}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &nopResolver{cc: cc}, nil
|
||||||
|
}
|
||||||
|
func init() {
|
||||||
|
resolver.Register(&ResolverDirect{})
|
||||||
|
}
|
||||||
|
func (rd *ResolverDirect) Scheme() string {
|
||||||
|
return scheme // return your custom scheme name
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetEndpoints returns the endpoints from the given target.
|
||||||
|
func GetEndpoints(target resolver.Target) string {
|
||||||
|
return strings.Trim(target.URL.Path, slashSeparator)
|
||||||
|
}
|
||||||
|
func subset(set []string, sub int) []string {
|
||||||
|
rand.Shuffle(len(set), func(i, j int) {
|
||||||
|
set[i], set[j] = set[j], set[i]
|
||||||
|
})
|
||||||
|
if len(set) <= sub {
|
||||||
|
return set
|
||||||
|
}
|
||||||
|
|
||||||
|
return set[:sub]
|
||||||
|
}
|
||||||
|
|
||||||
|
type nopResolver struct {
|
||||||
|
cc resolver.ClientConn
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n nopResolver) ResolveNow(options resolver.ResolveNowOptions) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n nopResolver) Close() {
|
||||||
|
|
||||||
|
}
|
||||||
170
pkg/common/discoveryregister/direct/directconn.go
Normal file
170
pkg/common/discoveryregister/direct/directconn.go
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
// 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 direct
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
"google.golang.org/grpc/credentials/insecure"
|
||||||
|
|
||||||
|
config2 "github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ServiceAddresses map[string][]int
|
||||||
|
|
||||||
|
func getServiceAddresses() ServiceAddresses {
|
||||||
|
return ServiceAddresses{
|
||||||
|
config2.Config.RpcRegisterName.OpenImUserName: config2.Config.RpcPort.OpenImUserPort,
|
||||||
|
config2.Config.RpcRegisterName.OpenImFriendName: config2.Config.RpcPort.OpenImFriendPort,
|
||||||
|
config2.Config.RpcRegisterName.OpenImMsgName: config2.Config.RpcPort.OpenImMessagePort,
|
||||||
|
config2.Config.RpcRegisterName.OpenImMessageGatewayName: config2.Config.LongConnSvr.OpenImMessageGatewayPort,
|
||||||
|
config2.Config.RpcRegisterName.OpenImGroupName: config2.Config.RpcPort.OpenImGroupPort,
|
||||||
|
config2.Config.RpcRegisterName.OpenImAuthName: config2.Config.RpcPort.OpenImAuthPort,
|
||||||
|
config2.Config.RpcRegisterName.OpenImPushName: config2.Config.RpcPort.OpenImPushPort,
|
||||||
|
config2.Config.RpcRegisterName.OpenImConversationName: config2.Config.RpcPort.OpenImConversationPort,
|
||||||
|
config2.Config.RpcRegisterName.OpenImThirdName: config2.Config.RpcPort.OpenImThirdPort,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ConnDirect struct {
|
||||||
|
additionalOpts []grpc.DialOption
|
||||||
|
currentServiceAddress string
|
||||||
|
conns map[string][]*grpc.ClientConn
|
||||||
|
resolverDirect *ResolverDirect
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cd *ConnDirect) GetClientLocalConns() map[string][]*grpc.ClientConn {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cd *ConnDirect) GetUserIdHashGatewayHost(ctx context.Context, userId string) (string, error) {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cd *ConnDirect) Register(serviceName, host string, port int, opts ...grpc.DialOption) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cd *ConnDirect) UnRegister() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cd *ConnDirect) CreateRpcRootNodes(serviceNames []string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cd *ConnDirect) RegisterConf2Registry(key string, conf []byte) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cd *ConnDirect) GetConfFromRegistry(key string) ([]byte, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cd *ConnDirect) Close() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewConnDirect() (*ConnDirect, error) {
|
||||||
|
return &ConnDirect{
|
||||||
|
conns: make(map[string][]*grpc.ClientConn),
|
||||||
|
resolverDirect: NewResolverDirect(),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cd *ConnDirect) GetConns(ctx context.Context,
|
||||||
|
serviceName string, opts ...grpc.DialOption) ([]*grpc.ClientConn, error) {
|
||||||
|
|
||||||
|
if conns, exists := cd.conns[serviceName]; exists {
|
||||||
|
return conns, nil
|
||||||
|
}
|
||||||
|
ports := getServiceAddresses()[serviceName]
|
||||||
|
var connections []*grpc.ClientConn
|
||||||
|
for _, port := range ports {
|
||||||
|
conn, err := cd.dialServiceWithoutResolver(ctx, fmt.Sprintf(config2.Config.Rpc.ListenIP+":%d", port), append(cd.additionalOpts, opts...)...)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("connect to port %d failed,serviceName %s, IP %s\n", port, serviceName, config2.Config.Rpc.ListenIP)
|
||||||
|
}
|
||||||
|
connections = append(connections, conn)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(connections) == 0 {
|
||||||
|
return nil, fmt.Errorf("no connections found for service: %s", serviceName)
|
||||||
|
}
|
||||||
|
return connections, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cd *ConnDirect) GetConn(ctx context.Context, serviceName string, opts ...grpc.DialOption) (*grpc.ClientConn, error) {
|
||||||
|
// Get service addresses
|
||||||
|
addresses := getServiceAddresses()
|
||||||
|
address, ok := addresses[serviceName]
|
||||||
|
if !ok {
|
||||||
|
return nil, errs.Wrap(errors.New("unknown service name"), "serviceName", serviceName)
|
||||||
|
}
|
||||||
|
var result string
|
||||||
|
for _, addr := range address {
|
||||||
|
if result != "" {
|
||||||
|
result = result + "," + fmt.Sprintf(config2.Config.Rpc.ListenIP+":%d", addr)
|
||||||
|
} else {
|
||||||
|
result = fmt.Sprintf(config2.Config.Rpc.ListenIP+":%d", addr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Try to dial a new connection
|
||||||
|
conn, err := cd.dialService(ctx, result, append(cd.additionalOpts, opts...)...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errs.Wrap(err, "address", result)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store the new connection
|
||||||
|
cd.conns[serviceName] = append(cd.conns[serviceName], conn)
|
||||||
|
return conn, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cd *ConnDirect) GetSelfConnTarget() string {
|
||||||
|
return cd.currentServiceAddress
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cd *ConnDirect) AddOption(opts ...grpc.DialOption) {
|
||||||
|
cd.additionalOpts = append(cd.additionalOpts, opts...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cd *ConnDirect) CloseConn(conn *grpc.ClientConn) {
|
||||||
|
if conn != nil {
|
||||||
|
conn.Close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cd *ConnDirect) dialService(ctx context.Context, address string, opts ...grpc.DialOption) (*grpc.ClientConn, error) {
|
||||||
|
options := append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||||
|
conn, err := grpc.DialContext(ctx, cd.resolverDirect.Scheme()+":///"+address, options...)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return conn, nil
|
||||||
|
}
|
||||||
|
func (cd *ConnDirect) dialServiceWithoutResolver(ctx context.Context, address string, opts ...grpc.DialOption) (*grpc.ClientConn, error) {
|
||||||
|
options := append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||||
|
conn, err := grpc.DialContext(ctx, address, options...)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return conn, nil
|
||||||
|
}
|
||||||
@@ -18,6 +18,8 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/openimsdk/open-im-server/v3/pkg/common/discoveryregister/direct"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/discoveryregister/kubernetes"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/discoveryregister/kubernetes"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/discoveryregister/zookeeper"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/discoveryregister/zookeeper"
|
||||||
|
|
||||||
@@ -36,6 +38,8 @@ func NewDiscoveryRegister(envType string) (discoveryregistry.SvcDiscoveryRegistr
|
|||||||
return zookeeper.NewZookeeperDiscoveryRegister()
|
return zookeeper.NewZookeeperDiscoveryRegister()
|
||||||
case "k8s":
|
case "k8s":
|
||||||
return kubernetes.NewK8sDiscoveryRegister()
|
return kubernetes.NewK8sDiscoveryRegister()
|
||||||
|
case "direct":
|
||||||
|
return direct.NewConnDirect()
|
||||||
default:
|
default:
|
||||||
return nil, errors.New("envType not correct")
|
return nil, errors.New("envType not correct")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ func TestNewDiscoveryRegister(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{"zookeeper", false, true},
|
{"zookeeper", false, true},
|
||||||
{"k8s", false, true}, // 假设 k8s 配置也已正确设置
|
{"k8s", false, true}, // 假设 k8s 配置也已正确设置
|
||||||
|
{"direct", false, true},
|
||||||
{"invalid", true, false},
|
{"invalid", true, false},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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"
|
||||||
@@ -130,20 +132,40 @@ func getMsgGatewayHost(ctx context.Context) []string {
|
|||||||
// GetConns returns the gRPC client connections to the specified service.
|
// GetConns returns the gRPC client connections to the specified service.
|
||||||
func (cli *K8sDR) GetConns(ctx context.Context, serviceName string, opts ...grpc.DialOption) ([]*grpc.ClientConn, error) {
|
func (cli *K8sDR) GetConns(ctx context.Context, serviceName string, opts ...grpc.DialOption) ([]*grpc.ClientConn, error) {
|
||||||
|
|
||||||
|
// This conditional checks if the serviceName is not the OpenImMessageGatewayName.
|
||||||
|
// It seems to handle a special case for the OpenImMessageGateway.
|
||||||
if serviceName != config.Config.RpcRegisterName.OpenImMessageGatewayName {
|
if serviceName != config.Config.RpcRegisterName.OpenImMessageGatewayName {
|
||||||
|
// DialContext creates a client connection to the given target (serviceName) using the specified context.
|
||||||
|
// 'cli.options' are likely default or common options for all connections in this struct.
|
||||||
|
// 'opts...' allows for additional gRPC dial options to be passed and used.
|
||||||
conn, err := grpc.DialContext(ctx, serviceName, append(cli.options, opts...)...)
|
conn, err := grpc.DialContext(ctx, serviceName, append(cli.options, opts...)...)
|
||||||
|
|
||||||
|
// The function returns a slice of client connections with the new connection, or an error if occurred.
|
||||||
return []*grpc.ClientConn{conn}, err
|
return []*grpc.ClientConn{conn}, err
|
||||||
} else {
|
} else {
|
||||||
|
// This block is executed if the serviceName is OpenImMessageGatewayName.
|
||||||
|
// 'ret' will accumulate the connections to return.
|
||||||
var ret []*grpc.ClientConn
|
var ret []*grpc.ClientConn
|
||||||
|
|
||||||
|
// getMsgGatewayHost presumably retrieves hosts for the message gateway service.
|
||||||
|
// The context is passed, likely for cancellation and timeout control.
|
||||||
gatewayHosts := getMsgGatewayHost(ctx)
|
gatewayHosts := getMsgGatewayHost(ctx)
|
||||||
|
|
||||||
|
// Iterating over the retrieved gateway hosts.
|
||||||
for _, host := range gatewayHosts {
|
for _, host := range gatewayHosts {
|
||||||
|
// Establishes a connection to each host.
|
||||||
|
// Again, appending cli.options with any additional opts provided.
|
||||||
conn, err := grpc.DialContext(ctx, host, append(cli.options, opts...)...)
|
conn, err := grpc.DialContext(ctx, host, append(cli.options, opts...)...)
|
||||||
|
|
||||||
|
// If there's an error while dialing any host, the function returns immediately with the error.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
} else {
|
||||||
|
// If the connection is successful, it is added to the 'ret' slice.
|
||||||
ret = append(ret, conn)
|
ret = append(ret, conn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// After all hosts are processed, the slice of connections is returned.
|
||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -166,7 +188,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
|
||||||
|
|||||||
@@ -15,10 +15,13 @@
|
|||||||
package zookeeper
|
package zookeeper
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/tools/discoveryregistry"
|
"github.com/OpenIMSDK/tools/discoveryregistry"
|
||||||
openkeeper "github.com/OpenIMSDK/tools/discoveryregistry/zookeeper"
|
openkeeper "github.com/OpenIMSDK/tools/discoveryregistry/zookeeper"
|
||||||
"github.com/OpenIMSDK/tools/log"
|
"github.com/OpenIMSDK/tools/log"
|
||||||
@@ -33,7 +36,7 @@ func NewZookeeperDiscoveryRegister() (discoveryregistry.SvcDiscoveryRegistry, er
|
|||||||
username := getEnv("ZOOKEEPER_USERNAME", config.Config.Zookeeper.Username)
|
username := getEnv("ZOOKEEPER_USERNAME", config.Config.Zookeeper.Username)
|
||||||
password := getEnv("ZOOKEEPER_PASSWORD", config.Config.Zookeeper.Password)
|
password := getEnv("ZOOKEEPER_PASSWORD", config.Config.Zookeeper.Password)
|
||||||
|
|
||||||
return openkeeper.NewClient(
|
zk, err := openkeeper.NewClient(
|
||||||
zkAddr,
|
zkAddr,
|
||||||
schema,
|
schema,
|
||||||
openkeeper.WithFreq(time.Hour),
|
openkeeper.WithFreq(time.Hour),
|
||||||
@@ -42,6 +45,16 @@ func NewZookeeperDiscoveryRegister() (discoveryregistry.SvcDiscoveryRegistry, er
|
|||||||
openkeeper.WithTimeout(10),
|
openkeeper.WithTimeout(10),
|
||||||
openkeeper.WithLogger(log.NewZkLogger()),
|
openkeeper.WithLogger(log.NewZkLogger()),
|
||||||
)
|
)
|
||||||
|
if err != nil {
|
||||||
|
uriFormat := "address:%s, username:%s, password:%s, schema:%s."
|
||||||
|
errInfo := fmt.Sprintf(uriFormat,
|
||||||
|
config.Config.Zookeeper.ZkAddr,
|
||||||
|
config.Config.Zookeeper.Username,
|
||||||
|
config.Config.Zookeeper.Password,
|
||||||
|
config.Config.Zookeeper.Schema)
|
||||||
|
return nil, errs.Wrap(err, errInfo)
|
||||||
|
}
|
||||||
|
return zk, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// getEnv returns the value of an environment variable if it exists, otherwise it returns the fallback value.
|
// getEnv returns the value of an environment variable if it exists, otherwise it returns the fallback value.
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ package kafka
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/tools/log"
|
"github.com/OpenIMSDK/tools/log"
|
||||||
|
|
||||||
@@ -36,7 +39,7 @@ type MConsumerGroupConfig struct {
|
|||||||
IsReturnErr bool
|
IsReturnErr bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMConsumerGroup(consumerConfig *MConsumerGroupConfig, topics, addrs []string, groupID string) *MConsumerGroup {
|
func NewMConsumerGroup(consumerConfig *MConsumerGroupConfig, topics, addrs []string, groupID string) (*MConsumerGroup, error) {
|
||||||
consumerGroupConfig := sarama.NewConfig()
|
consumerGroupConfig := sarama.NewConfig()
|
||||||
consumerGroupConfig.Version = consumerConfig.KafkaVersion
|
consumerGroupConfig.Version = consumerConfig.KafkaVersion
|
||||||
consumerGroupConfig.Consumer.Offsets.Initial = consumerConfig.OffsetsInitial
|
consumerGroupConfig.Consumer.Offsets.Initial = consumerConfig.OffsetsInitial
|
||||||
@@ -49,26 +52,28 @@ func NewMConsumerGroup(consumerConfig *MConsumerGroupConfig, topics, addrs []str
|
|||||||
SetupTLSConfig(consumerGroupConfig)
|
SetupTLSConfig(consumerGroupConfig)
|
||||||
consumerGroup, err := sarama.NewConsumerGroup(addrs, groupID, consumerGroupConfig)
|
consumerGroup, err := sarama.NewConsumerGroup(addrs, groupID, consumerGroupConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err.Error())
|
return nil, errs.Wrap(err, strings.Join(topics, ","), strings.Join(addrs, ","), groupID, config.Config.Kafka.Username, config.Config.Kafka.Password)
|
||||||
}
|
}
|
||||||
return &MConsumerGroup{
|
return &MConsumerGroup{
|
||||||
consumerGroup,
|
consumerGroup,
|
||||||
groupID,
|
groupID,
|
||||||
topics,
|
topics,
|
||||||
}
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mc *MConsumerGroup) GetContextFromMsg(cMsg *sarama.ConsumerMessage) context.Context {
|
func (mc *MConsumerGroup) GetContextFromMsg(cMsg *sarama.ConsumerMessage) context.Context {
|
||||||
return GetContextWithMQHeader(cMsg.Headers)
|
return GetContextWithMQHeader(cMsg.Headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mc *MConsumerGroup) RegisterHandleAndConsumer(handler sarama.ConsumerGroupHandler) {
|
func (mc *MConsumerGroup) RegisterHandleAndConsumer(ctx context.Context, handler sarama.ConsumerGroupHandler) {
|
||||||
log.ZDebug(context.Background(), "register consumer group", "groupID", mc.groupID)
|
log.ZDebug(context.Background(), "register consumer group", "groupID", mc.groupID)
|
||||||
ctx := context.Background()
|
|
||||||
for {
|
for {
|
||||||
err := mc.ConsumerGroup.Consume(ctx, mc.topics, handler)
|
err := mc.ConsumerGroup.Consume(ctx, mc.topics, handler)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err.Error())
|
log.ZWarn(ctx, "consume err", err, "topic", mc.topics, "groupID", mc.groupID)
|
||||||
|
}
|
||||||
|
if ctx.Err() != nil {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
|
|
||||||
"github.com/IBM/sarama"
|
"github.com/IBM/sarama"
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
"github.com/OpenIMSDK/tools/log"
|
"github.com/OpenIMSDK/tools/log"
|
||||||
@@ -44,7 +46,7 @@ type Producer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewKafkaProducer initializes a new Kafka producer.
|
// NewKafkaProducer initializes a new Kafka producer.
|
||||||
func NewKafkaProducer(addr []string, topic string) *Producer {
|
func NewKafkaProducer(addr []string, topic string) (*Producer, error) {
|
||||||
p := Producer{
|
p := Producer{
|
||||||
addr: addr,
|
addr: addr,
|
||||||
topic: topic,
|
topic: topic,
|
||||||
@@ -87,17 +89,17 @@ func NewKafkaProducer(addr []string, topic string) *Producer {
|
|||||||
for i := 0; i <= maxRetry; i++ {
|
for i := 0; i <= maxRetry; i++ {
|
||||||
p.producer, err = sarama.NewSyncProducer(p.addr, p.config)
|
p.producer, err = sarama.NewSyncProducer(p.addr, p.config)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return &p
|
return &p, nil
|
||||||
}
|
}
|
||||||
time.Sleep(1 * time.Second) // Wait before retrying
|
time.Sleep(1 * time.Second) // Wait before retrying
|
||||||
}
|
}
|
||||||
|
|
||||||
// Panic if unable to create producer after retries
|
// Panic if unable to create producer after retries
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("Failed to create Kafka producer: " + err.Error())
|
return nil, errs.Wrap(errors.New("failed to create Kafka producer: " + err.Error()))
|
||||||
}
|
}
|
||||||
|
|
||||||
return &p
|
return &p, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// configureProducerAck configures the producer's acknowledgement level.
|
// configureProducerAck configures the producer's acknowledgement level.
|
||||||
|
|||||||
@@ -17,7 +17,10 @@ package startrpc
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
"log"
|
"log"
|
||||||
|
>>>>>>> upstream/main
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@@ -27,6 +30,8 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/OpenIMSDK/tools/errs"
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
@@ -43,7 +48,6 @@ import (
|
|||||||
"github.com/OpenIMSDK/tools/discoveryregistry"
|
"github.com/OpenIMSDK/tools/discoveryregistry"
|
||||||
"github.com/OpenIMSDK/tools/mw"
|
"github.com/OpenIMSDK/tools/mw"
|
||||||
"github.com/OpenIMSDK/tools/network"
|
"github.com/OpenIMSDK/tools/network"
|
||||||
"github.com/OpenIMSDK/tools/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Start rpc server.
|
// Start rpc server.
|
||||||
@@ -61,20 +65,20 @@ func Start(
|
|||||||
net.JoinHostPort(network.GetListenIP(config.Config.Rpc.ListenIP), strconv.Itoa(rpcPort)),
|
net.JoinHostPort(network.GetListenIP(config.Config.Rpc.ListenIP), strconv.Itoa(rpcPort)),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return errs.Wrap(err, network.GetListenIP(config.Config.Rpc.ListenIP), strconv.Itoa(rpcPort))
|
||||||
}
|
}
|
||||||
|
|
||||||
defer listener.Close()
|
defer listener.Close()
|
||||||
client, err := kdisc.NewDiscoveryRegister(config.Config.Envs.Discovery)
|
client, err := kdisc.NewDiscoveryRegister(config.Config.Envs.Discovery)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return utils.Wrap1(err)
|
return errs.Wrap(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer client.Close()
|
defer client.Close()
|
||||||
client.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
client.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, "round_robin")))
|
||||||
registerIP, err := network.GetRpcRegisterIP(config.Config.Rpc.RegisterIP)
|
registerIP, err := network.GetRpcRegisterIP(config.Config.Rpc.RegisterIP)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return errs.Wrap(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var reg *prometheus.Registry
|
var reg *prometheus.Registry
|
||||||
@@ -96,7 +100,7 @@ func Start(
|
|||||||
|
|
||||||
err = rpcFn(client, srv)
|
err = rpcFn(client, srv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return utils.Wrap1(err)
|
return err
|
||||||
}
|
}
|
||||||
err = client.Register(
|
err = client.Register(
|
||||||
rpcRegisterName,
|
rpcRegisterName,
|
||||||
@@ -105,7 +109,7 @@ func Start(
|
|||||||
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return utils.Wrap1(err)
|
return errs.Wrap(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var wg errgroup.Group
|
var wg errgroup.Group
|
||||||
@@ -116,14 +120,15 @@ func Start(
|
|||||||
// Create a HTTP server for prometheus.
|
// Create a HTTP server for prometheus.
|
||||||
httpServer := &http.Server{Handler: promhttp.HandlerFor(reg, promhttp.HandlerOpts{}), Addr: fmt.Sprintf("0.0.0.0:%d", prometheusPort)}
|
httpServer := &http.Server{Handler: promhttp.HandlerFor(reg, promhttp.HandlerOpts{}), Addr: fmt.Sprintf("0.0.0.0:%d", prometheusPort)}
|
||||||
if err := httpServer.ListenAndServe(); err != nil {
|
if err := httpServer.ListenAndServe(); err != nil {
|
||||||
log.Fatal("Unable to start a http server.")
|
fmt.Fprintf(os.Stderr, "\n\nexit -1: \n%+v PrometheusPort: %d \n\n", err, prometheusPort)
|
||||||
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
wg.Go(func() error {
|
wg.Go(func() error {
|
||||||
return utils.Wrap1(srv.Serve(listener))
|
return errs.Wrap(srv.Serve(listener))
|
||||||
})
|
})
|
||||||
|
|
||||||
sigs := make(chan os.Signal, 1)
|
sigs := make(chan os.Signal, 1)
|
||||||
@@ -146,7 +151,7 @@ func Start(
|
|||||||
return gerr
|
return gerr
|
||||||
|
|
||||||
case <-time.After(15 * time.Second):
|
case <-time.After(15 * time.Second):
|
||||||
return utils.Wrap1(errors.New("timeout exit"))
|
return errs.Wrap(errors.New("timeout exit"))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import (
|
|||||||
|
|
||||||
"github.com/minio/minio-go/v7"
|
"github.com/minio/minio-go/v7"
|
||||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/third"
|
"github.com/OpenIMSDK/protocol/third"
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user