Compare commits

..

22 Commits

Author SHA1 Message Date
Xinwei Xiong(cubxxw-openim) 7c343a3f62 fix: docker release v3.1.1 images optimize
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
2023-08-04 18:58:48 +08:00
Xinwei Xiong(cubxxw-openim) 60800a5ced feat: add scripts bash path
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
2023-08-04 18:20:23 +08:00
Xinwei Xiong(cubxxw-openim) c52dbee98a fix: fix env config
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
2023-08-04 16:07:44 +08:00
Xinwei Xiong(cubxxw-openim) 4147cf53b7 fix: add scripts path set
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
2023-08-04 15:40:42 +08:00
Xinwei Xiong(cubxxw-openim) 8c55ad1f02 fix: docker release v3.1.1 images optimize
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
2023-08-04 15:23:29 +08:00
Xinwei Xiong(cubxxw-openim) 22c8cd7fdb refactor: remove makefile
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
2023-08-03 22:37:07 +08:00
Xinwei Xiong(cubxxw-openim) cdd3dbc51c fix: set branch
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
2023-08-03 18:05:57 +08:00
Xinwei Xiong(cubxxw-openim) 257443e675 fix: set branch
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
2023-08-03 17:38:22 +08:00
Xinwei Xiong(cubxxw-openim) 2cd01a5fa6 feat: add sub images actions build
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
2023-08-03 17:17:45 +08:00
Xinwei Xiong(cubxxw-openim) 095bfa790e style: fix cicd actions openimci
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
2023-08-03 16:56:44 +08:00
Xinwei Xiong(cubxxw-openim) e41747c662 style: fix cicd actions openimci
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
2023-08-03 16:55:13 +08:00
Xinwei Xiong(cubxxw-openim) 73c2c44fdb fix: dockerfile fix
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
2023-08-03 16:55:13 +08:00
Xinwei Xiong(cubxxw-openim) 59e3eeb0a3 fix: docker images optimize
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
2023-08-03 16:55:11 +08:00
Xinwei Xiong(cubxxw-openim) f9f604b4b9 feat: add openim deployment build sub image
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
2023-08-03 16:54:08 +08:00
Xinwei Xiong(cubxxw-openim) c60288d163 fix: gorelease quest
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
2023-08-03 16:54:08 +08:00
Xinwei Xiong(cubxxw-openim) 809c2bd55c fix: dockerfile path
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
2023-08-03 16:54:07 +08:00
Xinwei Xiong(cubxxw-openim) 60b40b3ded fix: scripts path
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
2023-08-03 16:54:07 +08:00
Xinwei Xiong(cubxxw-openim) 8d773a5360 fix: scripts path
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
2023-08-03 16:54:06 +08:00
Xinwei Xiong(cubxxw-openim) b77c5f6ac3 fix: scripts path
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
2023-08-03 16:54:06 +08:00
Xinwei Xiong(cubxxw-openim) 6d06ae5894 feat: set github hub
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
2023-08-03 16:54:06 +08:00
Xinwei Xiong(cubxxw-openim) 62f599317a feat: set github hub
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
2023-08-03 16:54:05 +08:00
Xinwei Xiong(cubxxw-openim) 07d01d5cc6 fix: part of the make rules optimization
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
2023-08-03 16:54:05 +08:00
212 changed files with 910 additions and 2923 deletions
-14
View File
@@ -1,17 +1,3 @@
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# To get started with Dependabot version updates, you'll need to specify which # To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located. # package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options: # Please see the documentation for all configuration options:
+1 -1
View File
@@ -27,7 +27,7 @@ jobs:
steps: steps:
- name: Invite user to join our group - name: Invite user to join our group
uses: peter-evans/create-or-update-comment@v3 uses: peter-evans/create-or-update-comment@v1
with: with:
token: ${{ secrets.BOT_GITHUB_TOKEN }} token: ${{ secrets.BOT_GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }} issue-number: ${{ github.event.issue.number }}
-14
View File
@@ -1,17 +1,3 @@
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Create Tag name: Create Tag
on: on:
+1 -1
View File
@@ -23,7 +23,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Comment cherry-pick command - name: Comment cherry-pick command
uses: actions/github-script@v6 uses: actions/github-script@v5
with: with:
script: | script: |
const pr = context.payload.pull_request; const pr = context.payload.pull_request;
+1 -1
View File
@@ -23,7 +23,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout the latest code - name: Checkout the latest code
uses: actions/checkout@v3 uses: actions/checkout@v2
with: with:
token: ${{ secrets.BOT_GITHUB_TOKEN }} token: ${{ secrets.BOT_GITHUB_TOKEN }}
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
+1 -1
View File
@@ -44,7 +44,7 @@ jobs:
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Setup Golang with cache - name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v4 uses: magnetikonline/action-golang-cache@v3
with: with:
go-version: ${{ env.GO_VERSION }} go-version: ${{ env.GO_VERSION }}
@@ -1,17 +1,3 @@
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Create Branch on Tag name: Create Branch on Tag
on: on:
+1 -1
View File
@@ -27,7 +27,7 @@ jobs:
- name: Link Checker - name: Link Checker
id: lychee id: lychee
uses: lycheeverse/lychee-action@v1.8.0 uses: lycheeverse/lychee-action@v1.7.0
with: with:
# For parameter description, see https://github.com/lycheeverse/lychee#commandline-parameters # For parameter description, see https://github.com/lycheeverse/lychee#commandline-parameters
# Actions Link address -> https://github.com/lycheeverse/lychee-action # Actions Link address -> https://github.com/lycheeverse/lychee-action
+1 -15
View File
@@ -1,17 +1,3 @@
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# shamelessly copied from https://github.com/sigstore/cosign/blob/main/.github/workflows/milestone.yaml # shamelessly copied from https://github.com/sigstore/cosign/blob/main/.github/workflows/milestone.yaml
name: milestone name: milestone
@@ -39,7 +25,7 @@ jobs:
statuses: none statuses: none
steps: steps:
- uses: actions/github-script@v6 # v6 - uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6
with: with:
script: | script: |
if (!context.payload.pull_request.merged) { if (!context.payload.pull_request.merged) {
+1 -1
View File
@@ -27,7 +27,7 @@ jobs:
permissions: write-all permissions: write-all
steps: steps:
- name: Setup Node.js Environment - name: Setup Node.js Environment
uses: actions/setup-node@v3 uses: actions/setup-node@v2
with: with:
node-version: '16' node-version: '16'
- uses: actions/checkout@v3 - uses: actions/checkout@v3
+4 -4
View File
@@ -53,7 +53,7 @@ jobs:
steps: steps:
- name: Set up Go ${{ matrix.go_version }} - name: Set up Go ${{ matrix.go_version }}
uses: actions/setup-go@v4 uses: actions/setup-go@v2
with: with:
go-version: ${{ matrix.go_version }} go-version: ${{ matrix.go_version }}
id: go id: go
@@ -149,7 +149,7 @@ jobs:
continue-on-error: true continue-on-error: true
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@v1
continue-on-error: true continue-on-error: true
openim-start: openim-start:
@@ -163,13 +163,13 @@ jobs:
os: ["ubuntu-latest"] os: ["ubuntu-latest"]
steps: steps:
- name: Set up Go ${{ matrix.go_version }} - name: Set up Go ${{ matrix.go_version }}
uses: actions/setup-go@v4 uses: actions/setup-go@v2
with: with:
go-version: ${{ matrix.go_version }} go-version: ${{ matrix.go_version }}
id: go id: go
- name: Check out code into the Go module directory - name: Check out code into the Go module directory
uses: actions/checkout@v3 uses: actions/checkout@v2
- name: Run OpenIM make install start - name: Run OpenIM make install start
run: | run: |
+1 -1
View File
@@ -47,7 +47,7 @@ jobs:
git checkout -b cicd/patch-${{ github.event.number }} git checkout -b cicd/patch-${{ github.event.number }}
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
- name: Setup Go - name: Setup Go
uses: actions/setup-go@v4 uses: actions/setup-go@v2
- name: Run go modules tidy - name: Run go modules tidy
run: | run: |
sudo make tidy sudo make tidy
+2 -3
View File
@@ -43,8 +43,7 @@ jobs:
# either 'goreleaser' (default) or 'goreleaser-pro': # either 'goreleaser' (default) or 'goreleaser-pro':
distribution: goreleaser distribution: goreleaser
version: latest version: latest
workdir: . args: release --clean
args: release -f ./build/goreleaser.yaml --rm-dist --clean
env: env:
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' # Your GoReleaser Pro key, if you are using the 'goreleaser-pro'
@@ -61,7 +60,7 @@ jobs:
matrix: matrix:
format: [ deb, rpm, apk ] format: [ deb, rpm, apk ]
steps: steps:
- uses: actions/checkout@v3 # v3 - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
with: with:
fetch-depth: 0 fetch-depth: 0
- uses: arduino/setup-task@e26d8975574116b0097a1161e0fe16ba75d84c1c # v1 - uses: arduino/setup-task@e26d8975574116b0097a1161e0fe16ba75d84c1c # v1
+3 -6
View File
@@ -38,15 +38,12 @@ jobs:
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v3 uses: actions/checkout@v2
- name: Download Docker Compose
run: |
curl -o docker-compose.yaml https://gist.githubusercontent.com/cubxxw/b1d5cbd2edfa23fee911118aa3e8249e/raw/openim-server.sh
shell: bash
- name: Start Docker Compose - name: Start Docker Compose
run: | run: |
sudo docker compose stop
sudo sleep 30
sudo docker compose up -d sudo docker compose up -d
sudo sleep 60 sudo sleep 60
continue-on-error: true continue-on-error: true
+1 -1
View File
@@ -32,7 +32,7 @@ jobs:
pull-requests: write pull-requests: write
steps: steps:
- uses: actions/stale@v8 - uses: actions/stale@v5
with: with:
repo-token: ${{ secrets.BOT_GITHUB_TOKEN }} repo-token: ${{ secrets.BOT_GITHUB_TOKEN }}
days-before-stale: 60 days-before-stale: 60
+1 -1
View File
@@ -156,7 +156,7 @@ flycheck_*.el
# vendor/ # vendor/
# Go workspace file # Go workspace file
# go.work go.work
### JetBrains ### ### JetBrains ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
+5 -3
View File
@@ -16,10 +16,10 @@ RUN go mod download
# Copy all files to the container # Copy all files to the container
ADD . . ADD . .
RUN make clean RUN /bin/sh -c "make clean"
RUN make build RUN /bin/sh -c "make build"
FROM ghcr.io/openim-sigs/openim-bash-image:latest FROM ghcr.io/openim-sigs/openim-bash-image:v1.3.0
WORKDIR ${SERVER_WORKDIR} WORKDIR ${SERVER_WORKDIR}
@@ -28,4 +28,6 @@ COPY --from=builder ${OPENIM_SERVER_CMDDIR} /openim/openim-server/scripts
COPY --from=builder ${SERVER_WORKDIR}/config /openim/openim-server/config COPY --from=builder ${SERVER_WORKDIR}/config /openim/openim-server/config
COPY --from=builder ${SERVER_WORKDIR}/_output/bin/platforms /openim/openim-server/_output/bin/platforms COPY --from=builder ${SERVER_WORKDIR}/_output/bin/platforms /openim/openim-server/_output/bin/platforms
VOLUME ["/openim/openim-server/logs","/openim/openim-server/config","/openim/openim-server/scripts"]
CMD ["bash","-c","${OPENIM_SERVER_CMDDIR}/docker_start_all.sh"] CMD ["bash","-c","${OPENIM_SERVER_CMDDIR}/docker_start_all.sh"]
+1 -1
View File
@@ -12,7 +12,7 @@ all: tidy gen add-copyright format lint cover build
# Build set # Build set
ROOT_PACKAGE=github.com/OpenIMSDK/Open-IM-Server ROOT_PACKAGE=github.com/OpenIMSDK/Open-IM-Server
# TODO: This is version control for the future https://github.com/OpenIMSDK/Open-IM-Server/issues/574 # TODO: This is version control for the future
VERSION_PACKAGE=github.com/OpenIMSDK/Open-IM-Server/pkg/version VERSION_PACKAGE=github.com/OpenIMSDK/Open-IM-Server/pkg/version
# ============================================================================== # ==============================================================================
+50 -157
View File
@@ -22,109 +22,42 @@
<p align="center"> <p align="center">
<a href="./README.md"><b> English </b></a> • <a href="./README.md"><b> English </b></a> •
<a href="./README-zh_CN.md"><b> 简体中文 </b></a> <a href="./README-zh_CN.md"><b> 中文 </b></a>
<a href="https://www.openim.online/en"><b> Docs </b></a>
</p> </p>
</p> </p>
## ✨ About OpenIM ## What is Open-IM-Server
Open-IM-Server, crafted meticulously using pure Golang, stands as a robust instant messaging server. Its unique approach to communication, via JSON over WebSocket, treats every interaction as a message. This simplifies customization and eliminates the need for tinkering with server code. Harnessing the power of microservice architecture, the server can be deployed via clusters, promising impressive performance and scalability. Open-IM-Server is an instant messaging server developed using pure Golang, adopting JSON over WebSocket as the communication protocol. In Open-IM-Server, everything is a message, so you can easily extend custom messages without modifying the server code. With a microservice architecture, Open-IM-Server can be deployed using clusters. By deploying Open-IM-Server on a server, developers can quickly integrate instant messaging and real-time networking features into their applications, ensuring the security and privacy of business data.
Open-IM-Server is more than an instant messaging server; it's a powerful tool for incorporating real-time networking into your applications, positioning itself as your premier choice for integration! 🚀 Open-IM-Server is not a standalone product and does not include account registration and login services. For your convenience, we have open-sourced the [chat repository](https://github.com/OpenIMSDK/chat) which includes login and registration functionality. By deploying the chat business server alongside Open-IM-Server, a chat product can be set up.
Please be aware that Open-IM-Server does not function as a standalone product and does not offer built-in account registration or login services. To ease your implementation process, we've open-sourced the [chat repository](https://github.com/OpenIMSDK/chat), which comprises these features. Deploying this chat business server in conjunction with Open-IM-Server expedites the setup of a comprehensive chat product. 👥 ## Features
Further enhancing your experience, we also provide an SDK client, wherein most complex logics are implemented. The [SDK repository](https://github.com/OpenIMSDK/openim-sdk-core) can be found at [this link](https://github.com/OpenIMSDK/openim-sdk-core). The [chat repository](https://github.com/OpenIMSDK/chat) is our business server while the 'core' represents the high-level encapsulation of the SDK, synergistically working together to deliver superior results. ✨ - Open source
- Easy to integrate
- Excellent scalability
- High performance
- Lightweight
- Supports multiple protocols
## :star2: Why OpenIM ## Community
- Visit the official website: [OpenIM Developer Documentation](https://www.openim.online/)
**🔍 Function screenshot display** ## Quick Start
<div align="center"> ### Deploying with docker-compose
| 💻🔄📱 Multi Terminal Synchronization 🔄🖥️ | 📅⚡ Efficient Meetings 🚀💼 |
| :----------------------------------------------------------: | :---------------------------------------------------------: |
| ![multiple-message](./assets/demo/multi-terminal-synchronization.png) | ![efficient-meetings](./assets/demo/efficient-meetings.png) |
| 📲🔄 **One-to-one and Group Chats** 👥🗣️ | 🎁💻 **Special Features - Custom Messages** ✉️🎨|
| ![group-chat](./assets/demo/group-chat.png) | ![special-function](./assets/demo/special-function.png) |
</div>
1. **Comprehensive Message Type Support :speech_balloon:**
✅ Supports almost all types of messages, including text, images, emojis, voice, video, geographical location, files, quotes, business cards, system notifications, custom messages and more
✅ Supports one-on-one and multi-person audio and video calls
✅ Provides terminal support for multiple platforms such as iOS, Android, Flutter, uni-app, ReactNative, Electron, Web, H5
2. **Efficient Meetings Anytime, Anywhere :earth_americas:**
✅ Based on IM (Instant Messaging) with 100% reliable forced signaling capabilities, it paves the way for IM systems, deeply integrated with chat applications
✅ Supports hundreds of people in a single meeting, with subscription numbers reaching thousands, and server-side audio and video recording
3. **One-on-one and Group Chats for Various Social Scenarios :busts_in_silhouette:**
✅ OpenIM has four roles: application administrator, group owner, group administrator, and regular member
✅ Powerful group features such as muting, group announcements, group validation, unlimited group members, and loading group messages as needed
4. **Unique Features :star2:**
✅ Supports read-and-burn private chats, customizable duration
✅ Message editing function broadens social scenarios, making instant communication more diverse and interesting
5. **Open Source :open_hands:**
✅ The code of OpenIM is open source, self-controlled data, aimed at building a globally leading IM open source community, including client SDK and server
✅ Based on open source Server, many excellent open source projects have been developed, such as [OpenKF](https://github.com/OpenIMSDK/OpenKF) (Open source AI customer service system)
6. **Easy to Expand :wrench:**
✅ The OpenIM server is implemented in Golang, introducing an innovative "everything is a message" communication model, simplifying the implementation of custom messages and extended features
7. **High Performance :racing_car:**
✅ OpenIM supports a hierarchical governance architecture in the cluster, tested by a large number of users, and abstracts the storage model of online messages, offline messages, and historical messages
8. **Full Platform Support :tv:**
✅ Supports native iOS, Android; cross-platform Flutter, uni-app, ReactNative; major web front-end frameworks such as React, Vue; applets; and PC platforms supported by Electron
9. **The ultimate deployment experience 🤖**
✅ Supports [cluster deployment](https://github.com/OpenIMSDK/Open-IM-Server/edit/main/deployments/README.md)
✅ Supports multi-architecture mirroring, our Docker images are hosted not only on GitHub but also on Alibaba Cloud and Docker Hub supporting multiple architectures. Visit [our GitHub packages](https://github.com/orgs/OpenIMSDK/packages?repo_name=Open-IM-Server) and read our [version management document](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/version.md) for more information.
11. **A large ecosystem of open source communities 🤲**
✅ We have tens of thousands of users and many solutions to problems.
✅ We have a large open source community called [OpenIMSDK](https://github.com/OpenIMSDK) that runs the core modules, we have an open source community called [openim-sigs](https://github.com/openim-sigs) to explore more IM-based infrastructure products.
## :rocket: Quick Start
<details> <summary>Deploying with Docker Compose</summary>
1. Clone the project 1. Clone the project
```bash ```bash
# choose what you need # choose what you need
BRANCH=release-v3.1 BRANCH=release-v3.0
git clone -b $BRANCH https://github.com/OpenIMSDK/Open-IM-Server openim && export openim=$(pwd)/openim && cd $openim && make build git clone -b $BRANCH https://github.com/OpenIMSDK/Open-IM-Server openim && export openim=$(pwd)/openim && cd $openim && make build
``` ```
> **Note** 2. Modify .env
> Read our release policy: https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/version.md
2. Modify `.env`
```bash ```bash
USER=root #no need to modify USER=root #no need to modify
@@ -137,9 +70,9 @@ DATA_DIR=./ #designate large disk directory
3. Deploy and start 3. Deploy and start
> **Note** > **Note**
> This command can only be executed once. It will modify the component passwords in docker-compose based on the `PASSWORD` variable in `.env`, and modify the component passwords in `config/config.yaml`. If the password in `.env` changes, you need to first execute `docker-compose down`; `rm components -rf` and then execute this command. > This command can only be executed once. It will modify the component passwords in docker-compose based on the PASSWORD variable in .env, and modify the component passwords in config/config.yaml. If the password in .env changes, you need to first execute docker-compose down; rm components -rf and then execute this command.
```bash ```
make install make install
``` ```
@@ -151,9 +84,9 @@ make check
![https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/images/docker_build.png](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/images/docker_build.png) ![https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/images/docker_build.png](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/images/docker_build.png)
</details>
<details> <summary>Compile from Source</summary>
### Compile from source
Ur need `Go 1.18` or higher version, and `make`. Ur need `Go 1.18` or higher version, and `make`.
@@ -164,7 +97,6 @@ Version Details: https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conv
BRANCH=release-v3.1 BRANCH=release-v3.1
git clone -b $BRANCH https://github.com/OpenIMSDK/Open-IM-Server openim && export openim=$(pwd)/openim && cd $openim && make build git clone -b $BRANCH https://github.com/OpenIMSDK/Open-IM-Server openim && export openim=$(pwd)/openim && cd $openim && make build
``` ```
Read about the [OpenIM Version Policy](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/version.md) Read about the [OpenIM Version Policy](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/version.md)
`make help` to help you see the instructions supported by OpenIM. `make help` to help you see the instructions supported by OpenIM.
@@ -173,9 +105,7 @@ All services have been successfully built as shown in the figure
![Successful Compilation](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/images/build.png) ![Successful Compilation](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/images/build.png)
</details> ### Component Configuration Instructions
<details> <summary>Component Configuration Instructions</summary>
The config/config.yaml file has detailed configuration instructions for the storage components. The config/config.yaml file has detailed configuration instructions for the storage components.
@@ -183,7 +113,7 @@ The config/config.yaml file has detailed configuration instructions for the stor
- Used for RPC service discovery and registration, cluster support. - Used for RPC service discovery and registration, cluster support.
```bash ```
zookeeper: zookeeper:
schema: openim #Not recommended to modify schema: openim #Not recommended to modify
address: [ 127.0.0.1:2181 ] #address address: [ 127.0.0.1:2181 ] #address
@@ -195,7 +125,7 @@ The config/config.yaml file has detailed configuration instructions for the stor
- Used for storing users, relationships, and groups, supports master-slave database. - Used for storing users, relationships, and groups, supports master-slave database.
```bash ```
mysql: mysql:
address: [ 127.0.0.1:13306 ] #address address: [ 127.0.0.1:13306 ] #address
username: root #username username: root #username
@@ -212,7 +142,7 @@ The config/config.yaml file has detailed configuration instructions for the stor
- Used for storing offline messages, supports mongo sharded clusters. - Used for storing offline messages, supports mongo sharded clusters.
```bash ```
mongo: mongo:
uri: #Use this value directly if not empty uri: #Use this value directly if not empty
address: [ 127.0.0.1:37017 ] #address address: [ 127.0.0.1:37017 ] #address
@@ -226,7 +156,7 @@ The config/config.yaml file has detailed configuration instructions for the stor
- Used for storing message sequence numbers, latest messages, user tokens, and mysql cache, supports cluster deployment. - Used for storing message sequence numbers, latest messages, user tokens, and mysql cache, supports cluster deployment.
```bash ```
redis: redis:
address: [ 127.0.0.1:16379 ] #address address: [ 127.0.0.1:16379 ] #address
username: #username username: #username
@@ -237,7 +167,7 @@ The config/config.yaml file has detailed configuration instructions for the stor
- Used for message queues, for message decoupling, supports cluster deployment. - Used for message queues, for message decoupling, supports cluster deployment.
```bash ```
kafka: kafka:
username: #username username: #username
password: #password password: #password
@@ -258,31 +188,27 @@ The config/config.yaml file has detailed configuration instructions for the stor
msgToModify: modify msgToModify: modify
``` ```
</details> ### Start and Stop Services
<details> <summary>Start and Stop Services</summary>
Start services Start services
``` ```
./scripts/start_all.sh; ./start_all.sh;
``` ```
Check services Check services
``` ```
./scripts/check_all.sh ./check_all.sh
``` ```
Stop services Stop services
``` ```
./scripts/stop_all.sh ./stop_all.sh
``` ```
</details> ### Open IM Ports
<details> <summary>Open IM Ports</summary>
| TCP Port | Description | Operation | | TCP Port | Description | Operation |
| --------- | ------------------------------------------------------------ | ----------------------------------------------------- | | --------- | ------------------------------------------------------------ | ----------------------------------------------------- |
@@ -290,75 +216,42 @@ Stop services
| TCP:10002 | api port, such as user, friend, group, message interfaces. | Port release or nginx reverse proxy, and firewall off | | TCP:10002 | api port, such as user, friend, group, message interfaces. | Port release or nginx reverse proxy, and firewall off |
| TCP:10005 | Required when choosing minio storage (openIM uses minio storage by default) | Port release or nginx reverse proxy, and firewall off | | TCP:10005 | Required when choosing minio storage (openIM uses minio storage by default) | Port release or nginx reverse proxy, and firewall off |
</details> ### Open Chat Ports
<details> <summary>Open Chat Ports</summary>
+ chat warehouse: https://github.com/OpenIMSDK/chat
| TCP Port | Description | Operation | | TCP Port | Description | Operation |
| --------- | --------------------------------------------------- | ----------------------------------------------------- | | --------- | --------------------------------------------------- | ----------------------------------------------------- |
| TCP:10008 | Business system, such as registration, login etc | Port release or nginx reverse proxy, and firewall off | | TCP:10008 | Business system, such as registration, login etc | Port release or nginx reverse proxy, and firewall off |
| TCP:10009 | Management backend, such as statistics, banning etc | Port release or nginx reverse proxy, and firewall off | | TCP:10009 | Management backend, such as statistics, banning etc | Port release or nginx reverse proxy, and firewall off |
</details> ## Relationship Between APP and OpenIM
## :link: Relationship Between APP and OpenIM OpenIM is an open source instant messaging component, it is not an independent product. This image shows the relationship between AppServer, AppClient, Open-IM-Server and Open-IM-SDK.
OpenIM isn't just an open-source instant messaging component, it's an integral part of your application ecosystem. Check out this diagram to understand how AppServer, AppClient, Open-IM-Server, and Open-IM-SDK interact. ![https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/open-im-server.png](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/images/open-im-server.png)
![App-OpenIM Relationship](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/images/open-im-server.png) ## Overall Architecture
## :building_construction: Overall Architecture ![https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/Architecture.jpg](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/images/Architecture.jpg)
Delve into the heart of Open-IM-Server's functionality with our architecture diagram. ## To start developing OpenIM
The [community repository](https://github.com/OpenIMSDK/community) hosts all information about building Kubernetes from source, how to contribute code and documentation, who to contact about what, etc.
![Overall Architecture](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/images/Architecture.jpg)
## :hammer_and_wrench: To start developing OpenIM ## Contributing
OpenIM Our goal is to build a top-level open source community. We have a set of standards, in the [Community repository](https://github.com/OpenIMSDK/community). Contributions to this project are welcome! Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for details.
If you'd like to contribute to this Open-IM-Server repository, please read our [contributor documentation](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/CONTRIBUTING.md). ## Community Meetings
We want anyone to get involved in our community, we offer gifts and rewards, and we welcome you to join us every Thursday night.
Before you start, please make sure your changes are in demand. The best for that is to create a [new discussion](https://github.com/OpenIMSDK/Open-IM-Server/discussions/new/choose) OR [Slack Communication](https://join.slack.com/t/openimsdk/shared_invite/zt-1tmoj26uf-_FDy3dowVHBiGvLk9e5Xkg), or if you find an issue, [report it](https://github.com/OpenIMSDK/Open-IM-Server/issues/new/choose) first. We take notes of each [biweekly meeting](https://github.com/OpenIMSDK/Open-IM-Server/issues/381) in [GitHub discussions](https://github.com/OpenIMSDK/Open-IM-Server/discussions/categories/meeting), and our minutes are written in [Google Docs](https://docs.google.com/document/d/1nx8MDpuG74NASx081JcCpxPgDITNTpIIos0DS6Vr9GU/edit?usp=sharing).
- [Code Standards](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/go_code.md)
- [Docker Images Standards](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/images.md)
- [Directory Standards](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/directory.md)
- [Commit Standards](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/commit.md)
- [Versioning Standards](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/version.md)
- [Interface Standards](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/api.md)
- [Log Standards](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/log.md)
- [Error Code Standards](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/conversions/error_code.md)
## :busts_in_silhouette: Community ## Who are using Open-IM-Server
The [user case studies](https://github.com/OpenIMSDK/community/blob/main/ADOPTERS.md) page includes the user list of the project. You can leave a [📝comment](https://github.com/OpenIMSDK/Open-IM-Server/issues/379) to let us know your use case.
+ 📚 [OpenIM Community](https://github.com/OpenIMSDK/community) ![avatar](https://openim-1253691595.cos.ap-nanjing.myqcloud.com/WechatIMG20.jpeg)
+ 💕 [OpenIM Interest Group](https://github.com/Openim-sigs)
+ 🚀 [Join our Slack community](https://join.slack.com/t/openimsdk/shared_invite/zt-1tmoj26uf-_FDy3dowVHBiGvLk9e5Xkg)
+ :eyes: [Join our wechat (微信群)](https://openim-1253691595.cos.ap-nanjing.myqcloud.com/WechatIMG20.jpeg)
## :calendar: Community Meetings ## License
We want anyone to get involved in our community and contributing code, we offer gifts and rewards, and we welcome you to join us every Thursday night. Open-IM-Server is under the Apache 2.0 license. See the [LICENSE](./LICENSE) file for details
Our conference is in the [OpenIM Slack](https://join.slack.com/t/openimsdk/shared_invite/zt-1tmoj26uf-_FDy3dowVHBiGvLk9e5Xkg) 🎯, then you can search the Open-IM-Server pipeline to join
We take notes of each [biweekly meeting](https://github.com/orgs/OpenIMSDK/discussions/categories/meeting) in [GitHub discussions](https://github.com/OpenIMSDK/Open-IM-Server/discussions/categories/meeting), Our historical meeting notes, as well as replays of the meetings are available at [Google Docs :bookmark_tabs:](https://docs.google.com/document/d/1nx8MDpuG74NASx081JcCpxPgDITNTpIIos0DS6Vr9GU/edit?usp=sharing).
## :eyes: Who are using OpenIM
Check out our [user case studies](https://github.com/OpenIMSDK/community/blob/main/ADOPTERS.md) page for a list of the project users. Don't hesitate to leave a [📝comment](https://github.com/OpenIMSDK/Open-IM-Server/issues/379) and share your use case.
## :page_facing_up: License
OpenIM is licensed under the Apache 2.0 license. See [LICENSE](https://github.com/OpenIMSDK/Open-IM-Server/tree/main/LICENSE) for the full license text.
The OpenIM logo, including its variations and animated versions, displayed in this repository [OpenIM](https://github.com/OpenIMSDK/Open-IM-Server) under the [assets/logo](./assets/logo) and [assets/logo-gif](assets/logo-gif) directories, are protected by copyright laws.
## 🔮 Thanks to our contributors!
<a href="https://github.com/OpenIMSDK/Open-IM-Server/graphs/contributors">
<img src="https://contrib.rocks/image?repo=OpenIMSDK/Open-IM-Server" />
</a>
-14
View File
@@ -1,14 +0,0 @@
## :star2: Why OpenIM
**🔍 Function screenshot display**
<div align="center">
| multiple message | Efficient meetings |
| :---------------------------------------: | :---------------------------------------------: |
| ![multiple-message](./multiple-message.png) | ![efficient-meetings](./efficient-meetings.png) |
| **One-to-one and group chats** | **Special features - Custom messages** |
| ![group-chat](./group-chat.png) | ![special-function](./special-function.png) |
</div>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 418 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 931 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 318 KiB

+2 -16
View File
@@ -1,17 +1,3 @@
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# OpenIM base image: https://github.com/openim-sigs/openim-base-image # OpenIM base image: https://github.com/openim-sigs/openim-base-image
# Set go mod installation source and proxy # Set go mod installation source and proxy
@@ -34,7 +20,7 @@ COPY . .
RUN make clean RUN make clean
RUN make build BINS=openim-api RUN make build BINS=openim-api
FROM ghcr.io/openim-sigs/openim-bash-image:latest FROM ghcr.io/openim-sigs/openim-bash-image:v1.3.0
WORKDIR /openim/openim-server WORKDIR /openim/openim-server
@@ -43,4 +29,4 @@ COPY --from=builder /openim/openim-server/config /openim/openim-server/config
EXPOSE ${10002} EXPOSE ${10002}
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-api --port 10002 -c ${SERVER_WORKDIR}/config"] CMD ["sh","-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-api --port 10002 -c ${SERVER_WORKDIR}/config"]
+2 -16
View File
@@ -1,17 +1,3 @@
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# OpenIM base image: https://github.com/openim-sigs/openim-base-image # OpenIM base image: https://github.com/openim-sigs/openim-base-image
# Set go mod installation source and proxy # Set go mod installation source and proxy
@@ -35,11 +21,11 @@ RUN go mod download
RUN make clean RUN make clean
RUN make build BINS=openim-cmdutils RUN make build BINS=openim-cmdutils
FROM ghcr.io/openim-sigs/openim-bash-image:latest FROM ghcr.io/openim-sigs/openim-bash-image:v1.3.0
WORKDIR /openim/openim-server WORKDIR /openim/openim-server
COPY --from=builder ${SERVER_WORKDIR}/_output/bin/platforms /openim/openim-server/_output/bin/platforms COPY --from=builder ${SERVER_WORKDIR}/_output/bin/platforms /openim/openim-server/_output/bin/platforms
COPY --from=builder ${SERVER_WORKDIR}/config /openim/openim-server/config COPY --from=builder ${SERVER_WORKDIR}/config /openim/openim-server/config
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-cmdutils"] CMD ["sh","-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-cmdutils"]
+2 -16
View File
@@ -1,17 +1,3 @@
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# OpenIM base image: https://github.com/openim-sigs/openim-base-image # OpenIM base image: https://github.com/openim-sigs/openim-base-image
# Set go mod installation source and proxy # Set go mod installation source and proxy
@@ -34,11 +20,11 @@ COPY . .
RUN make clean RUN make clean
RUN make build BINS=openim-crontask RUN make build BINS=openim-crontask
FROM ghcr.io/openim-sigs/openim-bash-image:latest FROM ghcr.io/openim-sigs/openim-bash-image:v1.3.0
WORKDIR /openim/openim-server WORKDIR /openim/openim-server
COPY --from=builder /openim/openim-server/_output/bin/platforms /openim/openim-server/_output/bin/platforms COPY --from=builder /openim/openim-server/_output/bin/platforms /openim/openim-server/_output/bin/platforms
COPY --from=builder /openim/openim-server/config /openim/openim-server/config COPY --from=builder /openim/openim-server/config /openim/openim-server/config
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-crontask"] CMD ["sh","-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-crontask"]
+1 -15
View File
@@ -1,17 +1,3 @@
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# OpenIM base image: https://github.com/openim-sigs/openim-base-image # OpenIM base image: https://github.com/openim-sigs/openim-base-image
# Set go mod installation source and proxy # Set go mod installation source and proxy
@@ -34,7 +20,7 @@ COPY . .
RUN make clean RUN make clean
RUN make build BINS=openim-msggateway RUN make build BINS=openim-msggateway
FROM ghcr.io/openim-sigs/openim-bash-image:latest FROM ghcr.io/openim-sigs/openim-bash-image:v1.3.0
WORKDIR /openim/openim-server WORKDIR /openim/openim-server
+1 -15
View File
@@ -1,17 +1,3 @@
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# OpenIM base image: https://github.com/openim-sigs/openim-base-image # OpenIM base image: https://github.com/openim-sigs/openim-base-image
# Set go mod installation source and proxy # Set go mod installation source and proxy
@@ -34,7 +20,7 @@ COPY . .
RUN make clean RUN make clean
RUN make build BINS=openim-msgtransfer RUN make build BINS=openim-msgtransfer
FROM ghcr.io/openim-sigs/openim-bash-image:latest FROM ghcr.io/openim-sigs/openim-bash-image:v1.3.0
ENV OS ${OS} ENV OS ${OS}
ENV ARCH ${ARCH} ENV ARCH ${ARCH}
+1 -15
View File
@@ -1,17 +1,3 @@
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# OpenIM base image: https://github.com/openim-sigs/openim-base-image # OpenIM base image: https://github.com/openim-sigs/openim-base-image
# Set go mod installation source and proxy # Set go mod installation source and proxy
@@ -34,7 +20,7 @@ COPY . .
RUN make clean RUN make clean
RUN make build BINS=openim-push RUN make build BINS=openim-push
FROM ghcr.io/openim-sigs/openim-bash-image:latest FROM ghcr.io/openim-sigs/openim-bash-image:v1.3.0
WORKDIR /openim/openim-server WORKDIR /openim/openim-server
+2 -16
View File
@@ -1,17 +1,3 @@
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# OpenIM base image: https://github.com/openim-sigs/openim-base-image # OpenIM base image: https://github.com/openim-sigs/openim-base-image
# Set go mod installation source and proxy # Set go mod installation source and proxy
@@ -37,7 +23,7 @@ RUN make clean
RUN CGO_ENABLED=0 go build -ldflags="-w -s" -o ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-auth ./cmd/openim-rpc/openim-rpc-auth RUN CGO_ENABLED=0 go build -ldflags="-w -s" -o ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-auth ./cmd/openim-rpc/openim-rpc-auth
FROM ghcr.io/openim-sigs/openim-bash-image:latest FROM ghcr.io/openim-sigs/openim-bash-image:v1.3.0
WORKDIR /openim/openim-server WORKDIR /openim/openim-server
@@ -49,4 +35,4 @@ COPY --from=builder /openim/openim-server/config /openim/openim-server/config
EXPOSE 10160 EXPOSE 10160
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-rpc-auth --port 10160 -c ${SERVER_WORKDIR}/config"] CMD ["sh","-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-rpc-auth --port 10160 -c ${SERVER_WORKDIR}/config"]
@@ -1,17 +1,3 @@
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# OpenIM base image: https://github.com/openim-sigs/openim-base-image # OpenIM base image: https://github.com/openim-sigs/openim-base-image
# Set go mod installation source and proxy # Set go mod installation source and proxy
@@ -43,7 +29,7 @@ RUN rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-fr
rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-user && \ rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-user && \
rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-auth rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-auth
FROM ghcr.io/openim-sigs/openim-bash-image:latest FROM ghcr.io/openim-sigs/openim-bash-image:v1.3.0
WORKDIR /openim/openim-server WORKDIR /openim/openim-server
@@ -56,4 +42,4 @@ COPY --from=builder /openim/openim-server/config /openim/openim-server/config
EXPOSE 10230 EXPOSE 10230
EXPOSE 20230 EXPOSE 20230
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-rpc-conversation --port 10230 --prometheus_port 20230 -c ${SERVER_WORKDIR}/config"] CMD ["sh","-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-rpc-conversation --port 10230 --prometheus_port 20230 -c ${SERVER_WORKDIR}/config"]
+2 -16
View File
@@ -1,17 +1,3 @@
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# OpenIM base image: https://github.com/openim-sigs/openim-base-image # OpenIM base image: https://github.com/openim-sigs/openim-base-image
# Set go mod installation source and proxy # Set go mod installation source and proxy
@@ -43,7 +29,7 @@ RUN rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-gr
rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-conversation && \ rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-conversation && \
rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-auth rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-auth
FROM ghcr.io/openim-sigs/openim-bash-image:latest FROM ghcr.io/openim-sigs/openim-bash-image:v1.3.0
WORKDIR /openim/openim-server WORKDIR /openim/openim-server
@@ -56,4 +42,4 @@ COPY --from=builder /openim/openim-server/config /openim/openim-server/config
EXPOSE 10120 EXPOSE 10120
EXPOSE 20120 EXPOSE 20120
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-rpc-friend --port 10120 --prometheus_port 20120 -c ${SERVER_WORKDIR}/config"] CMD ["sh","-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-rpc-friend --port 10120 --prometheus_port 20120 -c ${SERVER_WORKDIR}/config"]
+2 -16
View File
@@ -1,17 +1,3 @@
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# OpenIM base image: https://github.com/openim-sigs/openim-base-image # OpenIM base image: https://github.com/openim-sigs/openim-base-image
# Set go mod installation source and proxy # Set go mod installation source and proxy
@@ -43,7 +29,7 @@ RUN rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-fr
rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-conversation && \ rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-conversation && \
rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-auth rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-auth
FROM ghcr.io/openim-sigs/openim-bash-image:latest FROM ghcr.io/openim-sigs/openim-bash-image:v1.3.0
WORKDIR /openim/openim-server WORKDIR /openim/openim-server
@@ -56,4 +42,4 @@ COPY --from=builder /openim/openim-server/config /openim/openim-server/config
EXPOSE 10150 EXPOSE 10150
EXPOSE 20150 EXPOSE 20150
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-rpc-group --port 10150 --prometheus_port 20150 -c ${SERVER_WORKDIR}/config"] CMD ["sh","-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-rpc-group --port 10150 --prometheus_port 20150 -c ${SERVER_WORKDIR}/config"]
+2 -16
View File
@@ -1,17 +1,3 @@
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# OpenIM base image: https://github.com/openim-sigs/openim-base-image # OpenIM base image: https://github.com/openim-sigs/openim-base-image
# Set go mod installation source and proxy # Set go mod installation source and proxy
@@ -43,7 +29,7 @@ RUN rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-fr
rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-conversation && \ rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-conversation && \
rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-auth rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-auth
FROM ghcr.io/openim-sigs/openim-bash-image:latest FROM ghcr.io/openim-sigs/openim-bash-image:v1.3.0
WORKDIR /openim/openim-server WORKDIR /openim/openim-server
@@ -56,4 +42,4 @@ COPY --from=builder /openim/openim-server/config /openim/openim-server/config
EXPOSE 10130 EXPOSE 10130
EXPOSE 20130 EXPOSE 20130
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-rpc-msg --port 10130 --prometheus_port 20130 -c ${SERVER_WORKDIR}/config"] CMD ["sh","-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-rpc-msg --port 10130 --prometheus_port 20130 -c ${SERVER_WORKDIR}/config"]
+2 -16
View File
@@ -1,17 +1,3 @@
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# OpenIM base image: https://github.com/openim-sigs/openim-base-image # OpenIM base image: https://github.com/openim-sigs/openim-base-image
# Set go mod installation source and proxy # Set go mod installation source and proxy
@@ -43,7 +29,7 @@ RUN rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-fr
rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-conversation && \ rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-conversation && \
rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-auth rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-auth
FROM ghcr.io/openim-sigs/openim-bash-image:latest FROM ghcr.io/openim-sigs/openim-bash-image:v1.3.0
WORKDIR /openim/openim-server WORKDIR /openim/openim-server
@@ -55,4 +41,4 @@ COPY --from=builder /openim/openim-server/config /openim/openim-server/config
EXPOSE 10200 EXPOSE 10200
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-rpc-third --port 10200 -c ${SERVER_WORKDIR}/config"] CMD ["sh","-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-rpc-third --port 10200 -c ${SERVER_WORKDIR}/config"]
+2 -16
View File
@@ -1,17 +1,3 @@
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# OpenIM base image: https://github.com/openim-sigs/openim-base-image # OpenIM base image: https://github.com/openim-sigs/openim-base-image
# Set go mod installation source and proxy # Set go mod installation source and proxy
@@ -43,7 +29,7 @@ RUN rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-fr
rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-conversation && \ rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-conversation && \
rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-auth rm -rf ./_output/bin/platforms/$(go env GOOS)/$(go env GOARCH)/openim-rpc-auth
FROM ghcr.io/openim-sigs/openim-bash-image:latest FROM ghcr.io/openim-sigs/openim-bash-image:v1.3.0
WORKDIR /openim/openim-server WORKDIR /openim/openim-server
@@ -55,4 +41,4 @@ COPY --from=builder /openim/openim-server/config /openim/openim-server/config
EXPOSE 10110 EXPOSE 10110
CMD ["bash", "-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-rpc-user --port 10110 -c ${SERVER_WORKDIR}/config"] CMD ["sh","-c","${OPENIM_SERVER_BINDIR}/platforms/${OS}/${ARCH}/openim-rpc-user --port 10110 -c ${SERVER_WORKDIR}/config"]
+4 -5
View File
@@ -26,15 +26,14 @@ import (
_ "net/http/pprof" _ "net/http/pprof"
"github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/tools/discoveryregistry"
openKeeper "github.com/OpenIMSDK/tools/discoveryregistry/zookeeper"
"github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/Open-IM-Server/internal/api" "github.com/OpenIMSDK/Open-IM-Server/internal/api"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/tools/discoveryregistry"
openKeeper "github.com/OpenIMSDK/tools/discoveryregistry/zookeeper"
"github.com/OpenIMSDK/tools/log"
) )
func main() { func main() {
-11
View File
@@ -2,17 +2,6 @@
OpenIM 支持很多种集群化部署方式,包括但不限于 helm, sealos, kubeam, kubesphere, kubeflow, kuboard, kubespray, k3s, k3d, k3c, k3sup, k3v, k3x OpenIM 支持很多种集群化部署方式,包括但不限于 helm, sealos, kubeam, kubesphere, kubeflow, kuboard, kubespray, k3s, k3d, k3c, k3sup, k3v, k3x
**目前还在开发这个模块,预计 v3.2.0 之前会有一个集群方案。**
目前各个贡献者,以及之前的官方有出过一些可以参考的方案:
- https://github.com/OpenIMSDK/k8s-jenkins
- https://github.com/OpenIMSDK/Open-IM-Server-k8s-deploy
- https://github.com/OpenIMSDK/openim-charts
- https://github.com/showurl/deploy-openim
### 依赖检查 ### 依赖检查
```bash ```bash
+11 -8
View File
@@ -52,6 +52,7 @@ services:
net.core.somaxconn: 1024 net.core.somaxconn: 1024
command: redis-server --requirepass ${PASSWORD} --appendonly yes command: redis-server --requirepass ${PASSWORD} --appendonly yes
zookeeper: zookeeper:
image: wurstmeister/zookeeper image: wurstmeister/zookeeper
ports: ports:
@@ -63,6 +64,7 @@ services:
TZ: Asia/Shanghai TZ: Asia/Shanghai
restart: always restart: always
kafka: kafka:
image: wurstmeister/kafka image: wurstmeister/kafka
container_name: kafka container_name: kafka
@@ -96,13 +98,14 @@ services:
restart: always restart: always
command: minio server /data --console-address ':9090' command: minio server /data --console-address ':9090'
openim-server:
image: ghcr.io/openimsdk/openim-server:latest openim_server:
image: ghcr.io/openim-sigs/openim-server:v1.0.0-debug.11 #ghcr.io/openimsdk/openim-server:main
container_name: openim-server container_name: openim-server
volumes: volumes:
- ./logs:/openim/openim-server/logs - ./_output/openim/openim-server/logs:/openim/openim-server/logs
- ./config:/openim/openim-server/config - ./_output/openim/openim-server/config:/openim/openim-server/config
- ./scripts:/openim/openim-server/scripts - ./_output/openim/openim-server/scripts:/openim/openim-server/scripts
restart: always restart: always
depends_on: depends_on:
- zookeeper - zookeeper
@@ -119,7 +122,7 @@ services:
max-file: "2" max-file: "2"
openim-chat: openim-chat:
image: ghcr.io/openimsdk/openim-chat:latest image: ghcr.io/openim-sigs/openim-chat:v1.0.0-debug.11 # ghcr.io/openimsdk/openim-chat:main
container_name: openim-chat container_name: openim-chat
volumes: volumes:
- ./_output/openim/openim-chat/logs:/openim/openim-chat/logs - ./_output/openim/openim-chat/logs:/openim/openim-chat/logs
@@ -131,7 +134,7 @@ services:
- mongodb - mongodb
- redis - redis
- minio - minio
- openim-server - openim_server
network_mode: "host" network_mode: "host"
logging: logging:
driver: json-file driver: json-file
@@ -147,7 +150,7 @@ services:
# ports: # ports:
# - 9091:9091 # - 9091:9091
depends_on: depends_on:
- openim-server - openim_server
command: --web.listen-address=:9091 --config.file="/etc/prometheus/prometheus.yml" command: --web.listen-address=:9091 --config.file="/etc/prometheus/prometheus.yml"
network_mode: "host" network_mode: "host"
+4 -1
View File
@@ -1,5 +1,8 @@
docs/.generated_docs docs/.generated_docs
docs/guide/en-US/cmd/iam-apiserver.md
docs/guide/en-US/cmd/iam-authz-server.md
docs/guide/en-US/cmd/iam-pump.md
docs/guide/en-US/cmd/iam-watcher.md
docs/guide/en-US/cmd/openim/openim.md docs/guide/en-US/cmd/openim/openim.md
docs/guide/en-US/cmd/openim/openim_color.md docs/guide/en-US/cmd/openim/openim_color.md
docs/guide/en-US/cmd/openim/openim_completion.md docs/guide/en-US/cmd/openim/openim_completion.md
+209 -201
View File
@@ -1,19 +1,23 @@
## OpenIM development specification ## Go 代码开发规范
We have very high standards for code style and specification, and we want our products to be polished and perfect 在Go 项目开发中,一个好的编码规范可以极大的提高代码质量。为了帮你节省时间和精力,这里我整理了一份清晰、可直接套用的 Go 编码规范,供你参考。
## 1. Code style 这份规范,是我参考了 Go 官方提供的编码规范,以及 Go 社区沉淀的一些比较合理的规范之后,加入自己的理解总结出的,它比很多公司内部的规范更全面,你掌握了,以后在面试大厂的时候,或者在大厂里写代码的时候,都会让人高看你一眼,觉得你code很专业。
### 1.1 Code format 这份编码规范中包含代码风格、命名规范、注释规范、类型、控制结构、函数、GOPATH 设置规范、依赖管理和最佳实践九类规范。如果你觉得这些规范内容太多了,看完一遍也记不住,这完全没关系。你可以多看几遍,也可以在用到时把它翻出来,在实际应用中掌握。这篇特别放送的内容,更多是作为写代码时候的一个参考手册。
- Code must be formatted with `gofmt`. ## 1. 代码风格
- Leave spaces between operators and operands.
- It is recommended that a line of code does not exceed 120 characters. If the part exceeds, please use an appropriate line break method. But there are also some exception scenarios, such as import lines, code automatically generated by tools, and struct fields with tags. ### 1.1 代码格式
- The file length cannot exceed 800 lines.
- Function length cannot exceed 80 lines. - 代码都必须用 `gofmt` 进行格式化。
- import specification - 运算符和操作数之间要留空格。
- All code must be formatted with `goimports` (it is recommended to set the code Go code editor to: run `goimports` on save). - 建议一行代码不超过120个字符,超过部分,请采用合适的换行方式换行。但也有些例外场景,例如import行、工具自动生成的代码、带tag的struct字段。
- Do not use relative paths to import packages, such as `import ../util/net`. - 文件长度不能超过800行。
- Import aliases must be used when the package name does not match the last directory name of the import path, or when multiple identical package names conflict. - 函数长度不能超过80行。
- import规范
- 代码都必须用`goimports`进行格式化(建议将代码Go代码编辑器设置为:保存时运行 `goimports`)。
- 不要使用相对路径引入包,例如 `import ../util/net`
- 包名称与导入路径的最后一个目录名不匹配时,或者多个相同包名冲突时,则必须使用导入别名。
```go ```go
// bad // bad
@@ -22,32 +26,32 @@ We have very high standards for code style and specification, and we want our pr
//good //good
jwt "github.com/dgrijalva/jwt-go/v4" jwt "github.com/dgrijalva/jwt-go/v4"
``` ```
- Imported packages are suggested to be grouped, and anonymous package references use a new group, and anonymous package references are explained. - 导入的包建议进行分组,匿名包的引用使用一个新的分组,并对匿名包引用进行说明。
```go ```go
import ( import (
// go standard package // go 标准包
"fmt" "fmt"
// third party package // 第三方包
"github.com/jinzhu/gorm" "github.com/jinzhu/gorm"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
// Anonymous packages are grouped separately, and anonymous package references are explained // 匿名包单独分组,并对匿名包引用进行说明
// import mysql driver // import mysql driver
_ "github.com/jinzhu/gorm/dialects/mysql" _ "github.com/jinzhu/gorm/dialects/mysql"
// inner package // 内部包
v1 "github.com/marmotedu/api/apiserver/v1" v1 "github.com/marmotedu/api/apiserver/v1"
metav1 "github.com/marmotedu/apimachinery/pkg/meta/v1" metav1 "github.com/marmotedu/apimachinery/pkg/meta/v1"
"github.com/marmotedu/iam/pkg/cli/genericclioptions" "github.com/marmotedu/iam/pkg/cli/genericclioptions"
) )
``` ```
### 1.2 Declaration, initialization and definition ### 1.2 声明、初始化和定义
When multiple variables need to be used in a function, the `var` declaration can be used at the beginning of the function. Declaration outside the function must use `var`, do not use `:=`, it is easy to step on the scope of the variable. 当函数中需要使用到多个变量时,可以在函数开始处使用`var`声明。在函数外部声明必须使用 `var` ,不要采用 `:=` ,容易踩到变量的作用域的问题。
```go ```go
var ( var (
@@ -56,7 +60,7 @@ Height int
) )
``` ```
- When initializing a structure reference, please use `&T{}` instead of `new(T)` to make it consistent with structure initialization. - 在初始化结构引用时,请使用`&T{}`代替`new(T)`,以使其与结构体初始化一致。
```go ```go
// bad // bad
@@ -67,7 +71,7 @@ sptr.Name = "bar"
sptr := &T{Name: "bar"} sptr := &T{Name: "bar"}
``` ```
- The struct declaration and initialization format takes multiple lines and is defined as follows. - struct 声明和初始化格式采用多行,定义如下。
```go ```go
type User struct{ type User struct{
@@ -81,7 +85,7 @@ Email: "nosbelm@qq.com",
} }
``` ```
- Similar declarations are grouped together, and the same applies to constant, variable, and type declarations. - 相似的声明放在一组,同样适用于常量、变量和类型声明。
```go ```go
// bad // bad
@@ -95,14 +99,14 @@ import (
) )
``` ```
- Specify container capacity where possible to pre-allocate memory for the container, for example: - 尽可能指定容器容量,以便为容器预先分配内存,例如:
```go ```go
v := make(map[int]string, 4) v := make(map[int]string, 4)
v := make([]string, 0, 4) v := make([]string, 0, 4)
``` ```
- At the top level, use the standard var keyword. Do not specify a type unless it is different from the type of the expression. - 在顶层,使用标准var关键字。请勿指定类型,除非它与表达式的类型不同。
```go ```go
// bad // bad
@@ -112,13 +116,13 @@ func F() string { return "A" }
// good // good
var _s = F() var _s = F()
// Since F already explicitly returns a string type, we don't need to explicitly specify the type of _s // 由于 F 已经明确了返回一个字符串类型,因此我们没有必要显式指定_s 的类型
// still of that type // 还是那种类型
func F() string { return "A" } func F() string { return "A" }
``` ```
- Use `_` as a prefix for unexported top-level constants and variables. - 对于未导出的顶层常量和变量,使用`_`作为前缀。
```go ```go
// bad // bad
@@ -134,7 +138,7 @@ const (
) )
``` ```
- Embedded types (such as mutexes) should be at the top of the field list within the struct, and there must be a blank line separating embedded fields from regular fields. - 嵌入式类型(例如 mutex)应位于结构体内的字段列表的顶部,并且必须有一个空行将嵌入式字段与常规字段分隔开。
```go ```go
// bad // bad
@@ -151,9 +155,9 @@ type Client struct {
} }
``` ```
### 1.3 Error Handling ### 1.3 错误处理
- `error` is returned as the value of the function, `error` must be handled, or the return value assigned to explicitly ignore. For `defer xx.Close()`, there is no need to explicitly handle it. - `error`作为函数的值返回,必须对`error`进行处理,或将返回值赋值给明确忽略。对于`defer xx.Close()`可以不用显式处理。
```go ```go
func load() error { func load() error {
@@ -167,7 +171,7 @@ load()
_ = load() _ = load()
``` ```
- When `error` is returned as the value of a function and there are multiple return values, `error` must be the last parameter. - `error`作为函数的值返回且有多个返回值的时候,`error`必须是最后一个参数。
```go ```go
// bad // bad
@@ -181,7 +185,7 @@ func load() (int, error) {
} }
``` ```
- Perform error handling as early as possible and return as early as possible to reduce nesting. - 尽早进行错误处理,并尽早返回,减少嵌套。
```go ```go
// bad // bad
@@ -199,7 +203,7 @@ return err
// normal code // normal code
``` ```
- If you need to use the result of the function call outside if, you should use the following method. - 如果需要在 if 之外使用函数调用的结果,则应采用下面的方式。
```go ```go
// bad // bad
@@ -214,7 +218,7 @@ if err != nil {
} }
``` ```
- Errors should be judged independently, not combined with other logic. - 错误要单独判断,不与其他逻辑组合判断。
```go ```go
// bad // bad
@@ -237,7 +241,7 @@ return errors. New("invalid value v")
} }
``` ```
- If the return value needs to be initialized, use the following method. - 如果返回值需要初始化,则采用下面的方式。
```go ```go
v, err := f() v, err := f()
@@ -247,8 +251,8 @@ if err != nil {
} }
``` ```
- Bug description suggestions - 错误描述建议
- Error descriptions start with a lowercase letter and do not end with punctuation, for example: - 错误描述用小写字母开头,结尾不要加标点符号,例如:
```go ```go
// bad // bad
errors.New("Redis connection failed") errors.New("Redis connection failed")
@@ -257,34 +261,34 @@ errors.New("redis connection failed.")
// good // good
errors.New("redis connection failed") errors.New("redis connection failed")
``` ```
- Tell users what they can do, not what they can't. - 告诉用户他们可以做什么,而不是告诉他们不能做什么。
- When declaring a requirement, use must instead of should. For example, `must be greater than 0, must match regex '[a-z]+'`. - 当声明一个需求时,用must 而不是should。例如,`must be greater than 0must match regex '[a-z]+'`
- When declaring that a format is incorrect, use must not. For example, `must not contain`. - 当声明一个格式不对时,用must not。例如,`must not contain`
- Use may not when declaring an action. For example, `may not be specified when otherField is empty, only name may be specified`. - 当声明一个动作时用may not。例如,`may not be specified when otherField is emptyonly name may be specified`
- When quoting a literal string value, indicate the literal in single quotes. For example, `ust not contain '..'`. - 引用文字字符串值时,请在单引号中指示文字。例如,`ust not contain '..'`
- When referencing another field name, specify that name in backticks. For example, must be greater than `request`. - 当引用另一个字段名称时,请在反引号中指定该名称。例如,must be greater than `request`
- When specifying unequal, use words instead of symbols. For example, `must be less than 256, must be greater than or equal to 0 (do not use larger than, bigger than, more than, higher than)`. - 指定不等时,请使用单词而不是符号。例如,`must be less than 256must be greater than or equal to 0 (不要用 larger thanbigger thanmore thanhigher than)`
- When specifying ranges of numbers, use inclusive ranges whenever possible. - 指定数字范围时,请尽可能使用包含范围。
- Go 1.13 or above is recommended, and the error generation method is `fmt.Errorf("module xxx: %w", err)`. - 建议 Go 1.13 以上,error 生成方式为 `fmt.Errorf("module xxx: %w", err)`
### 1.4 panic processing ### 1.4 panic处理
- Panic is prohibited in business logic processing. - 在业务逻辑处理中禁止使用panic。
- In the main package, panic is only used when the program is completely inoperable, for example, the file cannot be opened, the database cannot be connected, and the program cannot run normally. - 在main包中,只有当程序完全不可运行时使用panic,例如无法打开文件、无法连接数据库导致程序无法正常运行。
- In the main package, use `log.Fatal` to record errors, so that the program can be terminated by the log, or the exception thrown by the panic can be recorded in the log file, which is convenient for troubleshooting. - 在main包中,使用 `log.Fatal` 来记录错误,这样就可以由log来结束程序,或者将panic抛出的异常记录到日志文件中,方便排查问题。
- An exportable interface must not panic. - 可导出的接口一定不能有panic
- It is recommended to use error instead of panic to convey errors in the package. - 包内建议采用error而不是panic来传递错误。
### 1.5 Unit Tests ### 1.5 单元测试
- The unit test filename naming convention is `example_test.go`. - 单元测试文件名命名规范为 `example_test.go`
- Write a test case for every important exportable function. - 每个重要的可导出函数都要编写测试用例。
- Because the functions in the unit test file are not external, the exportable structures, functions, etc. can be uncommented. - 因为单元测试文件内的函数都是不对外的,所以可导出的结构体、函数等可以不带注释。
- If `func (b *Bar) Foo` exists, the single test function can be `func TestBar_Foo`. - 如果存在 `func (b *Bar) Foo` ,单测函数可以为 `func TestBar_Foo`
### 1.6 Type assertion failure handling ### 1.6 类型断言失败处理
- A single return value from a type assertion will panic for an incorrect type. Always use the "comma ok" idiom. - type assertion 的单个返回值针对不正确的类型将产生 panic。请始终使用 “comma ok”的惯用法。
```go ```go
// bad // bad
@@ -297,85 +301,85 @@ if !ok {
} }
``` ```
## 2. Naming convention ## 2. 命名规范
The naming convention is a very important part of the code specification. A uniform, short, and precise naming convention can greatly improve the readability of the code and avoid unnecessary bugs. 命名规范是代码规范中非常重要的一部分,一个统一的、短小的、精确的命名规范可以大大提高代码的可读性,也可以借此规避一些不必要的Bug。
### 2.1 Package Naming ### 2.1 包命名
- The package name must be consistent with the directory name, try to use a meaningful and short package name, and do not conflict with the standard library. - 包名必须和目录名一致,尽量采取有意义、简短的包名,不要和标准库冲突。
- Package names are all lowercase, without uppercase or underscores, and use multi-level directories to divide the hierarchy. - 包名全部小写,没有大写或下划线,使用多级目录来划分层级。
- Item names can connect multiple words with dashes. - 项目名可以通过中划线来连接多个单词。
- Do not use plurals for the package name and the directory name where the package is located, for example, `net/url` instead of `net/urls`. - 包名以及包所在的目录名,不要使用复数,例如,是`net/url`,而不是`net/urls`
- Don't use broad, meaningless package names like common, util, shared or lib. - 不要用 commonutilshared 或者 lib 这类宽泛的、无意义的包名。
- The package name should be simple and clear, such as net, time, log. - 包名要简单明了,例如 nettimelog
### 2.2 Function Naming ### 2.2 函数命名
- The function name is in camel case, and the first letter is uppercase or lowercase according to the access control decision,For example: `MixedCaps` or `mixedCaps`. - 函数名采用驼峰式,首字母根据访问控制决定使用大写或小写,例如:`MixedCaps`或者`mixedCaps`
- Code automatically generated by code generation tools (such as `xxxx.pb.go`) and underscores used to group related test cases (such as `TestMyFunction_WhatIsBeingTested`) exclude this rule. - 代码生成工具自动生成的代码(如`xxxx.pb.go`)和为了对相关测试用例进行分组,而采用的下划线(如`TestMyFunction_WhatIsBeingTested`)排除此规则。
### 2.3 File Naming ### 2.3 文件命名
- Keep the filename short and meaningful. - 文件名要简短有意义。
- Filenames should be lowercase and use underscores to separate words. - 文件名应小写,并使用下划线分割单词。
### 2.4 Structure Naming ### 2.4 结构体命名
- The camel case is adopted, and the first letter is uppercase or lowercase according to the access control, such as `MixedCaps` or `mixedCaps`. - 采用驼峰命名方式,首字母根据访问控制决定使用大写或小写,例如`MixedCaps`或者`mixedCaps`
- Struct names should not be verbs, but should be nouns, such as `Node`, `NodeSpec`. - 结构体名不应该是动词,应该是名词,比如 `Node``NodeSpec`
- Avoid using meaningless structure names such as Data and Info. - 避免使用Data、Info这类无意义的结构体名。
- The declaration and initialization of the structure should take multiple lines, for example: - 结构体的声明和初始化应采用多行,例如:
```go ```go
// User multi-line declaration // User 多行声明
type User struct { type User struct {
name string Name string
Email string Email string
} }
// multi-line initialization // 多行初始化
u := User{ u := User{
UserName: "belm", UserName: "belm",
Email: "nosbelm@qq.com", Email: "nosbelm@qq.com",
} }
``` ```
### 2.5 Interface Naming ### 2.5 接口命名
- The interface naming rules are basically consistent with the structure naming rules: - 接口命名的规则,基本和结构体命名规则保持一致:
- Interface names of individual functions suffixed with "er"" (e.g. Reader, Writer) can sometimes lead to broken English, but that's okay. - 单个函数的接口名以 “er"”作为后缀(例如ReaderWriter),有时候可能导致蹩脚的英文,但是没关系。
- The interface name of the two functions is named after the two function names, eg ReadWriter. - 两个函数的接口名以两个函数名命名,例如ReadWriter
- An interface name for more than three functions, similar to a structure name. - 三个以上函数的接口名,类似于结构体名。
For example: 例如:
``` ```
// Seeking to an offset before the start of the file is an error. // Seeking to an offset before the start of the file is an error.
// Seeking to any positive offset is legal, but the behavior of subsequent // Seeking to any positive offset is legal, but the behavior of subsequent
// I/O operations on the underlying object are implementation-dependent. // I/O operations on the underlying object is implementation-dependent.
type Seeker interface { type Seeker interface {
Seek(offset int64, whence int) (int64, error) Seek(offset int64, whence int) (int64, error)
} }
// ReadWriter is the interface that groups the basic Read and Write methods. // ReadWriter is the interface that groups the basic Read and Write methods.
type ReadWriter interface { type ReadWriter interface {
reader Reader
Writer Writer
} }
``` ```
### 2.6 Variable Naming ### 2.6 变量命名
- Variable names must follow camel case, and the initial letter is uppercase or lowercase according to the access control decision. - 变量名必须遵循驼峰式,首字母根据访问控制决定使用大写或小写。
- In relatively simple (few objects, highly targeted) environments, some names can be abbreviated from full words to single letters, for example: - 在相对简单(对象数量少、针对性强)的环境中,可以将一些名称由完整单词简写为单个字母,例如:
- user can be abbreviated as u; - user 可以简写为 u
- userID can be abbreviated as uid. - userID 可以简写 uid
- When using proper nouns, the following rules need to be followed: - 特有名词时,需要遵循以下规则:
- If the variable is private and the proper noun is the first word, use lowercase, such as apiClient. - 如果变量为私有,且特有名词为首个单词,则使用小写,如 apiClient
- In other cases, the original wording of the noun should be used, such as APIClient, repoID, UserID. - 其他情况都应当使用该名词原有的写法,如 APIClientrepoIDUserID
Some common nouns are listed below. 下面列举了一些常见的特有名词。
``` ```
// A GonicMapper that contains a list of common initialisms taken from golang/lint // A GonicMapper that contains a list of common initialisms taken from golang/lint
@@ -416,7 +420,7 @@ var LintGonicMapper = GonicMapper{
} }
``` ```
- If the variable type is bool, the name should start with Has, Is, Can or Allow, for example: - 若变量类型为bool类型,则名称应以Has,Is,Can或Allow开头,例如:
```go ```go
var hasConflict bool var hasConflict bool
@@ -425,13 +429,13 @@ var can Manage bool
var allowGitHook bool var allowGitHook bool
``` ```
- Local variables should be as short as possible, for example, use buf to refer to buffer, and use i to refer to index. - 局部变量应当尽可能短小,比如使用buf指代buffer,使用i指代index
- The code automatically generated by the code generation tool can exclude this rule (such as the Id in `xxx.pb.go`) - 代码生成工具自动生成的代码可排除此规则(如`xxx.pb.go`里面的Id)
### 2.7 Constant naming ### 2.7 常量命名
- The constant name must follow the camel case, and the initial letter is uppercase or lowercase according to the access control decision. - 常量名必须遵循驼峰式,首字母根据访问控制决定使用大写或小写。
- If it is a constant of enumeration type, you need to create the corresponding type first: - 如果是枚举类型的常量,需要先创建相应类型:
```go ```go
// Code defines an error code type. // Code defines an error code type.
@@ -446,9 +450,9 @@ const (
) )
``` ```
### 2.8 Error naming ### 2.8 Error的命名
- The Error type should be written in the form of FooError. - Error类型应该写成FooError的形式。
```go ```go
type ExitError struct { type ExitError struct {
@@ -456,18 +460,18 @@ type ExitError struct {
} }
``` ```
- The Error variable is written in the form of ErrFoo. - Error变量写成ErrFoo的形式。
```go ```go
var ErrFormat = errors.New("unknown format") var ErrFormat = errors.New("unknown format")
``` ```
## 3. Comment specification ## 3. 注释规范
- Each exportable name must have a comment, which briefly introduces the exported variables, functions, structures, interfaces, etc. - 每个可导出的名字都要有注释,该注释对导出的变量、函数、结构体、接口等进行简要介绍。
- All single-line comments are used, and multi-line comments are prohibited. - 全部使用单行注释,禁止使用多行注释。
- Same as the code specification, single-line comments should not be too long, and no more than 120 characters are allowed. If it exceeds, please use a new line to display, and try to keep the format elegant. - 和代码的规范一样,单行注释不要过长,禁止超过 120 字符,超过的请使用换行展示,尽量保持格式优雅。
- A comment must be a complete sentence, starting with the content to be commented and ending with a period, `the format is // name description.`. For example: - 注释必须是完整的句子,以需要注释的内容作为开头,句点作为结尾,`格式为 // 名称 描述.`。例如:
```go ```go
// bad // bad
@@ -483,9 +487,9 @@ func PrintFlags(flags *pflag. FlagSet) {
} }
``` ```
- All commented out code should be deleted before submitting code review, otherwise, it should explain why it is not deleted, and give follow-up processing suggestions. - 所有注释掉的代码在提交code review前都应该被删除,否则应该说明为什么不删除,并给出后续处理建议。
- Multiple comments can be separated by blank lines, as follows: - 在多段注释之间可以使用空行分隔加以区分,如下所示:
```go ```go
// Package superman implements methods for saving the world. // Package superman implements methods for saving the world.
@@ -495,10 +499,10 @@ func PrintFlags(flags *pflag. FlagSet) {
package superman package superman
``` ```
### 3.1 Package Notes ### 3.1 包注释
- Each package has one and only one package-level annotation. - 每个包都有且仅有一个包级别的注释。
- Package comments are uniformly commented with // in the format of `// Package package name package description`, for example: - 包注释统一用 // 进行注释,格式为 `// Package 包名 包描述`,例如:
```go ```go
// Package genericclioptions contains flags which can be added to you command, bound, completed, and produce // Package genericclioptions contains flags which can be added to you command, bound, completed, and produce
@@ -506,15 +510,15 @@ package superman
package genericclioptions package genericclioptions
``` ```
### 3.2 Variable/Constant Comments ### 3.2 变量/常量注释
- Each variable/constant that can be exported must have a comment description, `the format is // variable name variable description`, for example: - 每个可导出的变量/常量都必须有注释说明,`格式为// 变量名 变量描述`,例如:
```go ```go
// ErrSigningMethod defines invalid signing method error. // ErrSigningMethod defines invalid signing method error.
var ErrSigningMethod = errors.New("Invalid signing method") var ErrSigningMethod = errors.New("Invalid signing method")
``` ```
- When there is a large block of constant or variable definition, you can comment a general description in front, and then comment the definition of the constant in detail before or at the end of each line of constant, for example: - 出现大块常量或变量定义时,可在前面注释一个总的说明,然后在每一行常量的前一行或末尾详细注释该常量的定义,例如:
```go ```go
// Code must start with 1xxxxx. // Code must start with 1xxxxx.
const ( const (
@@ -531,10 +535,10 @@ const (
ErrValidation ErrValidation
) )
``` ```
### 3.3 Structure Annotation ### 3.3 结构体注释
- Each structure or interface that needs to be exported must have a comment description, the format is `// structure name structure description.`. - 每个需要导出的结构体或者接口都必须有注释说明,格式为 `// 结构体名 结构体描述.`
- The name of the exportable member variable in the structure, if the meaning is not clear, a comment must be given and placed before the member variable or at the end of the same line. For example: - 结构体内的可导出成员变量名,如果意义不明确,必须要给出注释,放在成员变量的前一行或同一行的末尾。例如:
```go ```go
// User represents a user restful resource. It is also used as gorm model. // User represents a user restful resource. It is also used as gorm model.
@@ -550,9 +554,9 @@ type User struct {
} }
``` ```
### 3.4 Method Notes ### 3.4 方法注释
Each function or method that needs to be exported must have a comment, the format is // function name function description., for examplelike: 每个需要导出的函数或者方法都必须有注释,格式为// 函数名 函数描述.,例如:
```go ```go
// BeforeUpdate run before update database record. // BeforeUpdate run before update database record.
@@ -562,20 +566,20 @@ return nil
} }
``` ```
### 3.5 Type annotations ### 3.5 类型注释
- Each type definition and type alias that needs to be exported must have a comment description, the format is `// type name type description.`, for example: - 每个需要导出的类型定义和类型别名都必须有注释说明,格式为 `// 类型名 类型描述.`,例如:
```go ```go
// Code defines an error code type. // Code defines an error code type.
type Code int type Code int
``` ```
## 4. Type ## 4. 类型
### 4.1 Strings ### 4.1 字符串
- Empty string judgment. - 空字符串判断。
```go ```go
// bad // bad
@@ -589,7 +593,7 @@ if len(s) == 0 {
} }
``` ```
- `[]byte`/`string` equality comparison. - `[]byte`/`string`相等比较。
```go ```go
// bad // bad
@@ -607,7 +611,7 @@ bytes. Compare(s1, s2) == 0
bytes.Compare(s1, s2) != 0 bytes.Compare(s1, s2) != 0
``` ```
- Complex strings use raw strings to avoid character escaping. - 复杂字符串使用raw字符串避免字符转义。
```go ```go
// bad // bad
@@ -617,9 +621,9 @@ regexp.MustCompile("\\.")
regexp.MustCompile(`\.`) regexp.MustCompile(`\.`)
``` ```
### 4.2 Slicing ### 4.2 切片
- Empty slice judgment. - 空slice判断。
```go ```go
// bad // bad
@@ -633,9 +637,9 @@ if slice != nil && len(slice) == 0 {
} }
``` ```
The above judgment also applies to map and channel. 上面判断同样适用于map、channel
- Declare a slice. - 声明slice
```go ```go
// bad // bad
@@ -646,7 +650,7 @@ s := make([]string, 0)
var s []string var s []string
``` ```
- slice copy. - slice复制。
```go ```go
// bad // bad
@@ -662,7 +666,7 @@ for i := range b1 {
copy(b2, b1) copy(b2, b1)
``` ```
- slice added. - slice新增。
```go ```go
// bad // bad
@@ -676,16 +680,16 @@ var a, b []int
b = append(b, a...) b = append(b, a...)
``` ```
### 4.3 Structure ### 4.3 结构体
- struct initialization. - struct初始化。
The struct is initialized in multi-line format. struct以多行格式初始化。
```go ```go
type user struct { type user struct {
Id int64 Id int64
name string Name string
} }
u1 := user{100, "Colin"} u1 := user{100, "Colin"}
@@ -696,11 +700,11 @@ u2 := user{
} }
``` ```
## 5. Control Structure ## 5. 控制结构
### 5.1 if ### 5.1 if
- if accepts the initialization statement, the convention is to create local variables in the following way. - if 接受初始化语句,约定如下方式建立局部变量。
```go ```go
if err := loadConfig(); err != nil { if err := loadConfig(); err != nil {
@@ -709,7 +713,7 @@ return err
} }
``` ```
- if For variables of bool type, true and false judgments should be made directly. - if 对于bool类型的变量,应直接进行真假判断。
```go ```go
var isAllow bool var isAllow bool
@@ -720,7 +724,7 @@ if isAllow {
### 5.2 for ### 5.2 for
- Create local variables using short declarations. - 采用短声明建立局部变量。
```go ```go
sum := 0 sum := 0
@@ -729,7 +733,7 @@ for i := 0; i < 10; i++ {
} }
``` ```
- Don't use defer in for loop, defer will only be executed when the function exits. - 不要在 for 循环里面使用 defer,defer只有在函数退出时才会执行。
```go ```go
// bad // bad
@@ -757,7 +761,7 @@ defer fd. Close()
### 5.3 range ### 5.3 range
- If only the first item (key) is needed, discard the second. - 如果只需要第一项(key),就丢弃第二个。
```go ```go
for key := range keys { for key := range keys {
@@ -765,7 +769,7 @@ for key := range keys {
} }
``` ```
- If only the second item is required, underline the first item. - 如果只需要第二项,则把第一项置为下划线。
```go ```go
sum := 0 sum := 0
@@ -776,7 +780,7 @@ for _, value := range array {
### 5.4 switch ### 5.4 switch
- must have default. - 必须要有default
```go ```go
switch os := runtime.GOOS; os { switch os := runtime.GOOS; os {
@@ -790,37 +794,37 @@ switch os := runtime.GOOS; os {
``` ```
### 5.5 goto ### 5.5 goto
- Business code prohibits the use of goto. - 业务代码禁止使用 goto 。
- Try not to use frameworks or other low-level source code. - 框架或其他底层源码尽量不用。
## 6. Functions ## 6. 函数
- Incoming variables and return variables start with a lowercase letter. - 传入变量和返回变量以小写字母开头。
- The number of function parameters cannot exceed 5. - 函数参数个数不能超过5个。
- Function grouping and ordering - 函数分组与顺序
- Functions should be sorted in rough calling order. - 函数应按粗略的调用顺序排序。
- Functions in the same file should be grouped by receiver. - 同一文件中的函数应按接收者分组。
- Try to use value transfer instead of pointer transfer. - 尽量采用值传递,而非指针传递。
- The incoming parameters are map, slice, chan, interface, do not pass pointers. - 传入参数是 mapslicechaninterface ,不要传递指针。
### 6.1 Function parameters ### 6.1 函数参数
- If the function returns two or three arguments of the same type, or if the meaning of the result is not clear from the context, use named returns, otherwise it is not recommended to use named returns, for example: - 如果函数返回相同类型的两个或三个参数,或者如果从上下文中不清楚结果的含义,使用命名返回,其他情况不建议使用命名返回,例如:
```go ```go
func coordinate() (x, y float64, err error) { func coordinate() (x, y float64, err error) {
// normal code // normal code
} }
``` ```
- Both incoming and returned variables start with a lowercase letter. - 传入变量和返回变量都以小写字母开头。
- Try to pass by value instead of pointer. - 尽量用值传递,非指针传递。
- The number of parameters cannot exceed 5. - 参数数量均不能超过5个。
- Multiple return values can return up to three, and if there are more than three, please use struct. - 多返回值最多返回三个,超过三个请使用 struct
### 6.2 defer ### 6.2 defer
- When resources are created, resources should be released immediately after defer (defer can be used boldly, the performance of defer is greatly improved in Go1.14 version, and the performance loss of defer can be ignored even in performance-sensitive businesses). - 当存在资源创建时,应紧跟defer释放资源(可以大胆使用deferdefer在Go1.14版本中,性能大幅提升,defer的性能损耗即使在性能敏感型的业务中,也可以忽略)。
- First judge whether there is an error, and then defer to release resources, for example: - 先判断是否错误,再defer释放资源,例如:
```go ```go
rep, err := http.Get(url) rep, err := http.Get(url)
@@ -831,46 +835,46 @@ if err != nil {
defer resp.Body.Close() defer resp.Body.Close()
``` ```
### 6.3 Method Receiver ### 6.3 方法的接收器
- It is recommended to use the lowercase of the first English letter of the class name as the name of the receiver. - 推荐以类名第一个英文首字母的小写作为接收器的命名。
- Don't use a single character in the name of the receiver when the function exceeds 20 lines. - 接收器的命名在函数超过20行的时候不要用单字符。
- The name of the receiver cannot use confusing names such as me, this, and self. - 接收器的命名不能采用me、this、self这类易混淆名称。
### 6.4 Nesting ### 6.4 嵌套
- The nesting depth cannot exceed 4 levels. - 嵌套深度不能超过4层。
### 6.5 Variable Naming ### 6.5 变量命名
- The variable declaration should be placed before the first use of the variable as far as possible, following the principle of proximity. - 变量声明尽量放在变量第一次使用的前面,遵循就近原则。
- If the magic number appears more than twice, it is forbidden to use it and use a constant instead, for example: - 如果魔法数字出现超过两次,则禁止使用,改用一个常量代替,例如:
```go ```go
// PI ... // PI ...
const Price = 3.14 const Prise = 3.14
func getAppleCost(n float64) float64 { func getAppleCost(n float64) float64 {
return Price * n return Prise * n
} }
func getOrangeCost(n float64) float64 { func getOrangeCost(n float64) float64 {
return Price * n return Prise * n
} }
``` ```
## 7. GOPATH setting specification ## 7. GOPATH 设置规范
- After Go 1.11, the GOPATH rule has been weakened. Existing code (many libraries must have been created before 1.11) must conform to this rule. It is recommended to keep the GOPATH rule to facilitate code maintenance. - Go 1.11 之后,弱化了 GOPATH 规则,已有代码(很多库肯定是在1.11之前建立的)肯定符合这个规则,建议保留 GOPATH 规则,便于维护代码。
- Only one GOPATH is recommended, multiple GOPATHs are not recommended. If multiple GOPATHs are used, the bin directory where compilation takes effect is under the first GOPATH. - 建议只使用一个 GOPATH,不建议使用多个 GOPATH。如果使用多个GOPATH,编译生效的 bin 目录是在第一个 GOPATH 下。
## 8. Dependency Management ## 8. 依赖管理
- Go 1.11 and above must use Go Modules. - Go 1.11 以上必须使用 Go Modules
- When using Go Modules as a dependency management project, it is not recommended to submit the vendor directory. - 使用Go Modules作为依赖管理的项目时,不建议提交vendor目录。
- When using Go Modules as a dependency management project, the go.sum file must be submitted. - 使用Go Modules作为依赖管理的项目时,必须提交go.sum文件。
### 9. Best Practices ### 9. 最佳实践
- Minimize the use of global variables, but pass parameters, so that each function is "stateless". This reduces coupling and facilitates division of labor and unit testing. - 尽量少用全局变量,而是通过参数传递,使每个函数都是“无状态”的。这样可以减少耦合,也方便分工和单元测试。
- Verify interface compliance at compile time, for example: - 在编译时验证接口的符合性,例如:
```go ```go
type LogHandler struct { type LogHandler struct {
@@ -879,15 +883,19 @@ type LogHandler struct {
} }
var _ http.Handler = LogHandler{} var _ http.Handler = LogHandler{}
``` ```
- When the server processes a request, it should create a context, save the relevant information of the request (such as requestID), and pass it in the function call chain. - 服务器处理请求时,应该创建一个context,保存该请求的相关信息(如requestID),并在函数调用链中传递。
### 9.1 Performance ### 9.1 性能
- string represents an immutable string variable, modifying string is a relatively heavy operation, and basically needs to re-apply for memory. Therefore, if there is no special need, use []byte more when you need to modify. - string 表示的是不可变的字符串变量,对 string 的修改是比较重的操作,基本上都需要重新申请内存。所以,如果没有特殊需要,需要修改时多使用 []byte。
- Prefer strconv over fmt. - 优先使用 strconv 而不是 fmt
### 9.2 Precautions ### 9.2 注意事项
- append Be careful about automatically allocating memory, append may return a newly allocated address. - append 要小心自动分配内存,append 返回的可能是新分配的地址。
- If you want to directly modify the value of the map, the value can only be a pointer, otherwise the original value must be overwritten. - 如果要直接修改 map 的 value 值,则 value 只能是指针,否则要覆盖原来的值。
- map needs to be locked during concurrency. - map 在并发中需要加锁。
- The conversion of interface{} cannot be checked during compilation, it can only be checked at runtime, be careful to cause panic. - 编译过程无法检查 interface{} 的转换,只能在运行时检查,小心引起 panic
## 总结
这里向你介绍了九类常用的编码规范。但今天的最后,我要在这里提醒你一句:规范是人定的,你也可以根据需要,制定符合你项目的规范,但同时我也建议你采纳这些业界沉淀下来的规范,并通过工具来确保规范的执行。
-3
View File
@@ -11,9 +11,6 @@ OpenIM's versions correspond to GitHub's tag versions. Each time we release a ne
2. **Alibaba Cloud (registry.cn-hangzhou.aliyuncs.com):** For users in Mainland China, we also host OpenIM's Docker images on Alibaba Cloud to provide faster pull speeds. You can view all Alibaba Cloud images on this [page](https://cr.console.aliyun.com/cn-hangzhou/instances/repositories) of Alibaba Cloud Image Service (note that you need to log in to your Alibaba Cloud account first). 2. **Alibaba Cloud (registry.cn-hangzhou.aliyuncs.com):** For users in Mainland China, we also host OpenIM's Docker images on Alibaba Cloud to provide faster pull speeds. You can view all Alibaba Cloud images on this [page](https://cr.console.aliyun.com/cn-hangzhou/instances/repositories) of Alibaba Cloud Image Service (note that you need to log in to your Alibaba Cloud account first).
3. **Docker Hub (docker.io):** Docker Hub is the most commonly used Docker image hosting platform, and we also host OpenIM's images there to facilitate developers worldwide. You can view all Docker Hub images on the [OpenIM's Docker Hub page](https://hub.docker.com/r/openim). 3. **Docker Hub (docker.io):** Docker Hub is the most commonly used Docker image hosting platform, and we also host OpenIM's images there to facilitate developers worldwide. You can view all Docker Hub images on the [OpenIM's Docker Hub page](https://hub.docker.com/r/openim).
## Base images design
+ [https://github.com/openim-sigs/openim-base-image](https://github.com/openim-sigs/openim-base-image)
## OpenIM Image Design and Usage Guide ## OpenIM Image Design and Usage Guide
+7 -7
View File
@@ -8,7 +8,7 @@ require (
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
github.com/go-playground/validator/v10 v10.15.0 github.com/go-playground/validator/v10 v10.14.1
github.com/gogo/protobuf v1.3.2 github.com/gogo/protobuf v1.3.2
github.com/golang-jwt/jwt/v4 v4.5.0 github.com/golang-jwt/jwt/v4 v4.5.0
github.com/golang/protobuf v1.5.3 github.com/golang/protobuf v1.5.3
@@ -24,9 +24,9 @@ require (
github.com/robfig/cron/v3 v3.0.1 github.com/robfig/cron/v3 v3.0.1
github.com/sirupsen/logrus v1.9.3 // indirect github.com/sirupsen/logrus v1.9.3 // indirect
github.com/stretchr/testify v1.8.4 github.com/stretchr/testify v1.8.4
go.mongodb.org/mongo-driver v1.12.1 go.mongodb.org/mongo-driver v1.12.0
golang.org/x/image v0.9.0 // indirect golang.org/x/image v0.9.0 // indirect
google.golang.org/api v0.135.0 google.golang.org/api v0.134.0
google.golang.org/grpc v1.57.0 google.golang.org/grpc v1.57.0
google.golang.org/protobuf v1.31.0 google.golang.org/protobuf v1.31.0
gopkg.in/yaml.v3 v3.0.1 gopkg.in/yaml.v3 v3.0.1
@@ -37,9 +37,9 @@ require (
require github.com/google/uuid v1.3.0 require github.com/google/uuid v1.3.0
require ( require (
github.com/OpenIMSDK/protocol v0.0.6 github.com/OpenIMSDK/protocol v0.0.3
github.com/OpenIMSDK/tools v0.0.13 github.com/OpenIMSDK/tools v0.0.13
github.com/aliyun/aliyun-oss-go-sdk v2.2.8+incompatible github.com/aliyun/aliyun-oss-go-sdk v2.2.7+incompatible
github.com/go-redis/redis v6.15.9+incompatible github.com/go-redis/redis v6.15.9+incompatible
github.com/go-sql-driver/mysql v1.7.1 github.com/go-sql-driver/mysql v1.7.1
github.com/redis/go-redis/v9 v9.0.5 github.com/redis/go-redis/v9 v9.0.5
@@ -125,9 +125,8 @@ require (
golang.org/x/time v0.3.0 // indirect golang.org/x/time v0.3.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/appengine v1.6.7 // indirect google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230706204954-ccb25ca9f130 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20230706204954-ccb25ca9f130 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230726155614-23370e0ffb3e // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230720185612-659f7aaaa771 // indirect
) )
require ( require (
@@ -139,5 +138,6 @@ require (
github.com/ugorji/go/codec v1.2.11 // indirect github.com/ugorji/go/codec v1.2.11 // indirect
go.uber.org/zap v1.24.0 // indirect go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.11.0 // indirect golang.org/x/crypto v0.11.0 // indirect
google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect
) )
+12 -12
View File
@@ -17,8 +17,8 @@ cloud.google.com/go/storage v1.30.1/go.mod h1:NfxhC0UJE1aXSx7CIIbCf7y9HKT7Biccwk
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/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/OpenIMSDK/protocol v0.0.6 h1:KjaItOEww7vjrhwyxHnVzhw80pnjcNukpskadqW6gnA= github.com/OpenIMSDK/protocol v0.0.3 h1:CFQtmnyW+1dYKVFaVaHcJ6oYuMiMdNfU2gC1xz3K/9I=
github.com/OpenIMSDK/protocol v0.0.6/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y= github.com/OpenIMSDK/protocol v0.0.3/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
github.com/OpenIMSDK/tools v0.0.13 h1:rcw4HS8S2DPZR9UOBxD8/ol9UBMzXBypzOVEytDRIMo= github.com/OpenIMSDK/tools v0.0.13 h1:rcw4HS8S2DPZR9UOBxD8/ol9UBMzXBypzOVEytDRIMo=
github.com/OpenIMSDK/tools v0.0.13/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI= github.com/OpenIMSDK/tools v0.0.13/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI=
github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM= github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM=
@@ -26,8 +26,8 @@ github.com/Shopify/sarama v1.29.0 h1:ARid8o8oieau9XrHI55f/L3EoRAhm9px6sonbD7yuUE
github.com/Shopify/sarama v1.29.0/go.mod h1:2QpgD79wpdAESqNQMxNc0KYMkycd4slxGdV3TWSVqrU= github.com/Shopify/sarama v1.29.0/go.mod h1:2QpgD79wpdAESqNQMxNc0KYMkycd4slxGdV3TWSVqrU=
github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc= github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc=
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
github.com/aliyun/aliyun-oss-go-sdk v2.2.8+incompatible h1:6JF1bjhT0WN2srEmijfOFtVWwV91KZ6dJY1/JbdtGrI= github.com/aliyun/aliyun-oss-go-sdk v2.2.7+incompatible h1:KpbJFXwhVeuxNtBJ74MCGbIoaBok2uZvkD7QXp2+Wis=
github.com/aliyun/aliyun-oss-go-sdk v2.2.8+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8= github.com/aliyun/aliyun-oss-go-sdk v2.2.7+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
@@ -100,8 +100,8 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.15.0 h1:nDU5XeOKtB3GEa+uB7GNYwhVKsgjAR7VgKoNB6ryXfw= github.com/go-playground/validator/v10 v10.14.1 h1:9c50NUPC30zyuKprjL3vNZ0m5oG+jU0zvx4AqHGnv4k=
github.com/go-playground/validator/v10 v10.15.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/go-playground/validator/v10 v10.14.1/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/go-redis/redis v6.15.9+incompatible h1:K0pv1D7EQUjfyoMql+r/jZqCLizCGKFlFgcHWWmHQjg= github.com/go-redis/redis v6.15.9+incompatible h1:K0pv1D7EQUjfyoMql+r/jZqCLizCGKFlFgcHWWmHQjg=
github.com/go-redis/redis v6.15.9+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= github.com/go-redis/redis v6.15.9+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
@@ -338,8 +338,8 @@ github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7Jul
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.mongodb.org/mongo-driver v1.12.1 h1:nLkghSU8fQNaK7oUmDhQFsnrtcoNy7Z6LVFKsEecqgE= go.mongodb.org/mongo-driver v1.12.0 h1:aPx33jmn/rQuJXPQLZQ8NtfPQG8CaqgLThFtqRb0PiE=
go.mongodb.org/mongo-driver v1.12.1/go.mod h1:/rGBTebI3XYboVmgz+Wv3Bcbl3aD0QF9zl6kDDw18rQ= go.mongodb.org/mongo-driver v1.12.0/go.mod h1:AZkxhPnFJUoH7kZlFkVKucV20K387miPfm7oimrSmK0=
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= 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.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
@@ -463,8 +463,8 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk=
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8=
google.golang.org/api v0.135.0 h1:6Vgfj6uPMXcyy66waYWBwmkeNB+9GmUlJDOzkukPQYQ= google.golang.org/api v0.134.0 h1:ktL4Goua+UBgoP1eL1/60LwZJqa1sIzkLmvoR3hR6Gw=
google.golang.org/api v0.135.0/go.mod h1:Bp77uRFgwsSKI0BWH573F5Q6wSlznwI2NFayLOp/7mQ= google.golang.org/api v0.134.0/go.mod h1:sjRL3UnjTx5UqNQS9EWr9N8p7xbHpy1k0XGRLCf3Spk=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
@@ -477,8 +477,8 @@ google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130 h1:Au6te5hbKUV8pIY
google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130/go.mod h1:O9kGHb51iE/nOGvQaDUuadVYqovW56s5emA88lQnj6Y= google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130/go.mod h1:O9kGHb51iE/nOGvQaDUuadVYqovW56s5emA88lQnj6Y=
google.golang.org/genproto/googleapis/api v0.0.0-20230706204954-ccb25ca9f130 h1:XVeBY8d/FaK4848myy41HBqnDwvxeV3zMZhwN1TvAMU= google.golang.org/genproto/googleapis/api v0.0.0-20230706204954-ccb25ca9f130 h1:XVeBY8d/FaK4848myy41HBqnDwvxeV3zMZhwN1TvAMU=
google.golang.org/genproto/googleapis/api v0.0.0-20230706204954-ccb25ca9f130/go.mod h1:mPBs5jNgx2GuQGvFwUvVKqtn6HsUw9nP64BedgvqEsQ= google.golang.org/genproto/googleapis/api v0.0.0-20230706204954-ccb25ca9f130/go.mod h1:mPBs5jNgx2GuQGvFwUvVKqtn6HsUw9nP64BedgvqEsQ=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230726155614-23370e0ffb3e h1:S83+ibolgyZ0bqz7KEsUOPErxcv4VzlszxY+31OfB/E= google.golang.org/genproto/googleapis/rpc v0.0.0-20230720185612-659f7aaaa771 h1:Z8qdAF9GFsmcUuWQ5KVYIpP3PCKydn/YKORnghIalu4=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230726155614-23370e0ffb3e/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= google.golang.org/genproto/googleapis/rpc v0.0.0-20230720185612-659f7aaaa771/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
-8
View File
@@ -1,8 +0,0 @@
go 1.20
use (
.
./tools/changelog
./tools/infra
./tools/ncpu
)
-9
View File
@@ -1,9 +0,0 @@
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
-1
View File
@@ -1,5 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright © 2023 OpenIM. All rights reserved. # Copyright © 2023 OpenIM. All rights reserved.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
+1 -2
View File
@@ -17,10 +17,9 @@ package api
import ( import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/protocol/auth" "github.com/OpenIMSDK/protocol/auth"
"github.com/OpenIMSDK/tools/a2r" "github.com/OpenIMSDK/tools/a2r"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
) )
type AuthApi rpcclient.Auth type AuthApi rpcclient.Auth
+1 -2
View File
@@ -17,10 +17,9 @@ package api
import ( import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/protocol/conversation" "github.com/OpenIMSDK/protocol/conversation"
"github.com/OpenIMSDK/tools/a2r" "github.com/OpenIMSDK/tools/a2r"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
) )
type ConversationApi rpcclient.Conversation type ConversationApi rpcclient.Conversation
+1 -2
View File
@@ -15,11 +15,10 @@
package api package api
import ( import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/protocol/friend" "github.com/OpenIMSDK/protocol/friend"
"github.com/OpenIMSDK/tools/a2r" "github.com/OpenIMSDK/tools/a2r"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
+1 -2
View File
@@ -15,11 +15,10 @@
package api package api
import ( import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/protocol/group" "github.com/OpenIMSDK/protocol/group"
"github.com/OpenIMSDK/tools/a2r" "github.com/OpenIMSDK/tools/a2r"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
+4 -6
View File
@@ -15,15 +15,16 @@
package api package api
import ( import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/authverify"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/tools/mcontext" "github.com/OpenIMSDK/tools/mcontext"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10"
"github.com/mitchellh/mapstructure" "github.com/mitchellh/mapstructure"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
"github.com/OpenIMSDK/Open-IM-Server/pkg/authverify" "github.com/OpenIMSDK/Open-IM-Server/pkg/apistruct"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/protocol/msg" "github.com/OpenIMSDK/protocol/msg"
"github.com/OpenIMSDK/protocol/sdkws" "github.com/OpenIMSDK/protocol/sdkws"
@@ -32,9 +33,6 @@ import (
"github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/tools/utils" "github.com/OpenIMSDK/tools/utils"
"github.com/OpenIMSDK/Open-IM-Server/pkg/apistruct"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
) )
type MessageApi struct { type MessageApi struct {
+8 -10
View File
@@ -16,16 +16,14 @@ package api
import ( import (
"context" "context"
"net/http" "github.com/OpenIMSDK/Open-IM-Server/pkg/authverify"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
"github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/tools/apiresp" "github.com/OpenIMSDK/tools/apiresp"
"github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/tokenverify" "github.com/OpenIMSDK/tools/tokenverify"
"net/http"
"github.com/OpenIMSDK/Open-IM-Server/pkg/authverify"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding" "github.com/gin-gonic/gin/binding"
@@ -34,13 +32,12 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/credentials/insecure"
"github.com/OpenIMSDK/tools/discoveryregistry"
"github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/tools/mw"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/tools/discoveryregistry"
"github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/tools/mw"
) )
func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.UniversalClient) *gin.Engine { func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.UniversalClient) *gin.Engine {
@@ -85,6 +82,7 @@ func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.Unive
userRouterGroup.POST("/subscribe_users_status", ParseToken, u.UnSubscriberStatus) userRouterGroup.POST("/subscribe_users_status", ParseToken, u.UnSubscriberStatus)
userRouterGroup.POST("/unsubscribe_users_status", ParseToken, u.UnSubscriberStatus) userRouterGroup.POST("/unsubscribe_users_status", ParseToken, u.UnSubscriberStatus)
userRouterGroup.POST("/get_users_status", ParseToken, u.GetUserStatus) userRouterGroup.POST("/get_users_status", ParseToken, u.GetUserStatus)
} }
// friend routing group // friend routing group
friendRouterGroup := r.Group("/friend", ParseToken) friendRouterGroup := r.Group("/friend", ParseToken)
+1 -2
View File
@@ -17,10 +17,9 @@ package api
import ( import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/protocol/user" "github.com/OpenIMSDK/protocol/user"
"github.com/OpenIMSDK/tools/a2r" "github.com/OpenIMSDK/tools/a2r"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
) )
type StatisticsApi rpcclient.User type StatisticsApi rpcclient.User
+2 -4
View File
@@ -15,18 +15,16 @@
package api package api
import ( import (
"github.com/gin-gonic/gin"
"math/rand" "math/rand"
"net/http" "net/http"
"strconv" "strconv"
"github.com/gin-gonic/gin" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/protocol/third" "github.com/OpenIMSDK/protocol/third"
"github.com/OpenIMSDK/tools/a2r" "github.com/OpenIMSDK/tools/a2r"
"github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/mcontext" "github.com/OpenIMSDK/tools/mcontext"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
) )
type ThirdApi rpcclient.Third type ThirdApi rpcclient.Third
+2 -3
View File
@@ -17,6 +17,8 @@ package api
import ( import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/protocol/msggateway" "github.com/OpenIMSDK/protocol/msggateway"
"github.com/OpenIMSDK/protocol/user" "github.com/OpenIMSDK/protocol/user"
@@ -24,9 +26,6 @@ import (
"github.com/OpenIMSDK/tools/apiresp" "github.com/OpenIMSDK/tools/apiresp"
"github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
) )
type UserApi rpcclient.User type UserApi rpcclient.User
+2 -3
View File
@@ -18,12 +18,11 @@ import (
"context" "context"
"time" "time"
"github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/tools/mcontext"
cbapi "github.com/OpenIMSDK/Open-IM-Server/pkg/callbackstruct" cbapi "github.com/OpenIMSDK/Open-IM-Server/pkg/callbackstruct"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/http" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/http"
"github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/tools/mcontext"
) )
func url() string { func url() string {
+1 -2
View File
@@ -18,11 +18,10 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/OpenIMSDK/Open-IM-Server/pkg/msgprocessor"
"runtime/debug" "runtime/debug"
"sync" "sync"
"github.com/OpenIMSDK/Open-IM-Server/pkg/msgprocessor"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
"github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/constant"
+4 -7
View File
@@ -16,23 +16,20 @@ package msggateway
import ( import (
"context" "context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/authverify" "github.com/OpenIMSDK/Open-IM-Server/pkg/authverify"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/errs"
"google.golang.org/grpc" "google.golang.org/grpc"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/startrpc"
"github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/protocol/msggateway" "github.com/OpenIMSDK/protocol/msggateway"
"github.com/OpenIMSDK/tools/discoveryregistry" "github.com/OpenIMSDK/tools/discoveryregistry"
"github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/tools/utils" "github.com/OpenIMSDK/tools/utils"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/startrpc"
) )
func (s *Server) InitServer(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error { func (s *Server) InitServer(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error {
+1 -2
View File
@@ -23,11 +23,10 @@ import (
"github.com/go-playground/validator/v10" "github.com/go-playground/validator/v10"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/protocol/msg" "github.com/OpenIMSDK/protocol/msg"
"github.com/OpenIMSDK/protocol/sdkws" "github.com/OpenIMSDK/protocol/sdkws"
"github.com/OpenIMSDK/tools/utils" "github.com/OpenIMSDK/tools/utils"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
) )
type Req struct { type Req struct {
+5 -6
View File
@@ -17,19 +17,17 @@ package msggateway
import ( import (
"context" "context"
"errors" "errors"
"github.com/OpenIMSDK/Open-IM-Server/pkg/authverify"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"net/http" "net/http"
"strconv" "strconv"
"sync" "sync"
"sync/atomic" "sync/atomic"
"time" "time"
"github.com/OpenIMSDK/Open-IM-Server/pkg/authverify"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/protocol/constant"
"github.com/redis/go-redis/v9" "github.com/redis/go-redis/v9"
@@ -93,7 +91,6 @@ func (ws *WsServer) SetDiscoveryRegistry(client discoveryregistry.SvcDiscoveryRe
u := rpcclient.NewUserRpcClient(client) u := rpcclient.NewUserRpcClient(client)
ws.userClient = &u ws.userClient = &u
} }
func (ws *WsServer) SetUserOnlineStatus(ctx context.Context, client *Client, status int32) { func (ws *WsServer) SetUserOnlineStatus(ctx context.Context, client *Client, status int32) {
err := ws.userClient.SetUserStatus(ctx, client.UserID, status, client.PlatformID) err := ws.userClient.SetUserStatus(ctx, client.UserID, status, client.PlatformID)
if err != nil { if err != nil {
@@ -110,7 +107,9 @@ func (ws *WsServer) SetUserOnlineStatus(ctx context.Context, client *Client, sta
if err != nil { if err != nil {
log.ZWarn(ctx, "CallbackUserOffline err", err) log.ZWarn(ctx, "CallbackUserOffline err", err)
} }
} }
} }
func (ws *WsServer) SetCacheHandler(cache cache.MsgModel) { func (ws *WsServer) SetCacheHandler(cache cache.MsgModel) {
+3 -4
View File
@@ -22,10 +22,6 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/credentials/insecure"
openKeeper "github.com/OpenIMSDK/tools/discoveryregistry/zookeeper"
"github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/tools/mw"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
@@ -34,6 +30,9 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
openKeeper "github.com/OpenIMSDK/tools/discoveryregistry/zookeeper"
"github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/tools/mw"
) )
type MsgTransfer struct { type MsgTransfer struct {
@@ -16,29 +16,27 @@ package msgtransfer
import ( import (
"context" "context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/msgprocessor"
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
"time" "time"
"github.com/OpenIMSDK/Open-IM-Server/pkg/msgprocessor"
"github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/errs"
"github.com/Shopify/sarama" "github.com/Shopify/sarama"
"github.com/go-redis/redis" "github.com/go-redis/redis"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/kafka"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/protocol/sdkws" "github.com/OpenIMSDK/protocol/sdkws"
"github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/tools/mcontext" "github.com/OpenIMSDK/tools/mcontext"
"github.com/OpenIMSDK/tools/utils" "github.com/OpenIMSDK/tools/utils"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/kafka"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
) )
const ( const (
@@ -20,12 +20,11 @@ import (
"github.com/Shopify/sarama" "github.com/Shopify/sarama"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
pbMsg "github.com/OpenIMSDK/protocol/msg"
"github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
kfk "github.com/OpenIMSDK/Open-IM-Server/pkg/common/kafka" kfk "github.com/OpenIMSDK/Open-IM-Server/pkg/common/kafka"
pbMsg "github.com/OpenIMSDK/protocol/msg"
"github.com/OpenIMSDK/tools/log"
) )
type OnlineHistoryMongoConsumerHandler struct { type OnlineHistoryMongoConsumerHandler struct {
@@ -17,15 +17,14 @@ package msgtransfer
import ( import (
"context" "context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
kfk "github.com/OpenIMSDK/Open-IM-Server/pkg/common/kafka"
"github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/constant"
pbMsg "github.com/OpenIMSDK/protocol/msg" pbMsg "github.com/OpenIMSDK/protocol/msg"
"github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/tools/utils" "github.com/OpenIMSDK/tools/utils"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
kfk "github.com/OpenIMSDK/Open-IM-Server/pkg/common/kafka"
"github.com/Shopify/sarama" "github.com/Shopify/sarama"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
+3 -4
View File
@@ -17,15 +17,14 @@ package push
import ( import (
"context" "context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/callbackstruct"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/http"
"github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/protocol/sdkws" "github.com/OpenIMSDK/protocol/sdkws"
"github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/mcontext" "github.com/OpenIMSDK/tools/mcontext"
"github.com/OpenIMSDK/tools/utils" "github.com/OpenIMSDK/tools/utils"
"github.com/OpenIMSDK/Open-IM-Server/pkg/callbackstruct"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/http"
) )
func url() string { func url() string {
+2 -4
View File
@@ -16,20 +16,18 @@ package fcm
import ( import (
"context" "context"
"path/filepath"
config2 "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" config2 "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"path/filepath"
firebase "firebase.google.com/go" firebase "firebase.google.com/go"
"firebase.google.com/go/messaging" "firebase.google.com/go/messaging"
"github.com/redis/go-redis/v9" "github.com/redis/go-redis/v9"
"google.golang.org/api/option" "google.golang.org/api/option"
"github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush" "github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/protocol/constant"
) )
const SinglePushCountLimit = 400 const SinglePushCountLimit = 400
+4 -5
View File
@@ -25,15 +25,14 @@ import (
"github.com/go-redis/redis" "github.com/go-redis/redis"
"github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/tools/mcontext"
"github.com/OpenIMSDK/tools/utils/splitter"
"github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush" "github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
http2 "github.com/OpenIMSDK/Open-IM-Server/pkg/common/http" http2 "github.com/OpenIMSDK/Open-IM-Server/pkg/common/http"
"github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/tools/mcontext"
"github.com/OpenIMSDK/tools/utils/splitter"
"github.com/OpenIMSDK/tools/utils" "github.com/OpenIMSDK/tools/utils"
) )
+2 -3
View File
@@ -20,14 +20,13 @@ import (
"github.com/Shopify/sarama" "github.com/Shopify/sarama"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
kfk "github.com/OpenIMSDK/Open-IM-Server/pkg/common/kafka"
"github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/constant"
pbChat "github.com/OpenIMSDK/protocol/msg" pbChat "github.com/OpenIMSDK/protocol/msg"
pbPush "github.com/OpenIMSDK/protocol/push" pbPush "github.com/OpenIMSDK/protocol/push"
"github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/tools/utils" "github.com/OpenIMSDK/tools/utils"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
kfk "github.com/OpenIMSDK/Open-IM-Server/pkg/common/kafka"
) )
type ConsumerHandler struct { type ConsumerHandler struct {
+4 -5
View File
@@ -20,15 +20,14 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
"github.com/OpenIMSDK/protocol/constant"
pbPush "github.com/OpenIMSDK/protocol/push"
"github.com/OpenIMSDK/tools/discoveryregistry"
"github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/localcache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/localcache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/protocol/constant"
pbPush "github.com/OpenIMSDK/protocol/push"
"github.com/OpenIMSDK/tools/discoveryregistry"
"github.com/OpenIMSDK/tools/log"
) )
type pushServer struct { type pushServer struct {
+7 -9
View File
@@ -18,17 +18,8 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"errors" "errors"
"github.com/OpenIMSDK/Open-IM-Server/pkg/msgprocessor" "github.com/OpenIMSDK/Open-IM-Server/pkg/msgprocessor"
"github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/protocol/msggateway"
"github.com/OpenIMSDK/protocol/sdkws"
"github.com/OpenIMSDK/tools/discoveryregistry"
"github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/tools/mcontext"
"github.com/OpenIMSDK/tools/utils"
"github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush" "github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush"
"github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush/fcm" "github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush/fcm"
"github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush/getui" "github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush/getui"
@@ -39,6 +30,13 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/localcache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/localcache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/protocol/msggateway"
"github.com/OpenIMSDK/protocol/sdkws"
"github.com/OpenIMSDK/tools/discoveryregistry"
"github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/tools/mcontext"
"github.com/OpenIMSDK/tools/utils"
) )
type Pusher struct { type Pusher struct {
-14
View File
@@ -1,17 +1,3 @@
// Copyright © 2023 OpenIM. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package push package push
import ( import (
+4 -6
View File
@@ -16,11 +16,14 @@ package auth
import ( import (
"context" "context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/authverify" "github.com/OpenIMSDK/Open-IM-Server/pkg/authverify"
"google.golang.org/grpc" "google.golang.org/grpc"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
pbAuth "github.com/OpenIMSDK/protocol/auth" pbAuth "github.com/OpenIMSDK/protocol/auth"
"github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/protocol/msggateway" "github.com/OpenIMSDK/protocol/msggateway"
@@ -30,11 +33,6 @@ import (
"github.com/OpenIMSDK/tools/mcontext" "github.com/OpenIMSDK/tools/mcontext"
"github.com/OpenIMSDK/tools/tokenverify" "github.com/OpenIMSDK/tools/tokenverify"
"github.com/OpenIMSDK/tools/utils" "github.com/OpenIMSDK/tools/utils"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
) )
type authServer struct { type authServer struct {
+7 -9
View File
@@ -16,19 +16,10 @@ package conversation
import ( import (
"context" "context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/msgprocessor" "github.com/OpenIMSDK/Open-IM-Server/pkg/msgprocessor"
"google.golang.org/grpc" "google.golang.org/grpc"
"github.com/OpenIMSDK/protocol/constant"
pbConversation "github.com/OpenIMSDK/protocol/conversation"
"github.com/OpenIMSDK/tools/discoveryregistry"
"github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/tools/tx"
"github.com/OpenIMSDK/tools/utils"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
@@ -36,6 +27,13 @@ import (
tableRelation "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation" tableRelation "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification"
"github.com/OpenIMSDK/protocol/constant"
pbConversation "github.com/OpenIMSDK/protocol/conversation"
"github.com/OpenIMSDK/tools/discoveryregistry"
"github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/tools/tx"
"github.com/OpenIMSDK/tools/utils"
) )
type conversationServer struct { type conversationServer struct {
+3 -5
View File
@@ -16,15 +16,13 @@ package friend
import ( import (
"context" "context"
"time"
"github.com/OpenIMSDK/Open-IM-Server/pkg/authverify" "github.com/OpenIMSDK/Open-IM-Server/pkg/authverify"
"time"
pbFriend "github.com/OpenIMSDK/protocol/friend"
"github.com/OpenIMSDK/tools/mcontext"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
pbFriend "github.com/OpenIMSDK/protocol/friend"
"github.com/OpenIMSDK/tools/mcontext"
) )
func (s *friendServer) GetPaginationBlacks( func (s *friendServer) GetPaginationBlacks(
+3 -4
View File
@@ -17,14 +17,13 @@ package friend
import ( import (
"context" "context"
cbapi "github.com/OpenIMSDK/Open-IM-Server/pkg/callbackstruct"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/http"
"github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/constant"
pbfriend "github.com/OpenIMSDK/protocol/friend" pbfriend "github.com/OpenIMSDK/protocol/friend"
"github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/mcontext" "github.com/OpenIMSDK/tools/mcontext"
cbapi "github.com/OpenIMSDK/Open-IM-Server/pkg/callbackstruct"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/http"
) )
func CallbackBeforeAddFriend(ctx context.Context, req *pbfriend.ApplyToAddFriendReq) error { func CallbackBeforeAddFriend(ctx context.Context, req *pbfriend.ApplyToAddFriendReq) error {
+7 -10
View File
@@ -16,28 +16,25 @@ package friend
import ( import (
"context" "context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/authverify" "github.com/OpenIMSDK/Open-IM-Server/pkg/authverify"
"github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/tools/log"
"google.golang.org/grpc" "google.golang.org/grpc"
"github.com/OpenIMSDK/protocol/constant"
pbfriend "github.com/OpenIMSDK/protocol/friend"
registry "github.com/OpenIMSDK/tools/discoveryregistry"
"github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/tx"
"github.com/OpenIMSDK/tools/utils"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation"
tablerelation "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation" tablerelation "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification"
"github.com/OpenIMSDK/protocol/constant"
pbfriend "github.com/OpenIMSDK/protocol/friend"
registry "github.com/OpenIMSDK/tools/discoveryregistry"
"github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/tx"
"github.com/OpenIMSDK/tools/utils"
) )
type friendServer struct { type friendServer struct {
+1 -2
View File
@@ -17,9 +17,8 @@ package group
import ( import (
"context" "context"
pbGroup "github.com/OpenIMSDK/protocol/group"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
pbGroup "github.com/OpenIMSDK/protocol/group"
) )
func (s *groupServer) GetGroupInfoCache( func (s *groupServer) GetGroupInfoCache(
+5 -6
View File
@@ -18,18 +18,17 @@ import (
"context" "context"
"time" "time"
"github.com/OpenIMSDK/Open-IM-Server/pkg/apistruct"
"github.com/OpenIMSDK/Open-IM-Server/pkg/callbackstruct"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/http"
"github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/protocol/group" "github.com/OpenIMSDK/protocol/group"
"github.com/OpenIMSDK/protocol/wrapperspb" "github.com/OpenIMSDK/protocol/wrapperspb"
"github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/mcontext" "github.com/OpenIMSDK/tools/mcontext"
"github.com/OpenIMSDK/tools/utils" "github.com/OpenIMSDK/tools/utils"
"github.com/OpenIMSDK/Open-IM-Server/pkg/apistruct"
"github.com/OpenIMSDK/Open-IM-Server/pkg/callbackstruct"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/http"
) )
func CallbackBeforeCreateGroup(ctx context.Context, req *group.CreateGroupReq) (err error) { func CallbackBeforeCreateGroup(ctx context.Context, req *group.CreateGroupReq) (err error) {
+1 -2
View File
@@ -15,9 +15,8 @@
package group package group
import ( import (
"github.com/OpenIMSDK/protocol/sdkws"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/protocol/sdkws"
) )
func (s *groupServer) groupDB2PB(group *relation.GroupModel, ownerUserID string, memberCount uint32) *sdkws.GroupInfo { func (s *groupServer) groupDB2PB(group *relation.GroupModel, ownerUserID string, memberCount uint32) *sdkws.GroupInfo {
+1 -2
View File
@@ -17,9 +17,8 @@ package group
import ( import (
"context" "context"
"github.com/OpenIMSDK/tools/utils"
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation" relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/tools/utils"
) )
func (s *groupServer) FindGroupMember( func (s *groupServer) FindGroupMember(
+6 -8
View File
@@ -31,13 +31,17 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification"
"github.com/OpenIMSDK/tools/mw/specialerror"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/tools/mw/specialerror"
"google.golang.org/grpc" "google.golang.org/grpc"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation"
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation"
"github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/constant"
pbGroup "github.com/OpenIMSDK/protocol/group" pbGroup "github.com/OpenIMSDK/protocol/group"
"github.com/OpenIMSDK/protocol/sdkws" "github.com/OpenIMSDK/protocol/sdkws"
@@ -46,12 +50,6 @@ import (
"github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/tools/mcontext" "github.com/OpenIMSDK/tools/mcontext"
"github.com/OpenIMSDK/tools/utils" "github.com/OpenIMSDK/tools/utils"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation"
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation"
) )
func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error { func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error {
+3 -4
View File
@@ -19,15 +19,14 @@ import (
"fmt" "fmt"
"strings" "strings"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
"github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/constant"
pbGroup "github.com/OpenIMSDK/protocol/group" pbGroup "github.com/OpenIMSDK/protocol/group"
sdkws "github.com/OpenIMSDK/protocol/sdkws" sdkws "github.com/OpenIMSDK/protocol/sdkws"
"github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/utils" "github.com/OpenIMSDK/tools/utils"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
) )
func (s *groupServer) GetJoinedSuperGroupList( func (s *groupServer) GetJoinedSuperGroupList(
+3 -5
View File
@@ -16,20 +16,18 @@ package msg
import ( import (
"context" "context"
"github.com/OpenIMSDK/protocol/sdkws" "github.com/OpenIMSDK/protocol/sdkws"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
cbapi "github.com/OpenIMSDK/Open-IM-Server/pkg/callbackstruct"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/http"
"github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/constant"
pbChat "github.com/OpenIMSDK/protocol/msg" pbChat "github.com/OpenIMSDK/protocol/msg"
"github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/tools/mcontext" "github.com/OpenIMSDK/tools/mcontext"
"github.com/OpenIMSDK/tools/utils" "github.com/OpenIMSDK/tools/utils"
cbapi "github.com/OpenIMSDK/Open-IM-Server/pkg/callbackstruct"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/http"
) )
func cbURL() string { func cbURL() string {
-1
View File
@@ -16,7 +16,6 @@ package msg
import ( import (
"context" "context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/authverify" "github.com/OpenIMSDK/Open-IM-Server/pkg/authverify"
"github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/constant"
+1 -2
View File
@@ -17,12 +17,11 @@ package msg
import ( import (
"context" "context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/protocol/msg" "github.com/OpenIMSDK/protocol/msg"
"github.com/OpenIMSDK/protocol/sdkws" "github.com/OpenIMSDK/protocol/sdkws"
"github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
) )
type MessageInterceptorFunc func(ctx context.Context, req *msg.SendMsgReq) (*sdkws.MsgData, error) type MessageInterceptorFunc func(ctx context.Context, req *msg.SendMsgReq) (*sdkws.MsgData, error)
+2 -4
View File
@@ -17,18 +17,16 @@ package msg
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"github.com/OpenIMSDK/Open-IM-Server/pkg/authverify"
"time" "time"
"github.com/OpenIMSDK/Open-IM-Server/pkg/authverify" unRelationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
"github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/protocol/msg" "github.com/OpenIMSDK/protocol/msg"
"github.com/OpenIMSDK/protocol/sdkws" "github.com/OpenIMSDK/protocol/sdkws"
"github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/tools/utils" "github.com/OpenIMSDK/tools/utils"
unRelationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
) )
func (m *msgServer) RevokeMsg(ctx context.Context, req *msg.RevokeMsgReq) (*msg.RevokeMsgResp, error) { func (m *msgServer) RevokeMsg(ctx context.Context, req *msg.RevokeMsgReq) (*msg.RevokeMsgResp, error) {
+2 -4
View File
@@ -16,9 +16,9 @@ package msg
import ( import (
"context" "context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/msgprocessor" "github.com/OpenIMSDK/Open-IM-Server/pkg/msgprocessor"
promePkg "github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome"
"github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/constant"
pbConversation "github.com/OpenIMSDK/protocol/conversation" pbConversation "github.com/OpenIMSDK/protocol/conversation"
pbMsg "github.com/OpenIMSDK/protocol/msg" pbMsg "github.com/OpenIMSDK/protocol/msg"
@@ -28,8 +28,6 @@ import (
"github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/tools/mcontext" "github.com/OpenIMSDK/tools/mcontext"
"github.com/OpenIMSDK/tools/utils" "github.com/OpenIMSDK/tools/utils"
promePkg "github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome"
) )
func (m *msgServer) SendMsg(ctx context.Context, req *pbMsg.SendMsgReq) (resp *pbMsg.SendMsgResp, error error) { func (m *msgServer) SendMsg(ctx context.Context, req *pbMsg.SendMsgReq) (resp *pbMsg.SendMsgResp, error error) {
@@ -151,7 +149,7 @@ func (m *msgServer) sendMsgSingleChat(ctx context.Context, req *pbMsg.SendMsgReq
if err := m.messageVerification(ctx, req); err != nil { if err := m.messageVerification(ctx, req); err != nil {
return nil, err return nil, err
} }
isSend := true var isSend = true
isNotification := msgprocessor.IsNotificationByMsg(req.MsgData) isNotification := msgprocessor.IsNotificationByMsg(req.MsgData)
if !isNotification { if !isNotification {
isSend, err = m.modifyMessageByUserMessageReceiveOpt( isSend, err = m.modifyMessageByUserMessageReceiveOpt(
+4 -5
View File
@@ -19,17 +19,16 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
"github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/protocol/conversation"
"github.com/OpenIMSDK/protocol/msg"
"github.com/OpenIMSDK/tools/discoveryregistry"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/localcache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/localcache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/protocol/conversation"
"github.com/OpenIMSDK/protocol/msg"
"github.com/OpenIMSDK/tools/discoveryregistry"
) )
type ( type (
+1 -2
View File
@@ -18,11 +18,10 @@ import (
"context" "context"
"time" "time"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
"github.com/OpenIMSDK/protocol/msg" "github.com/OpenIMSDK/protocol/msg"
"github.com/OpenIMSDK/protocol/sdkws" "github.com/OpenIMSDK/protocol/sdkws"
"github.com/OpenIMSDK/tools/utils" "github.com/OpenIMSDK/tools/utils"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
) )
func (m *msgServer) GetActiveUser(ctx context.Context, req *msg.GetActiveUserReq) (*msg.GetActiveUserResp, error) { func (m *msgServer) GetActiveUser(ctx context.Context, req *msg.GetActiveUserReq) (*msg.GetActiveUserResp, error) {
-1
View File
@@ -16,7 +16,6 @@ package msg
import ( import (
"context" "context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/authverify" "github.com/OpenIMSDK/Open-IM-Server/pkg/authverify"
"github.com/OpenIMSDK/Open-IM-Server/pkg/msgprocessor" "github.com/OpenIMSDK/Open-IM-Server/pkg/msgprocessor"
+1 -2
View File
@@ -18,11 +18,10 @@ import (
"github.com/redis/go-redis/v9" "github.com/redis/go-redis/v9"
"gorm.io/gorm" "gorm.io/gorm"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/protocol/sdkws" "github.com/OpenIMSDK/protocol/sdkws"
"github.com/OpenIMSDK/tools/utils" "github.com/OpenIMSDK/tools/utils"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
) )
func isMessageHasReadEnabled(msgData *sdkws.MsgData) bool { func isMessageHasReadEnabled(msgData *sdkws.MsgData) bool {
+1 -2
View File
@@ -20,13 +20,12 @@ import (
"strconv" "strconv"
"time" "time"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/protocol/msg" "github.com/OpenIMSDK/protocol/msg"
"github.com/OpenIMSDK/protocol/sdkws" "github.com/OpenIMSDK/protocol/sdkws"
"github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/utils" "github.com/OpenIMSDK/tools/utils"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
) )
var ExcludeContentType = []int{constant.HasReadReceipt} var ExcludeContentType = []int{constant.HasReadReceipt}
+2 -3
View File
@@ -18,14 +18,13 @@ import (
"context" "context"
"time" "time"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/cont"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/protocol/third" "github.com/OpenIMSDK/protocol/third"
"github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/tools/mcontext" "github.com/OpenIMSDK/tools/mcontext"
"github.com/OpenIMSDK/tools/utils" "github.com/OpenIMSDK/tools/utils"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/cont"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
) )
func (t *thirdServer) PartLimit(ctx context.Context, req *third.PartLimitReq) (*third.PartLimitResp, error) { func (t *thirdServer) PartLimit(ctx context.Context, req *third.PartLimitReq) (*third.PartLimitResp, error) {
+2 -3
View File
@@ -27,15 +27,14 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
"github.com/OpenIMSDK/protocol/third"
"github.com/OpenIMSDK/tools/discoveryregistry"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation"
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation" relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/protocol/third"
"github.com/OpenIMSDK/tools/discoveryregistry"
) )
func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error { func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error {
+1 -2
View File
@@ -18,11 +18,10 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/OpenIMSDK/Open-IM-Server/pkg/authverify"
"strings" "strings"
"unicode/utf8" "unicode/utf8"
"github.com/OpenIMSDK/Open-IM-Server/pkg/authverify"
"github.com/OpenIMSDK/protocol/third" "github.com/OpenIMSDK/protocol/third"
"github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/mcontext" "github.com/OpenIMSDK/tools/mcontext"
+14 -26
View File
@@ -17,20 +17,11 @@ package user
import ( import (
"context" "context"
"errors" "errors"
"strings"
"time"
"github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/authverify" "github.com/OpenIMSDK/Open-IM-Server/pkg/authverify"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/unrelation"
"github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/protocol/constant" "strings"
"github.com/OpenIMSDK/protocol/sdkws" "time"
pbuser "github.com/OpenIMSDK/protocol/user"
registry "github.com/OpenIMSDK/tools/discoveryregistry"
"github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/tx"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
@@ -40,6 +31,12 @@ import (
tablerelation "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation" tablerelation "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification" "github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification"
"github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/protocol/sdkws"
pbuser "github.com/OpenIMSDK/protocol/user"
registry "github.com/OpenIMSDK/tools/discoveryregistry"
"github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/tx"
"google.golang.org/grpc" "google.golang.org/grpc"
@@ -253,27 +250,18 @@ func (s *userServer) GetAllUserID(ctx context.Context, req *pbuser.GetAllUserIDR
// SubscribeOrCancelUsersStatus Subscribe online or cancel online users. // SubscribeOrCancelUsersStatus Subscribe online or cancel online users.
func (s *userServer) SubscribeOrCancelUsersStatus(ctx context.Context, req *pbuser.SubscribeOrCancelUsersStatusReq) (resp *pbuser.SubscribeOrCancelUsersStatusResp, err error) { func (s *userServer) SubscribeOrCancelUsersStatus(ctx context.Context, req *pbuser.SubscribeOrCancelUsersStatusReq) (resp *pbuser.SubscribeOrCancelUsersStatusResp, err error) {
if req.Genre == constant.SubscriberUser { err = s.UserDatabase.SubscribeOrCancelUsersStatus(ctx, req.UserID, req.UserIDs, req.Genre)
err = s.UserDatabase.SubscribeUsersStatus(ctx, req.UserID, req.UserIDs)
if err != nil { if err != nil {
return nil, err return nil, err
} }
var status []*pbuser.OnlineStatus //var status map[string][]string
status, err = s.UserDatabase.GetUserStatus(ctx, req.UserIDs) //TODO 获取用户在线列表,返回订阅的用户的在线列表
if err != nil {
return nil, err
}
return &pbuser.SubscribeOrCancelUsersStatusResp{StatusList: status}, nil
} else if req.Genre == constant.Unsubscribe {
err = s.UserDatabase.UnsubscribeUsersStatus(ctx, req.UserID, req.UserIDs)
if err != nil {
return nil, err
}
}
return &pbuser.SubscribeOrCancelUsersStatusResp{}, nil return &pbuser.SubscribeOrCancelUsersStatusResp{}, nil
} }
func (s *userServer) GetUserStatus(ctx context.Context, req *pbuser.GetUserStatusReq) (resp *pbuser.GetUserStatusResp, err error) { func (s *userServer) GetUserStatus(ctx context.Context, req *pbuser.GetUserStatusReq) (resp *pbuser.GetUserStatusResp, err error) {
//TODO 是否加一个参数校验-判断req.userID的数量,每一个获取加一个限制,一次请求限制500?
onlineStatusList, err := s.UserDatabase.GetUserStatus(ctx, req.UserIDs) onlineStatusList, err := s.UserDatabase.GetUserStatus(ctx, req.UserIDs)
if err != nil { if err != nil {
return nil, err return nil, err

Some files were not shown because too many files have changed in this diff Show More