From f1c9686ada6d195449a5762e14c8312c48263ea3 Mon Sep 17 00:00:00 2001 From: Xinwei Xiong <3293172751@qq.com> Date: Mon, 18 Dec 2023 10:24:12 +0800 Subject: [PATCH] feat: Add OpenIM server, environment support for Docker Compose, and Kubernetes deployment. (#1559) * feat: add openim server code Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: add openim env Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: add openim mongo and redis env Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: add zk and redis mongo env Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: add kafka and redis mongo env Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: add openim docker Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: add openim docker Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: add openim docker Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: add openim copyright Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * fix: docker compose Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * fix: remove openim chat config file Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: add openim config set Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: add openim config set Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * fix: fix Security vulnerability Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * fix: fix Security vulnerability Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * fix: docker compose Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * Update kubernetes.go * Update discoveryregister.go * fix: copyright-add Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> --------- Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> --- .github/workflows/build-docker-image.yml | 3 + .github/workflows/build-openim-web-image.yml | 139 ------ .gitignore | 15 +- config/Readme.md | 243 ++++++++++ config/templates/README.md | 36 -- config/templates/alertmanager.yml.template | 14 + config/templates/config.yaml.template | 17 +- .../email.tmpl.template} | 0 config/templates/env.template | 18 +- .../instance-down-rules.yml.template | 36 ++ config/templates/notification.yaml.template | 354 +++++++++++++++ .../{ => templates}/open-im-ng-example.conf | 0 .../{ => templates}/prometheus-dashboard.yaml | 14 + config/templates/prometheus.yml.template | 14 + deployments/{README.md => Readme.md} | 0 deployments/charts/helmfile.yaml | 14 + deployments/charts/openim-api/Chart.yaml | 14 + .../charts/openim-api/templates/app-cm.yaml | 14 + .../openim-api/templates/deployment.yaml | 14 + .../charts/openim-api/templates/hpa.yaml | 14 + .../charts/openim-api/templates/ingress.yaml | 14 + .../charts/openim-api/templates/service.yaml | 14 + .../openim-api/templates/serviceaccount.yaml | 14 + deployments/charts/openim-api/values.yaml | 14 + .../charts/openim-msggateway/Chart.yaml | 14 + .../openim-msggateway/templates/hpa.yaml | 14 + .../openim-msggateway/templates/ingress.yaml | 14 + .../openim-msggateway/templates/service.yaml | 14 + .../templates/serviceaccount.yaml | 14 + .../charts/openim-msggateway/values.yaml | 14 + .../charts/openim-msgtransfer/Chart.yaml | 14 + .../templates/deployment.yaml | 14 + .../openim-msgtransfer/templates/hpa.yaml | 14 + .../openim-msgtransfer/templates/ingress.yaml | 14 + .../openim-msgtransfer/templates/service.yaml | 14 + .../templates/serviceaccount.yaml | 14 + .../charts/openim-msgtransfer/values.yaml | 14 + deployments/charts/openim-push/Chart.yaml | 14 + .../openim-push/templates/deployment.yaml | 14 + .../charts/openim-push/templates/hpa.yaml | 14 + .../charts/openim-push/templates/ingress.yaml | 14 + .../charts/openim-push/templates/service.yaml | 14 + .../openim-push/templates/serviceaccount.yaml | 14 + deployments/charts/openim-push/values.yaml | 14 + deployments/charts/openim-rpc-auth/Chart.yaml | 14 + .../openim-rpc-auth/templates/deployment.yaml | 14 + .../charts/openim-rpc-auth/templates/hpa.yaml | 14 + .../openim-rpc-auth/templates/ingress.yaml | 14 + .../openim-rpc-auth/templates/service.yaml | 14 + .../templates/serviceaccount.yaml | 14 + .../charts/openim-rpc-auth/values.yaml | 14 + .../charts/openim-rpc-conversation/Chart.yaml | 14 + .../templates/deployment.yaml | 14 + .../templates/hpa.yaml | 14 + .../templates/ingress.yaml | 14 + .../templates/service.yaml | 14 + .../templates/serviceaccount.yaml | 14 + .../openim-rpc-conversation/values.yaml | 14 + .../charts/openim-rpc-friend/Chart.yaml | 14 + .../templates/deployment.yaml | 14 + .../openim-rpc-friend/templates/hpa.yaml | 14 + .../openim-rpc-friend/templates/ingress.yaml | 14 + .../openim-rpc-friend/templates/service.yaml | 14 + .../templates/serviceaccount.yaml | 14 + .../charts/openim-rpc-friend/values.yaml | 14 + .../charts/openim-rpc-group/Chart.yaml | 14 + .../templates/deployment.yaml | 14 + .../openim-rpc-group/templates/hpa.yaml | 14 + .../openim-rpc-group/templates/ingress.yaml | 14 + .../openim-rpc-group/templates/service.yaml | 14 + .../templates/serviceaccount.yaml | 14 + .../charts/openim-rpc-group/values.yaml | 14 + deployments/charts/openim-rpc-msg/Chart.yaml | 14 + .../openim-rpc-msg/templates/deployment.yaml | 14 + .../charts/openim-rpc-msg/templates/hpa.yaml | 14 + .../openim-rpc-msg/templates/ingress.yaml | 14 + .../openim-rpc-msg/templates/service.yaml | 14 + .../templates/serviceaccount.yaml | 14 + deployments/charts/openim-rpc-msg/values.yaml | 14 + .../charts/openim-rpc-third/Chart.yaml | 14 + .../templates/deployment.yaml | 14 + .../openim-rpc-third/templates/hpa.yaml | 14 + .../openim-rpc-third/templates/ingress.yaml | 14 + .../openim-rpc-third/templates/service.yaml | 14 + .../templates/serviceaccount.yaml | 14 + .../charts/openim-rpc-third/values.yaml | 14 + deployments/charts/openim-rpc-user/Chart.yaml | 14 + .../openim-rpc-user/templates/deployment.yaml | 14 + .../charts/openim-rpc-user/templates/hpa.yaml | 14 + .../openim-rpc-user/templates/ingress.yaml | 14 + .../openim-rpc-user/templates/service.yaml | 14 + .../templates/serviceaccount.yaml | 14 + .../charts/openim-rpc-user/values.yaml | 14 + deployments/openim-charts.yaml | 14 + deployments/templates/alertmanager.yml | 14 + deployments/templates/charts-value.yaml | 14 + deployments/templates/chat.yaml | 118 ----- deployments/templates/email.tmpl | 16 + deployments/templates/env-template.yaml | 18 +- deployments/templates/helm-image.yaml | 14 + .../templates}/instance-down-rules.yml | 14 + .../templates}/notification.yaml | 33 +- deployments/templates/openim.yaml | 17 +- deployments/templates/prometheus.yml | 14 + internal/api/msg.go | 1 + internal/msggateway/compressor_test.go | 14 + internal/push/offlinepush/dummy/push.go | 14 + internal/push/push_rpc_server.go | 3 +- internal/rpc/friend/callback.go | 2 + internal/rpc/friend/friend.go | 1 + internal/rpc/group/callback.go | 3 +- internal/rpc/group/group.go | 3 +- internal/rpc/msg/as_read.go | 8 +- internal/rpc/msg/callback.go | 2 + internal/rpc/third/log.go | 14 + internal/rpc/user/callback.go | 1 + internal/tools/cron_task_test.go | 14 + pkg/apistruct/msg.go | 36 +- pkg/callbackstruct/constant.go | 14 + pkg/callbackstruct/revoke.go | 14 + pkg/common/cmd/constant.go | 14 + pkg/common/config/config.go | 1 + pkg/common/config/parse.go | 4 +- pkg/common/convert/user.go | 3 +- pkg/common/db/cache/group.go | 2 +- pkg/common/db/cache/init_redis.go | 24 +- pkg/common/db/cache/msg_test.go | 14 + pkg/common/db/cache/s3.go | 14 + pkg/common/db/mgo/black.go | 14 + pkg/common/db/mgo/conversation.go | 14 + pkg/common/db/mgo/friend.go | 14 + pkg/common/db/mgo/friend_request.go | 14 + pkg/common/db/mgo/group.go | 14 + pkg/common/db/mgo/group_member.go | 14 + pkg/common/db/mgo/group_request.go | 14 + pkg/common/db/mgo/log.go | 14 + pkg/common/db/mgo/object.go | 14 + pkg/common/db/mgo/user.go | 14 + pkg/common/db/s3/cos/internal.go | 14 + pkg/common/db/s3/minio/internal.go | 14 + pkg/common/db/s3/minio/thumbnail.go | 14 + pkg/common/db/table/relation/log.go | 14 + pkg/common/db/unrelation/mongo.go | 137 +++--- .../discoveryregister/discoveryregister.go | 169 ++----- .../discoveryregister_test.go | 428 ++---------------- .../kubernetes/kubernetes.go | 174 +++++++ .../discoveryregister/zookeeper/zookeeper.go | 61 +++ pkg/common/ginprometheus/ginprometheus.go | 14 + pkg/common/kafka/producer.go | 138 +++--- pkg/common/kafka/util.go | 11 + pkg/common/prommetrics/gin_api.go | 16 +- pkg/common/prommetrics/grpc_auth.go | 14 + pkg/common/prommetrics/grpc_msg.go | 14 + pkg/common/prommetrics/grpc_msggateway.go | 14 + pkg/common/prommetrics/grpc_push.go | 14 + pkg/common/prommetrics/prommetrics.go | 14 + pkg/common/prommetrics/prommetrics_test.go | 14 + pkg/common/prommetrics/transfer.go | 14 + pkg/common/startrpc/start_test.go | 14 + pkg/common/version/base.go | 16 +- pkg/common/version/types.go | 14 + pkg/common/version/version.go | 18 +- pkg/rpcclient/grouphash/grouphash.go | 14 + scripts/check-all.sh | 4 +- scripts/githooks/pre-push.sh | 2 +- scripts/init-config.sh | 159 ++++--- test/e2e/api/token/token.go | 28 +- test/e2e/api/user/curd.go | 24 +- test/e2e/api/user/user.go | 30 +- test/e2e/e2e.go | 14 + test/e2e/e2e_test.go | 14 + test/e2e/framework/config/config.go | 14 + test/e2e/framework/config/config_test.go | 14 + .../framework/ginkgowrapper/ginkgowrapper.go | 14 + .../ginkgowrapper/ginkgowrapper_test.go | 14 + test/e2e/framework/helpers/chat/chat.go | 22 +- tools/component/component.go | 320 +++++++------ .../chat/cmd/conversion-chat/chat.go | 14 + .../chat/conversion/conversion.go | 14 + tools/data-conversion/chat/v2/admin.go | 14 + tools/data-conversion/chat/v2/chat.go | 14 + .../cmd/conversion-msg/conversion-msg.go | 14 + tools/data-conversion/openim/mysql/cmd.go | 14 + .../openim/mysql/conversion/conversion.go | 14 + .../openim/mysql/v2/model_struct.go | 14 + tools/data-conversion/openim/mysql/v3/log.go | 14 + .../openim/proto/msg/msg.proto | 14 + .../openim/proto/sdk_ws/ws.proto | 14 + tools/data-conversion/utils/find_insert.go | 14 + tools/data-conversion/utils/time.go | 14 + tools/infra/infra.go | 14 + tools/up35/pkg/convert.go | 17 +- .../pkg/internal/rtc/mongo/mgo/meeting.go | 20 +- .../rtc/mongo/mgo/meeting_invitation.go | 27 +- .../internal/rtc/mongo/mgo/meeting_record.go | 18 +- .../up35/pkg/internal/rtc/mongo/mgo/signal.go | 20 +- .../rtc/mongo/mgo/signal_invitation.go | 20 +- .../pkg/internal/rtc/mongo/table/meeting.go | 17 +- .../pkg/internal/rtc/mongo/table/signal.go | 17 +- tools/up35/pkg/internal/rtc/mysql/meeting.go | 14 + tools/up35/pkg/internal/rtc/mysql/signal.go | 16 +- tools/up35/pkg/pkg.go | 17 +- tools/up35/up35.go | 17 +- tools/url2im/main.go | 14 + tools/url2im/pkg/api.go | 14 + tools/url2im/pkg/buffer.go | 14 + tools/url2im/pkg/config.go | 14 + tools/url2im/pkg/http.go | 14 + tools/url2im/pkg/manage.go | 14 + tools/url2im/pkg/md5.go | 14 + tools/url2im/pkg/progress.go | 14 + 211 files changed, 3985 insertions(+), 1235 deletions(-) delete mode 100644 .github/workflows/build-openim-web-image.yml create mode 100644 config/Readme.md delete mode 100644 config/templates/README.md rename config/{email.tmpl => templates/email.tmpl.template} (100%) create mode 100644 config/templates/instance-down-rules.yml.template create mode 100644 config/templates/notification.yaml.template rename config/{ => templates}/open-im-ng-example.conf (100%) rename config/{ => templates}/prometheus-dashboard.yaml (98%) rename deployments/{README.md => Readme.md} (100%) delete mode 100644 deployments/templates/chat.yaml create mode 100644 deployments/templates/email.tmpl rename {config => deployments/templates}/instance-down-rules.yml (61%) rename {config => deployments/templates}/notification.yaml (88%) create mode 100644 pkg/common/discoveryregister/kubernetes/kubernetes.go create mode 100644 pkg/common/discoveryregister/zookeeper/zookeeper.go diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index a8cb98a51..619744987 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -48,6 +48,7 @@ jobs: images: openim/openim-server # generate Docker tags based on the following events/attributes tags: | + type=ref,event=tag type=schedule type=ref,event=branch type=ref,event=pr @@ -90,6 +91,7 @@ jobs: images: registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-server # generate Docker tags based on the following events/attributes tags: | + type=ref,event=tag type=schedule type=ref,event=branch type=ref,event=pr @@ -133,6 +135,7 @@ jobs: images: ghcr.io/openimsdk/openim-server # generate Docker tags based on the following events/attributes tags: | + type=ref,event=tag type=schedule type=ref,event=branch type=ref,event=pr diff --git a/.github/workflows/build-openim-web-image.yml b/.github/workflows/build-openim-web-image.yml deleted file mode 100644 index 999c2e1e3..000000000 --- a/.github/workflows/build-openim-web-image.yml +++ /dev/null @@ -1,139 +0,0 @@ -# Copyright © 2023 OpenIM open source community. 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: Build OpenIM Web Docker image - -on: -# schedule: -# - cron: '30 3 * * *' - push: - branches: - # - main - - release-* - tags: - - v* - workflow_dispatch: - -env: - # Common versions - GO_VERSION: "1.20" - -jobs: - build-openim-web-dockerhub: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - -# docker.io/openim/openim-web:latest - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v5.0.0 - with: - images: openim/openim-web - # generate Docker tags based on the following events/attributes - tags: | - type=schedule - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - type=sha - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Build and push Docker image - uses: docker/build-push-action@v5 - with: - context: . - file: ./build/images/openim-tools/openim-web/Dockerfile - platforms: linux/amd64,linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - build-openim-web-aliyun: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 -# registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-web:latest - - name: Extract metadata (tags, labels) for Docker - id: meta2 - uses: docker/metadata-action@v5.0.0 - with: - images: registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-web - - - name: Log in to AliYun Docker Hub - uses: docker/login-action@v3 - with: - registry: registry.cn-hangzhou.aliyuncs.com - username: ${{ secrets.ALIREGISTRY_USERNAME }} - password: ${{ secrets.ALIREGISTRY_TOKEN }} - - - name: Build and push Docker image - uses: docker/build-push-action@v5 - with: - context: . - file: ./build/images/openim-tools/openim-web/Dockerfile - platforms: linux/amd64,linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta2.outputs.tags }} - labels: ${{ steps.meta2.outputs.labels }} - - build-openim-web-ghcr: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 -# ghcr.io/openimsdk/openim-web:latest - - name: Extract metadata (tags, labels) for Docker - id: meta2 - uses: docker/metadata-action@v5.0.0 - with: - images: ghcr.io/openimsdk/openim-web - - - name: Log in to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push Docker image - uses: docker/build-push-action@v5 - with: - context: . - file: ./build/images/openim-tools/openim-web/Dockerfile - platforms: linux/amd64,linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta2.outputs.tags }} - labels: ${{ steps.meta2.outputs.labels }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 675ce10c7..fb8d428d2 100644 --- a/.gitignore +++ b/.gitignore @@ -32,10 +32,13 @@ _output/ deployments/charts/generated-configs/ ### OpenIM Config ### -config/config.yaml -./config/config.yaml .env -./.env +config/config.yaml +config/alertmanager.yml +config/prometheus.yml +config/email.tmpl +config/notification.yaml +config/instance-down-rules.yml ### OpenIM deploy ### deployments/openim-server/charts @@ -388,8 +391,4 @@ Sessionx.vim # End of https://www.toptal.com/developers/gitignore/api/go,git,vim,tags,test,emacs,backup,jetbrains .idea -dist/ -.env -config/config.yaml -config/alertmanager.yml -config/prometheus.yml \ No newline at end of file +dist/ \ No newline at end of file diff --git a/config/Readme.md b/config/Readme.md new file mode 100644 index 000000000..72f4577a5 --- /dev/null +++ b/config/Readme.md @@ -0,0 +1,243 @@ +# OpenIM Configuration Guide + + +* 1. [Directory Structure and File Descriptions](#DirectoryStructureandFileDescriptions) + * 1.1. [Directory Structure](#DirectoryStructure) + * 1.2. [Directory Structure Explanation](#DirectoryStructureExplanation) +* 2. [File Descriptions](#FileDescriptions) + * 2.1. [Files in the Root Directory](#FilesintheRootDirectory) + * 2.2. [Files in the `templates/` Directory](#FilesinthetemplatesDirectory) +* 3. [Configuration File Generation](#ConfigurationFileGeneration) + * 3.1. [How to Use `init-config.sh` Script](#HowtoUseinit-config.shScript) + * 3.2. [Examples of Operations](#ExamplesofOperations) + * 3.3. [Points to Note](#PointstoNote) +* 4. [Example Directory](#ExampleDirectory) + * 4.1. [Overview](#Overview) + * 4.2. [Structure](#Structure) + * 4.3. [How to Use These Examples](#HowtoUseTheseExamples) + * 4.4. [Tips for Using Example Files:](#TipsforUsingExampleFiles:) +* 5. [Configuration Item Descriptions](#ConfigurationItemDescriptions) +* 6. [Version Management and Upgrading](#VersionManagementandUpgrading) + * 6.1. [Pulling the Latest Code](#PullingtheLatestCode) + * 6.2. [Generating the Latest Example Configuration Files](#GeneratingtheLatestExampleConfigurationFiles) + * 6.3. [Comparing Configuration File Differences](#ComparingConfigurationFileDifferences) + * 6.4. [Updating Configuration Files](#UpdatingConfigurationFiles) + * 6.5. [Updating Binary Files and Restarting Services](#UpdatingBinaryFilesandRestartingServices) + * 6.6. [Best Practices for Version Management](#BestPracticesforVersionManagement) +* 7. [How to Contribute](#HowtoContribute) + * 7.1. [OpenIM Configuration Item Descriptions](#OpenIMConfigurationItemDescriptions) + * 7.2. [Modifying Template Files](#ModifyingTemplateFiles) + * 7.3. [Updating Configuration Center Scripts](#UpdatingConfigurationCenterScripts) + * 7.4. [Configuration File Generation Process](#ConfigurationFileGenerationProcess) + * 7.5. [Contribution Guidelines](#ContributionGuidelines) + * 7.6. [Submission and Review](#SubmissionandReview) + + + + + +## 1. Directory Structure and File Descriptions + +This document details the structure of the `config` directory, aiding users in understanding and managing configuration files. + +### 1.1. Directory Structure + +```bash +$ tree config +├── alertmanager.yml +├── config.yaml +├── email.tmpl +├── instance-down-rules.yml +├── notification.yaml +├── prometheus.yml +├── Readme.md +└── templates + ├── alertmanager.yml.template + ├── config.yaml.template + ├── email.tmpl.template + ├── env.template + ├── instance-down-rules.yml.template + ├── notification.yaml.template + ├── open-im-ng-example.conf + ├── prometheus-dashboard.yaml + └── prometheus.yml.template +``` + +### 1.2. Directory Structure Explanation + +- **Root Directory (`config/`)**: Contains actual configuration files and the `templates` subdirectory. +- **`templates/` Subdirectory**: Stores configuration templates for generating or updating configuration files in the root directory. + +## 2. File Descriptions + +### 2.1. Files in the Root Directory + +- **`alertmanager.yml`**: Configuration file for AlertManager, managing and setting up the alert system. +- **`config.yaml`**: The main application configuration file, covering service settings. +- **`email.tmpl`**: Template file for email notifications, defining email format and content. +- **`instance-down-rules.yml`**: Instance downtime rules configuration file for the monitoring system. +- **`notification.yaml`**: Configuration file for notification settings, defining different types of notifications. +- **`prometheus.yml`**: Configuration file for the Prometheus monitoring system, setting monitoring metrics and rules. + +### 2.2. Files in the `templates/` Directory + +- **`alertmanager.yml.template`**: Template for AlertManager configuration. +- **`config.yaml.template`**: Main configuration template for the application. +- **`email.tmpl.template`**: Template for email notifications. +- **`env.template`**: Template for environmental variable configurations, setting environment-related configurations. +- **`instance-down-rules.yml.template`**: Template for instance downtime rules. +- **`notification.yaml.template`**: Template for notification settings. +- **`open-im-ng-example.conf`**: Example configuration file for the application. +- **`prometheus-dashboard.yaml`**: Prometheus dashboard configuration file, specific to the OpenIM application. +- **`prometheus.yml.template`**: Template for Prometheus configuration. + +## 3. Configuration File Generation + +Configuration files can be automatically generated using the `make init` command or the `./scripts/init-config.sh` script. These scripts conveniently extract templates from the `templates` directory and generate or update actual configuration files in the root directory. + +### 3.1. How to Use `init-config.sh` Script + +```bash +$ ./scripts/init-config.sh --help +Usage: init-config.sh [options] +Options: + -h, --help Show this help message + --force Overwrite existing files without prompt + --skip Skip generation if file exists + --examples Generate example files + --clean-config Clean all configuration files + --clean-examples Clean all example files +``` + +### 3.2. Examples of Operations + +- Generate all template configuration files: + + ```bash + $ ./scripts/init-config.sh --examples + ``` + +- Force overwrite existing configuration files: + + ```bash + $ ./scripts/init-config.sh --force + ``` + +### 3.3. Points to Note + +- **Template files should not be directly modified**: Files in the `template` directory are templates included in source code management. Direct modification may lead to version conflicts or management issues. +- **Operations for Windows Users**: Windows users can use the `cp` command to copy files from the `template` directory to the `config/` directory and then modify the configuration items as needed. + +## 4. Example Directory + +Welcome to our project's `examples` directory! This directory contains a range of example files, showcasing various configurations and settings of our software. These examples are intended to provide you with templates that can serve as a starting point for your own configurations. + +### 4.1. Overview + +In this directory, you'll find examples suitable for a variety of use cases. Each file is a template with default values and configurations, demonstrating best practices and typical scenarios. Whether you're just getting started or looking to implement complex settings, these examples should help you get on the right track. + +### 4.2. Structure + +Here's a quick overview of the contents in this directory: + +- `env-example.yaml`: Demonstrates how to set up environmental variables. +- `openim-example.yaml`: Example configuration file for the OpenIM application. +- `prometheus-example.yml`: Example configuration for monitoring with Prometheus. +- `alertmanager-example.yml`: Template for setting up Alertmanager configuration. + +### 4.3. How to Use These Examples + +To use these examples, simply copy the relevant files to your working directory and rename them as needed (for example, removing the `-example` suffix). Then, modify the files according to your needs. + +### 4.4. Tips for Using Example Files: + +1. **Read Comments**: Each file contains comments explaining the various sections and settings. Make sure to read these comments for a better understanding of how to customize the file. +2. **Check Required Changes**: Some examples might require mandatory changes before they can be used effectively (such as setting specific environmental variables). +3. **Version Compatibility**: Ensure that the example files are compatible with the version of the software you are using. + +## 5. Configuration Item Descriptions + +## 6. Version Management and Upgrading + +When managing and upgrading the `config` directory's versions, it is crucial to ensure that the configuration files in both the local `config/` and `config/templates/` directories are kept in sync. This process can ensure that your configuration files are consistent with the latest standard templates, while also maintaining custom settings. + +### 6.1. Pulling the Latest Code + +First, ensure that your local repository is in sync with the remote repository. This can be achieved by pulling the latest code: + +```bash +$ git pull +``` + +### 6.2. Generating the Latest Example Configuration Files + +Next, generate the latest example configuration files. This can be done by running the `init-config.sh` script, using the `--examples` option to generate example files, and the `--skip` option to avoid overwriting existing configuration files: + +```bash +$ ./scripts/init-config.sh --examples --skip +``` + +### 6.3. Comparing Configuration File Differences + +Once the latest example configuration files are generated, you need to compare the configuration files in the `config/` and `config/templates/` directories to find any potential differences. This step ensures that you can identify and integrate any important updates or changes. Tools like `diff` can be helpful in completing this step: + +```bash +$ diff -ur config/ config/templates/ +``` + +### 6.4. Updating Configuration Files + +Based on the comparison results, manually update the configuration files in the `config/` directory to reflect the latest configurations in `config/templates/`. During this process, ensure to retain any custom configuration settings. + +### 6.5. Updating Binary Files and Restarting Services + +After updating the configuration files, the next step is to update any related binary files. This typically involves downloading and installing the latest version of the application or service. Depending on the specific application or service, this might involve running specific update scripts or directly downloading the latest version from official sources. + +Once the binary files are updated, the services need to be restarted to apply the new configurations. Make sure to conduct necessary checks before restarting to ensure the correctness of the configurations. + +### 6.6. Best Practices for Version Management + +- **Record Changes**: When committing changes to a version control system, ensure to log detailed change logs. +- **Stay Synced**: Regularly sync with the remote repository to ensure that your local configurations are in line with the latest developments. +- **Backup**: Backup your current configurations before making any significant changes, so that you can revert to a previous state if necessary. + +By following these steps and best practices, you can ensure effective management and smooth upgrading of your `config` directory. + +## 7. How to Contribute + +If you have an understanding of the logic behind OpenIM's configuration generation, then you will clearly know where to make modifications to contribute code. + +### 7.1. OpenIM Configuration Item Descriptions + +First, it is recommended to read the [OpenIM Configuration Items Document](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md). This will help you understand the roles of various configuration items and how they affect the operation of OpenIM. + +### 7.2. Modifying Template Files + +To contribute to OpenIM, focus on the `./deployments/templates` directory. This contains various configuration template files, which are the basis for generating the final configuration files. + +When making modifications, ensure that your changes align with OpenIM's configuration requirements and logic. This may involve adding new template files or modifying existing files to reflect new configuration options or structural changes. + +### 7.3. Updating Configuration Center Scripts + +In addition to modifying template files, pay attention to the `./scripts/install/environment.sh` script. In this script, you may need to add or modify environment variables. + +This script is responsible for defining environment variables that influence configuration generation. Therefore, any new configuration items or modifications to existing items need to be reflected here. + +### 7.4. Configuration File Generation Process + +The essence of the `make init` command is to use the environment variables defined in `/scripts/install/environment.sh` to render the template files in the `./deployments/templates` directory, thereby generating the final configuration files. + +When contributing code, ensure that your changes work smoothly in this process and do not cause errors during configuration file generation. + +### 7.5. Contribution Guidelines + +- **Code Review**: Ensure your changes have passed code review. This typically means that the code should be clear, easy to understand, and adhere to the project's coding style and best practices. +- **Testing**: Before submitting changes, conduct thorough tests to ensure new or modified configurations work as expected and do not negatively impact existing functionalities. +- **Documentation**: If you have added a new configuration option or made significant changes to an existing one, update the relevant documentation to assist other users and developers in understanding and utilizing these changes. + +### 7.6. Submission and Review + +After completing your changes, submit your code to the OpenIM repository in the form of a Pull Request (PR). The PR will be reviewed by the project maintainers and you may be asked to make further modifications or provide additional information. \ No newline at end of file diff --git a/config/templates/README.md b/config/templates/README.md deleted file mode 100644 index 6a979c6bb..000000000 --- a/config/templates/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# Examples Directory - -Welcome to the `examples` directory of our project! This directory contains a collection of example files that demonstrate various configurations and setups for our software. These examples are designed to provide you with templates that can be used as a starting point for your own configurations. - -## Overview - -In this directory, you'll find examples for a variety of use cases. Each file is a template with default values and configurations that illustrate best practices and typical scenarios. Whether you're just getting started or looking to implement a complex setup, these examples should help you get on the right track. - -## Structure - -Here's a quick overview of what you'll find in this directory: - -+ `env-example.yaml`: Demonstrates how to set up environment variables. -+ `openim-example.yaml`: A sample configuration file for the OpenIM application. -+ `prometheus-example.yml`: An example Prometheus configuration for monitoring. -+ `alertmanager-example.yml`: A template for setting up Alertmanager configurations. - -## How to Use These Examples - -To use these examples, simply copy the relevant file to your working directory and rename it as needed (e.g., removing the `-example` suffix). Then, modify the file according to your requirements. - -### Tips for Using Example Files: - -1. **Read the Comments**: Each file contains comments that explain various sections and settings. Make sure to read these comments for a better understanding of how to customize the file. -2. **Check for Required Changes**: Some examples might require mandatory changes (like setting specific environment variables) before they can be used effectively. -3. **Version Compatibility**: Ensure that the example files are compatible with the version of the software you are using. - -## Contributing - -If you have a configuration that you believe would be beneficial to others, please feel free to contribute by opening a pull request with your proposed changes. We appreciate contributions that expand our examples with new scenarios and use cases. - -## Support - -If you encounter any issues or have questions regarding the example files, please open an issue on our repository. Our community is here to help you navigate through any challenges you might face. - -Thank you for exploring our examples, and we hope they will be helpful in setting up and configuring your environment! diff --git a/config/templates/alertmanager.yml.template b/config/templates/alertmanager.yml.template index da5f99b19..a0daadfbd 100644 --- a/config/templates/alertmanager.yml.template +++ b/config/templates/alertmanager.yml.template @@ -1,3 +1,17 @@ +# 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. + ###################### AlertManager Configuration ###################### # AlertManager configuration using environment variables # diff --git a/config/templates/config.yaml.template b/config/templates/config.yaml.template index 7eb082b24..fd51a2e31 100644 --- a/config/templates/config.yaml.template +++ b/config/templates/config.yaml.template @@ -37,13 +37,20 @@ zookeeper: ###################### Mongo ###################### # MongoDB configuration -# If uri is not empty, it will be used directly -# -# MongoDB address for standalone setup, Mongos address for sharded cluster setup -# Default MongoDB database name -# Maximum connection pool size + +# If uri is not empty, it will be used directly for the MongoDB connection. +# This is a complete MongoDB URI string. +# Example: mongodb://user:password@host1:port1,host2:port2/dbname?options mongo: uri: '' + +# List of MongoDB server addresses. +# Used for constructing the MongoDB URI if 'uri' above is empty. +# For a standalone setup, specify the address of the single server. +# For a sharded cluster, specify the addresses of the Mongos servers. +# Example: [ '172.28.0.1:37017', '172.28.0.2:37017' ] +# Default MongoDB database name +# Maximum connection pool size address: [ 172.28.0.1:37017 ] database: openIM_v3 username: root diff --git a/config/email.tmpl b/config/templates/email.tmpl.template similarity index 100% rename from config/email.tmpl rename to config/templates/email.tmpl.template diff --git a/config/templates/env.template b/config/templates/env.template index 54218c330..ffcec89e5 100644 --- a/config/templates/env.template +++ b/config/templates/env.template @@ -1,3 +1,17 @@ +# 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. + # ====================================== # ========= Basic Configuration ======== # ====================================== @@ -10,10 +24,6 @@ USER=root # Default: PASSWORD=openIM123 PASSWORD=openIM123 -# Endpoint for the MinIO object storage service. -# Default: MINIO_ENDPOINT=http://172.28.0.1:10005 -MINIO_ENDPOINT=http://172.28.0.1:10005 - # Base URL for the application programming interface (API). # Default: API_URL=http://172.28.0.1:10002 API_URL=http://14.155.64.202:10002 diff --git a/config/templates/instance-down-rules.yml.template b/config/templates/instance-down-rules.yml.template new file mode 100644 index 000000000..7a6e9fda9 --- /dev/null +++ b/config/templates/instance-down-rules.yml.template @@ -0,0 +1,36 @@ +# 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. + +groups: + - name: instance_down + rules: + - alert: InstanceDown + expr: up == 0 + for: 1m + labels: + severity: critical + annotations: + summary: "Instance {{ $labels.instance }} down" + description: "{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 1 minutes." + + - name: database_insert_failure_alerts + rules: + - alert: DatabaseInsertFailed + expr: (increase(msg_insert_redis_failed_total[5m]) > 0) or (increase(msg_insert_mongo_failed_total[5m]) > 0) + for: 1m + labels: + severity: critical + annotations: + summary: "Increase in MsgInsertRedisFailedCounter or MsgInsertMongoFailedCounter detected" + description: "Either MsgInsertRedisFailedCounter or MsgInsertMongoFailedCounter has increased in the last 5 minutes, indicating failures in message insert operations to Redis or MongoDB,maybe the redis or mongodb is crash." diff --git a/config/templates/notification.yaml.template b/config/templates/notification.yaml.template new file mode 100644 index 000000000..665c21261 --- /dev/null +++ b/config/templates/notification.yaml.template @@ -0,0 +1,354 @@ +# 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. + +# Determines if a message should be sent. If set to false, it triggers a silent sync without a message. If true, it requires triggering a conversation. +# For rpc notification, send twice: once as a message and once as a notification. +# The options field 'isNotification' indicates if it's a notification. +groupCreated: + isSendMsg: true + +# Reliability level of the message sending. +# Set to 1 to send only when online, 2 for guaranteed delivery. + reliabilityLevel: 1 + +# This setting is effective only when 'isSendMsg' is true. +# It controls whether to count unread messages. + unreadCount: false + +# Configuration for offline push notifications. + offlinePush: + # Enables or disables offline push notifications. + enable: false + + # Title for the notification when a group is created. + title: "create group title" + + # Description for the notification. + desc: "create group desc" + + # Additional information for the notification. + ext: "create group ext" + +# Content type is not added here. +# Content should use a JSON structure conforming to the protobuf format. + +groupInfoSet: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: "groupInfoSet title" + desc: "groupInfoSet desc" + ext: "groupInfoSet ext" + + +joinGroupApplication: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: "joinGroupApplication title" + desc: "joinGroupApplication desc" + ext: "joinGroupApplication ext" + +memberQuit: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: "memberQuit title" + desc: "memberQuit desc" + ext: "memberQuit ext" + +groupApplicationAccepted: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: "groupApplicationAccepted title" + desc: "groupApplicationAccepted desc" + ext: "groupApplicationAccepted ext" + +groupApplicationRejected: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: " title" + desc: " desc" + ext: " ext" + + +groupOwnerTransferred: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: "groupOwnerTransferred title" + desc: "groupOwnerTransferred desc" + ext: "groupOwnerTransferred ext" + +memberKicked: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: "memberKicked title" + desc: "memberKicked desc" + ext: "memberKicked ext" + +memberInvited: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: "memberInvited title" + desc: "memberInvited desc" + ext: "memberInvited ext" + +memberEnter: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: "memberEnter title" + desc: "memberEnter desc" + ext: "memberEnter ext" + +groupDismissed: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: "groupDismissed title" + desc: "groupDismissed desc" + ext: "groupDismissed ext" + +groupMuted: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: "groupMuted title" + desc: "groupMuted desc" + ext: "groupMuted ext" + +groupCancelMuted: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: "groupCancelMuted title" + desc: "groupCancelMuted desc" + ext: "groupCancelMuted ext" + defaultTips: + tips: "group Cancel Muted" + + +groupMemberMuted: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: "groupMemberMuted title" + desc: "groupMemberMuted desc" + ext: "groupMemberMuted ext" + +groupMemberCancelMuted: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: "groupMemberCancelMuted title" + desc: "groupMemberCancelMuted desc" + ext: "groupMemberCancelMuted ext" + +groupMemberInfoSet: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: "groupMemberInfoSet title" + desc: "groupMemberInfoSet desc" + ext: "groupMemberInfoSet ext" + +groupInfoSetAnnouncement: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: "groupInfoSetAnnouncement title" + desc: "groupInfoSetAnnouncement desc" + ext: "groupInfoSetAnnouncement ext" + + +groupInfoSetName: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: "groupInfoSetName title" + desc: "groupInfoSetName desc" + ext: "groupInfoSetName ext" + + +#############################friend################################# +friendApplicationAdded: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: "Somebody applies to add you as a friend" + desc: "Somebody applies to add you as a friend" + ext: "Somebody applies to add you as a friend" + +friendApplicationApproved: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: "Someone applies to add your friend application" + desc: "Someone applies to add your friend application" + ext: "Someone applies to add your friend application" + +friendApplicationRejected: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: "Someone rejected your friend application" + desc: "Someone rejected your friend application" + ext: "Someone rejected your friend application" + +friendAdded: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: "We have become friends" + desc: "We have become friends" + ext: "We have become friends" + +friendDeleted: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: "deleted a friend" + desc: "deleted a friend" + ext: "deleted a friend" + +friendRemarkSet: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: "Your friend's profile has been changed" + desc: "Your friend's profile has been changed" + ext: "Your friend's profile has been changed" + +blackAdded: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: "blocked a user" + desc: "blocked a user" + ext: "blocked a user" + +blackDeleted: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: "Remove a blocked user" + desc: "Remove a blocked user" + ext: "Remove a blocked user" + +friendInfoUpdated: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: "friend info updated" + desc: "friend info updated" + ext: "friend info updated" + +#####################user######################### +userInfoUpdated: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: "Remove a blocked user" + desc: "Remove a blocked user" + ext: "Remove a blocked user" + +userStatusChanged: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: "user status changed" + desc: "user status changed" + ext: "user status changed" + +#####################conversation######################### +conversationChanged: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: "conversation changed" + desc: "conversation changed" + ext: "conversation changed" + +conversationSetPrivate: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: "burn after reading" + desc: "burn after reading" + ext: "burn after reading" diff --git a/config/open-im-ng-example.conf b/config/templates/open-im-ng-example.conf similarity index 100% rename from config/open-im-ng-example.conf rename to config/templates/open-im-ng-example.conf diff --git a/config/prometheus-dashboard.yaml b/config/templates/prometheus-dashboard.yaml similarity index 98% rename from config/prometheus-dashboard.yaml rename to config/templates/prometheus-dashboard.yaml index 0e7823797..e1b569df3 100644 --- a/config/prometheus-dashboard.yaml +++ b/config/templates/prometheus-dashboard.yaml @@ -1,3 +1,17 @@ +# 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. + { "annotations": { "list": [ diff --git a/config/templates/prometheus.yml.template b/config/templates/prometheus.yml.template index 7950c5d33..709fe9754 100644 --- a/config/templates/prometheus.yml.template +++ b/config/templates/prometheus.yml.template @@ -1,3 +1,17 @@ +# 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. + # my global config global: scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. diff --git a/deployments/README.md b/deployments/Readme.md similarity index 100% rename from deployments/README.md rename to deployments/Readme.md diff --git a/deployments/charts/helmfile.yaml b/deployments/charts/helmfile.yaml index a6a009257..eb064be9a 100644 --- a/deployments/charts/helmfile.yaml +++ b/deployments/charts/helmfile.yaml @@ -1,3 +1,17 @@ +# 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. + {{- define "defaultValues" -}} - ./generated-configs/helm-image.yaml - ./generated-configs/config.yaml diff --git a/deployments/charts/openim-api/Chart.yaml b/deployments/charts/openim-api/Chart.yaml index 74779b64a..e79d2a2c2 100644 --- a/deployments/charts/openim-api/Chart.yaml +++ b/deployments/charts/openim-api/Chart.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: v2 name: openim-api description: A OpenIM Api Helm chart for Kubernetes diff --git a/deployments/charts/openim-api/templates/app-cm.yaml b/deployments/charts/openim-api/templates/app-cm.yaml index 7a6f23314..9d4e96e8b 100644 --- a/deployments/charts/openim-api/templates/app-cm.yaml +++ b/deployments/charts/openim-api/templates/app-cm.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: v1 kind: ConfigMap metadata: diff --git a/deployments/charts/openim-api/templates/deployment.yaml b/deployments/charts/openim-api/templates/deployment.yaml index 27bfa1f13..3b4bf57a2 100644 --- a/deployments/charts/openim-api/templates/deployment.yaml +++ b/deployments/charts/openim-api/templates/deployment.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: apps/v1 kind: Deployment metadata: diff --git a/deployments/charts/openim-api/templates/hpa.yaml b/deployments/charts/openim-api/templates/hpa.yaml index 0e5848181..dc0742a25 100644 --- a/deployments/charts/openim-api/templates/hpa.yaml +++ b/deployments/charts/openim-api/templates/hpa.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.autoscaling.enabled }} apiVersion: autoscaling/v2beta1 kind: HorizontalPodAutoscaler diff --git a/deployments/charts/openim-api/templates/ingress.yaml b/deployments/charts/openim-api/templates/ingress.yaml index 62c66c135..55bc69710 100644 --- a/deployments/charts/openim-api/templates/ingress.yaml +++ b/deployments/charts/openim-api/templates/ingress.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.ingress.enabled -}} {{- $fullName := include "openim-api.fullname" . -}} {{- $svcPort := .Values.service.port -}} diff --git a/deployments/charts/openim-api/templates/service.yaml b/deployments/charts/openim-api/templates/service.yaml index eb37fa56c..3704bf35c 100644 --- a/deployments/charts/openim-api/templates/service.yaml +++ b/deployments/charts/openim-api/templates/service.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: v1 kind: Service metadata: diff --git a/deployments/charts/openim-api/templates/serviceaccount.yaml b/deployments/charts/openim-api/templates/serviceaccount.yaml index e3e7b2849..556a71e34 100644 --- a/deployments/charts/openim-api/templates/serviceaccount.yaml +++ b/deployments/charts/openim-api/templates/serviceaccount.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.serviceAccount.create -}} apiVersion: v1 kind: ServiceAccount diff --git a/deployments/charts/openim-api/values.yaml b/deployments/charts/openim-api/values.yaml index e41fb6e76..4208335de 100644 --- a/deployments/charts/openim-api/values.yaml +++ b/deployments/charts/openim-api/values.yaml @@ -1,3 +1,17 @@ +# 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. + # Default values for openim-api. # This is a YAML-formatted file. # Declare variables to be passed into your templates. diff --git a/deployments/charts/openim-msggateway/Chart.yaml b/deployments/charts/openim-msggateway/Chart.yaml index c8c380bf9..fb6d0d153 100644 --- a/deployments/charts/openim-msggateway/Chart.yaml +++ b/deployments/charts/openim-msggateway/Chart.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: v2 name: openim-msggateway description: A Helm chart for Kubernetes diff --git a/deployments/charts/openim-msggateway/templates/hpa.yaml b/deployments/charts/openim-msggateway/templates/hpa.yaml index e1fbe50a6..99121afba 100644 --- a/deployments/charts/openim-msggateway/templates/hpa.yaml +++ b/deployments/charts/openim-msggateway/templates/hpa.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.autoscaling.enabled }} apiVersion: autoscaling/v2beta1 kind: HorizontalPodAutoscaler diff --git a/deployments/charts/openim-msggateway/templates/ingress.yaml b/deployments/charts/openim-msggateway/templates/ingress.yaml index 5c1c24078..0e22e1936 100644 --- a/deployments/charts/openim-msggateway/templates/ingress.yaml +++ b/deployments/charts/openim-msggateway/templates/ingress.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.ingress.enabled -}} {{- $fullName := include "openim-msggateway.fullname" . -}} {{- $svcPort := .Values.service.port -}} diff --git a/deployments/charts/openim-msggateway/templates/service.yaml b/deployments/charts/openim-msggateway/templates/service.yaml index 2ed58a869..e33fce6db 100644 --- a/deployments/charts/openim-msggateway/templates/service.yaml +++ b/deployments/charts/openim-msggateway/templates/service.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: v1 kind: Service metadata: diff --git a/deployments/charts/openim-msggateway/templates/serviceaccount.yaml b/deployments/charts/openim-msggateway/templates/serviceaccount.yaml index 6b47c12c5..718880d71 100644 --- a/deployments/charts/openim-msggateway/templates/serviceaccount.yaml +++ b/deployments/charts/openim-msggateway/templates/serviceaccount.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.serviceAccount.create -}} apiVersion: v1 kind: ServiceAccount diff --git a/deployments/charts/openim-msggateway/values.yaml b/deployments/charts/openim-msggateway/values.yaml index d82c674fc..059601807 100644 --- a/deployments/charts/openim-msggateway/values.yaml +++ b/deployments/charts/openim-msggateway/values.yaml @@ -1,3 +1,17 @@ +# 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. + # Default values for openim-msggateway. # This is a YAML-formatted file. # Declare variables to be passed into your templates. diff --git a/deployments/charts/openim-msgtransfer/Chart.yaml b/deployments/charts/openim-msgtransfer/Chart.yaml index bba7a047f..37d897728 100644 --- a/deployments/charts/openim-msgtransfer/Chart.yaml +++ b/deployments/charts/openim-msgtransfer/Chart.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: v2 name: openim-msgtransfer description: A Helm chart for Kubernetes diff --git a/deployments/charts/openim-msgtransfer/templates/deployment.yaml b/deployments/charts/openim-msgtransfer/templates/deployment.yaml index adb8ae737..2c9e24bdd 100644 --- a/deployments/charts/openim-msgtransfer/templates/deployment.yaml +++ b/deployments/charts/openim-msgtransfer/templates/deployment.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: apps/v1 kind: Deployment metadata: diff --git a/deployments/charts/openim-msgtransfer/templates/hpa.yaml b/deployments/charts/openim-msgtransfer/templates/hpa.yaml index 75c7d4fef..89921bf30 100644 --- a/deployments/charts/openim-msgtransfer/templates/hpa.yaml +++ b/deployments/charts/openim-msgtransfer/templates/hpa.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.autoscaling.enabled }} apiVersion: autoscaling/v2beta1 kind: HorizontalPodAutoscaler diff --git a/deployments/charts/openim-msgtransfer/templates/ingress.yaml b/deployments/charts/openim-msgtransfer/templates/ingress.yaml index c9968a438..ab28a9e71 100644 --- a/deployments/charts/openim-msgtransfer/templates/ingress.yaml +++ b/deployments/charts/openim-msgtransfer/templates/ingress.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.ingress.enabled -}} {{- $fullName := include "openim-msgtransfer.fullname" . -}} {{- $svcPort := .Values.service.port -}} diff --git a/deployments/charts/openim-msgtransfer/templates/service.yaml b/deployments/charts/openim-msgtransfer/templates/service.yaml index 839e520e5..e657f8c18 100644 --- a/deployments/charts/openim-msgtransfer/templates/service.yaml +++ b/deployments/charts/openim-msgtransfer/templates/service.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: v1 kind: Service metadata: diff --git a/deployments/charts/openim-msgtransfer/templates/serviceaccount.yaml b/deployments/charts/openim-msgtransfer/templates/serviceaccount.yaml index 2e3ca4ee7..78816bd80 100644 --- a/deployments/charts/openim-msgtransfer/templates/serviceaccount.yaml +++ b/deployments/charts/openim-msgtransfer/templates/serviceaccount.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.serviceAccount.create -}} apiVersion: v1 kind: ServiceAccount diff --git a/deployments/charts/openim-msgtransfer/values.yaml b/deployments/charts/openim-msgtransfer/values.yaml index d4a792d17..6e26d72c8 100644 --- a/deployments/charts/openim-msgtransfer/values.yaml +++ b/deployments/charts/openim-msgtransfer/values.yaml @@ -1,3 +1,17 @@ +# 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. + # Default values for openim-msgtransfer. # This is a YAML-formatted file. # Declare variables to be passed into your templates. diff --git a/deployments/charts/openim-push/Chart.yaml b/deployments/charts/openim-push/Chart.yaml index 93e134879..966769b00 100644 --- a/deployments/charts/openim-push/Chart.yaml +++ b/deployments/charts/openim-push/Chart.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: v2 name: openim-push description: A Helm chart for Kubernetes diff --git a/deployments/charts/openim-push/templates/deployment.yaml b/deployments/charts/openim-push/templates/deployment.yaml index 684e76e02..34de33e10 100644 --- a/deployments/charts/openim-push/templates/deployment.yaml +++ b/deployments/charts/openim-push/templates/deployment.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: apps/v1 kind: Deployment metadata: diff --git a/deployments/charts/openim-push/templates/hpa.yaml b/deployments/charts/openim-push/templates/hpa.yaml index 89c89c041..40c77b048 100644 --- a/deployments/charts/openim-push/templates/hpa.yaml +++ b/deployments/charts/openim-push/templates/hpa.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.autoscaling.enabled }} apiVersion: autoscaling/v2beta1 kind: HorizontalPodAutoscaler diff --git a/deployments/charts/openim-push/templates/ingress.yaml b/deployments/charts/openim-push/templates/ingress.yaml index b00fda3d3..6638f256d 100644 --- a/deployments/charts/openim-push/templates/ingress.yaml +++ b/deployments/charts/openim-push/templates/ingress.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.ingress.enabled -}} {{- $fullName := include "openim-push.fullname" . -}} {{- $svcPort := .Values.service.port -}} diff --git a/deployments/charts/openim-push/templates/service.yaml b/deployments/charts/openim-push/templates/service.yaml index 4d8bb0457..b38c35375 100644 --- a/deployments/charts/openim-push/templates/service.yaml +++ b/deployments/charts/openim-push/templates/service.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: v1 kind: Service metadata: diff --git a/deployments/charts/openim-push/templates/serviceaccount.yaml b/deployments/charts/openim-push/templates/serviceaccount.yaml index e22115724..66dfedfdf 100644 --- a/deployments/charts/openim-push/templates/serviceaccount.yaml +++ b/deployments/charts/openim-push/templates/serviceaccount.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.serviceAccount.create -}} apiVersion: v1 kind: ServiceAccount diff --git a/deployments/charts/openim-push/values.yaml b/deployments/charts/openim-push/values.yaml index dd6f0faf6..3348fe79d 100644 --- a/deployments/charts/openim-push/values.yaml +++ b/deployments/charts/openim-push/values.yaml @@ -1,3 +1,17 @@ +# 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. + # Default values for openim-push. # This is a YAML-formatted file. # Declare variables to be passed into your templates. diff --git a/deployments/charts/openim-rpc-auth/Chart.yaml b/deployments/charts/openim-rpc-auth/Chart.yaml index 97848dbf2..8e8fb03b4 100644 --- a/deployments/charts/openim-rpc-auth/Chart.yaml +++ b/deployments/charts/openim-rpc-auth/Chart.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: v2 name: openim-rpc-auth description: A Helm chart for Kubernetes diff --git a/deployments/charts/openim-rpc-auth/templates/deployment.yaml b/deployments/charts/openim-rpc-auth/templates/deployment.yaml index 4dbc49731..202162775 100644 --- a/deployments/charts/openim-rpc-auth/templates/deployment.yaml +++ b/deployments/charts/openim-rpc-auth/templates/deployment.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: apps/v1 kind: Deployment metadata: diff --git a/deployments/charts/openim-rpc-auth/templates/hpa.yaml b/deployments/charts/openim-rpc-auth/templates/hpa.yaml index 20108afbf..e99536cf1 100644 --- a/deployments/charts/openim-rpc-auth/templates/hpa.yaml +++ b/deployments/charts/openim-rpc-auth/templates/hpa.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.autoscaling.enabled }} apiVersion: autoscaling/v2beta1 kind: HorizontalPodAutoscaler diff --git a/deployments/charts/openim-rpc-auth/templates/ingress.yaml b/deployments/charts/openim-rpc-auth/templates/ingress.yaml index f14458c52..ece395de7 100644 --- a/deployments/charts/openim-rpc-auth/templates/ingress.yaml +++ b/deployments/charts/openim-rpc-auth/templates/ingress.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.ingress.enabled -}} {{- $fullName := include "openim-rpc-auth.fullname" . -}} {{- $svcPort := .Values.service.port -}} diff --git a/deployments/charts/openim-rpc-auth/templates/service.yaml b/deployments/charts/openim-rpc-auth/templates/service.yaml index ef7b00b86..3674da014 100644 --- a/deployments/charts/openim-rpc-auth/templates/service.yaml +++ b/deployments/charts/openim-rpc-auth/templates/service.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: v1 kind: Service metadata: diff --git a/deployments/charts/openim-rpc-auth/templates/serviceaccount.yaml b/deployments/charts/openim-rpc-auth/templates/serviceaccount.yaml index f13dcca81..555d4f6ff 100644 --- a/deployments/charts/openim-rpc-auth/templates/serviceaccount.yaml +++ b/deployments/charts/openim-rpc-auth/templates/serviceaccount.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.serviceAccount.create -}} apiVersion: v1 kind: ServiceAccount diff --git a/deployments/charts/openim-rpc-auth/values.yaml b/deployments/charts/openim-rpc-auth/values.yaml index a6db6716c..93fa68b87 100644 --- a/deployments/charts/openim-rpc-auth/values.yaml +++ b/deployments/charts/openim-rpc-auth/values.yaml @@ -1,3 +1,17 @@ +# 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. + # Default values for openim-rpc-auth. # This is a YAML-formatted file. # Declare variables to be passed into your templates. diff --git a/deployments/charts/openim-rpc-conversation/Chart.yaml b/deployments/charts/openim-rpc-conversation/Chart.yaml index 090d63127..0ca8f5513 100644 --- a/deployments/charts/openim-rpc-conversation/Chart.yaml +++ b/deployments/charts/openim-rpc-conversation/Chart.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: v2 name: openim-rpc-conversation description: A Helm chart for Kubernetes diff --git a/deployments/charts/openim-rpc-conversation/templates/deployment.yaml b/deployments/charts/openim-rpc-conversation/templates/deployment.yaml index 13dd5c531..01721aa30 100644 --- a/deployments/charts/openim-rpc-conversation/templates/deployment.yaml +++ b/deployments/charts/openim-rpc-conversation/templates/deployment.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: apps/v1 kind: Deployment metadata: diff --git a/deployments/charts/openim-rpc-conversation/templates/hpa.yaml b/deployments/charts/openim-rpc-conversation/templates/hpa.yaml index a2378bfa0..524245562 100644 --- a/deployments/charts/openim-rpc-conversation/templates/hpa.yaml +++ b/deployments/charts/openim-rpc-conversation/templates/hpa.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.autoscaling.enabled }} apiVersion: autoscaling/v2beta1 kind: HorizontalPodAutoscaler diff --git a/deployments/charts/openim-rpc-conversation/templates/ingress.yaml b/deployments/charts/openim-rpc-conversation/templates/ingress.yaml index 224591f67..078c472b8 100644 --- a/deployments/charts/openim-rpc-conversation/templates/ingress.yaml +++ b/deployments/charts/openim-rpc-conversation/templates/ingress.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.ingress.enabled -}} {{- $fullName := include "openim-rpc-conversation.fullname" . -}} {{- $svcPort := .Values.service.port -}} diff --git a/deployments/charts/openim-rpc-conversation/templates/service.yaml b/deployments/charts/openim-rpc-conversation/templates/service.yaml index be8355154..f90673584 100644 --- a/deployments/charts/openim-rpc-conversation/templates/service.yaml +++ b/deployments/charts/openim-rpc-conversation/templates/service.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: v1 kind: Service metadata: diff --git a/deployments/charts/openim-rpc-conversation/templates/serviceaccount.yaml b/deployments/charts/openim-rpc-conversation/templates/serviceaccount.yaml index 4e2d0e29f..14b1b2129 100644 --- a/deployments/charts/openim-rpc-conversation/templates/serviceaccount.yaml +++ b/deployments/charts/openim-rpc-conversation/templates/serviceaccount.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.serviceAccount.create -}} apiVersion: v1 kind: ServiceAccount diff --git a/deployments/charts/openim-rpc-conversation/values.yaml b/deployments/charts/openim-rpc-conversation/values.yaml index 1b3e1e3de..bb88ab613 100644 --- a/deployments/charts/openim-rpc-conversation/values.yaml +++ b/deployments/charts/openim-rpc-conversation/values.yaml @@ -1,3 +1,17 @@ +# 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. + # Default values for openim-rpc-conversation. # This is a YAML-formatted file. # Declare variables to be passed into your templates. diff --git a/deployments/charts/openim-rpc-friend/Chart.yaml b/deployments/charts/openim-rpc-friend/Chart.yaml index d7e4a9fef..62e92db9b 100644 --- a/deployments/charts/openim-rpc-friend/Chart.yaml +++ b/deployments/charts/openim-rpc-friend/Chart.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: v2 name: openim-rpc-friend description: A Helm chart for Kubernetes diff --git a/deployments/charts/openim-rpc-friend/templates/deployment.yaml b/deployments/charts/openim-rpc-friend/templates/deployment.yaml index 227ef1144..a57188828 100644 --- a/deployments/charts/openim-rpc-friend/templates/deployment.yaml +++ b/deployments/charts/openim-rpc-friend/templates/deployment.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: apps/v1 kind: Deployment metadata: diff --git a/deployments/charts/openim-rpc-friend/templates/hpa.yaml b/deployments/charts/openim-rpc-friend/templates/hpa.yaml index 7c4f14b7c..ae88e2621 100644 --- a/deployments/charts/openim-rpc-friend/templates/hpa.yaml +++ b/deployments/charts/openim-rpc-friend/templates/hpa.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.autoscaling.enabled }} apiVersion: autoscaling/v2beta1 kind: HorizontalPodAutoscaler diff --git a/deployments/charts/openim-rpc-friend/templates/ingress.yaml b/deployments/charts/openim-rpc-friend/templates/ingress.yaml index b5d411743..0845aa783 100644 --- a/deployments/charts/openim-rpc-friend/templates/ingress.yaml +++ b/deployments/charts/openim-rpc-friend/templates/ingress.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.ingress.enabled -}} {{- $fullName := include "openim-rpc-friend.fullname" . -}} {{- $svcPort := .Values.service.port -}} diff --git a/deployments/charts/openim-rpc-friend/templates/service.yaml b/deployments/charts/openim-rpc-friend/templates/service.yaml index 792592d87..e445d561f 100644 --- a/deployments/charts/openim-rpc-friend/templates/service.yaml +++ b/deployments/charts/openim-rpc-friend/templates/service.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: v1 kind: Service metadata: diff --git a/deployments/charts/openim-rpc-friend/templates/serviceaccount.yaml b/deployments/charts/openim-rpc-friend/templates/serviceaccount.yaml index c81343f6b..5146d6781 100644 --- a/deployments/charts/openim-rpc-friend/templates/serviceaccount.yaml +++ b/deployments/charts/openim-rpc-friend/templates/serviceaccount.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.serviceAccount.create -}} apiVersion: v1 kind: ServiceAccount diff --git a/deployments/charts/openim-rpc-friend/values.yaml b/deployments/charts/openim-rpc-friend/values.yaml index 041665a81..34dcda9da 100644 --- a/deployments/charts/openim-rpc-friend/values.yaml +++ b/deployments/charts/openim-rpc-friend/values.yaml @@ -1,3 +1,17 @@ +# 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. + # Default values for openim-rpc-friend. # This is a YAML-formatted file. # Declare variables to be passed into your templates. diff --git a/deployments/charts/openim-rpc-group/Chart.yaml b/deployments/charts/openim-rpc-group/Chart.yaml index 8e037caea..c3f7e3bfa 100644 --- a/deployments/charts/openim-rpc-group/Chart.yaml +++ b/deployments/charts/openim-rpc-group/Chart.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: v2 name: openim-rpc-group description: A Helm chart for Kubernetes diff --git a/deployments/charts/openim-rpc-group/templates/deployment.yaml b/deployments/charts/openim-rpc-group/templates/deployment.yaml index 74ebe6c92..406d0b342 100644 --- a/deployments/charts/openim-rpc-group/templates/deployment.yaml +++ b/deployments/charts/openim-rpc-group/templates/deployment.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: apps/v1 kind: Deployment metadata: diff --git a/deployments/charts/openim-rpc-group/templates/hpa.yaml b/deployments/charts/openim-rpc-group/templates/hpa.yaml index 0ba0e8283..91f313abe 100644 --- a/deployments/charts/openim-rpc-group/templates/hpa.yaml +++ b/deployments/charts/openim-rpc-group/templates/hpa.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.autoscaling.enabled }} apiVersion: autoscaling/v2beta1 kind: HorizontalPodAutoscaler diff --git a/deployments/charts/openim-rpc-group/templates/ingress.yaml b/deployments/charts/openim-rpc-group/templates/ingress.yaml index 6a744f914..e3cad781a 100644 --- a/deployments/charts/openim-rpc-group/templates/ingress.yaml +++ b/deployments/charts/openim-rpc-group/templates/ingress.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.ingress.enabled -}} {{- $fullName := include "openim-rpc-group.fullname" . -}} {{- $svcPort := .Values.service.port -}} diff --git a/deployments/charts/openim-rpc-group/templates/service.yaml b/deployments/charts/openim-rpc-group/templates/service.yaml index aa16f71b9..fc6f76060 100644 --- a/deployments/charts/openim-rpc-group/templates/service.yaml +++ b/deployments/charts/openim-rpc-group/templates/service.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: v1 kind: Service metadata: diff --git a/deployments/charts/openim-rpc-group/templates/serviceaccount.yaml b/deployments/charts/openim-rpc-group/templates/serviceaccount.yaml index b42dfb13b..304bbda56 100644 --- a/deployments/charts/openim-rpc-group/templates/serviceaccount.yaml +++ b/deployments/charts/openim-rpc-group/templates/serviceaccount.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.serviceAccount.create -}} apiVersion: v1 kind: ServiceAccount diff --git a/deployments/charts/openim-rpc-group/values.yaml b/deployments/charts/openim-rpc-group/values.yaml index ec36e256f..f04c64147 100644 --- a/deployments/charts/openim-rpc-group/values.yaml +++ b/deployments/charts/openim-rpc-group/values.yaml @@ -1,3 +1,17 @@ +# 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. + # Default values for openim-rpc-group. # This is a YAML-formatted file. # Declare variables to be passed into your templates. diff --git a/deployments/charts/openim-rpc-msg/Chart.yaml b/deployments/charts/openim-rpc-msg/Chart.yaml index 659767484..c32fe64c1 100644 --- a/deployments/charts/openim-rpc-msg/Chart.yaml +++ b/deployments/charts/openim-rpc-msg/Chart.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: v2 name: openim-rpc-msg description: A Helm chart for Kubernetes diff --git a/deployments/charts/openim-rpc-msg/templates/deployment.yaml b/deployments/charts/openim-rpc-msg/templates/deployment.yaml index e0565710a..d764294ea 100644 --- a/deployments/charts/openim-rpc-msg/templates/deployment.yaml +++ b/deployments/charts/openim-rpc-msg/templates/deployment.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: apps/v1 kind: Deployment metadata: diff --git a/deployments/charts/openim-rpc-msg/templates/hpa.yaml b/deployments/charts/openim-rpc-msg/templates/hpa.yaml index c01e07294..0e6dde369 100644 --- a/deployments/charts/openim-rpc-msg/templates/hpa.yaml +++ b/deployments/charts/openim-rpc-msg/templates/hpa.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.autoscaling.enabled }} apiVersion: autoscaling/v2beta1 kind: HorizontalPodAutoscaler diff --git a/deployments/charts/openim-rpc-msg/templates/ingress.yaml b/deployments/charts/openim-rpc-msg/templates/ingress.yaml index 2f5ad9d15..2ba587338 100644 --- a/deployments/charts/openim-rpc-msg/templates/ingress.yaml +++ b/deployments/charts/openim-rpc-msg/templates/ingress.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.ingress.enabled -}} {{- $fullName := include "openim-rpc-msg.fullname" . -}} {{- $svcPort := .Values.service.port -}} diff --git a/deployments/charts/openim-rpc-msg/templates/service.yaml b/deployments/charts/openim-rpc-msg/templates/service.yaml index 9afd55a8c..953b89d5d 100644 --- a/deployments/charts/openim-rpc-msg/templates/service.yaml +++ b/deployments/charts/openim-rpc-msg/templates/service.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: v1 kind: Service metadata: diff --git a/deployments/charts/openim-rpc-msg/templates/serviceaccount.yaml b/deployments/charts/openim-rpc-msg/templates/serviceaccount.yaml index da69e5ce8..70fd82069 100644 --- a/deployments/charts/openim-rpc-msg/templates/serviceaccount.yaml +++ b/deployments/charts/openim-rpc-msg/templates/serviceaccount.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.serviceAccount.create -}} apiVersion: v1 kind: ServiceAccount diff --git a/deployments/charts/openim-rpc-msg/values.yaml b/deployments/charts/openim-rpc-msg/values.yaml index 22cfd61f1..cf2f4e84d 100644 --- a/deployments/charts/openim-rpc-msg/values.yaml +++ b/deployments/charts/openim-rpc-msg/values.yaml @@ -1,3 +1,17 @@ +# 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. + # Default values for openim-rpc-msg. # This is a YAML-formatted file. # Declare variables to be passed into your templates. diff --git a/deployments/charts/openim-rpc-third/Chart.yaml b/deployments/charts/openim-rpc-third/Chart.yaml index d7763d70a..ff624aa34 100644 --- a/deployments/charts/openim-rpc-third/Chart.yaml +++ b/deployments/charts/openim-rpc-third/Chart.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: v2 name: openim-rpc-third description: A Helm chart for Kubernetes diff --git a/deployments/charts/openim-rpc-third/templates/deployment.yaml b/deployments/charts/openim-rpc-third/templates/deployment.yaml index c14cce817..e4f47de57 100644 --- a/deployments/charts/openim-rpc-third/templates/deployment.yaml +++ b/deployments/charts/openim-rpc-third/templates/deployment.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: apps/v1 kind: Deployment metadata: diff --git a/deployments/charts/openim-rpc-third/templates/hpa.yaml b/deployments/charts/openim-rpc-third/templates/hpa.yaml index 2197e21a5..f20ecb973 100644 --- a/deployments/charts/openim-rpc-third/templates/hpa.yaml +++ b/deployments/charts/openim-rpc-third/templates/hpa.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.autoscaling.enabled }} apiVersion: autoscaling/v2beta1 kind: HorizontalPodAutoscaler diff --git a/deployments/charts/openim-rpc-third/templates/ingress.yaml b/deployments/charts/openim-rpc-third/templates/ingress.yaml index 3ba50cf33..1c64ac545 100644 --- a/deployments/charts/openim-rpc-third/templates/ingress.yaml +++ b/deployments/charts/openim-rpc-third/templates/ingress.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.ingress.enabled -}} {{- $fullName := include "openim-rpc-third.fullname" . -}} {{- $svcPort := .Values.service.port -}} diff --git a/deployments/charts/openim-rpc-third/templates/service.yaml b/deployments/charts/openim-rpc-third/templates/service.yaml index 866b5cda2..f467992a2 100644 --- a/deployments/charts/openim-rpc-third/templates/service.yaml +++ b/deployments/charts/openim-rpc-third/templates/service.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: v1 kind: Service metadata: diff --git a/deployments/charts/openim-rpc-third/templates/serviceaccount.yaml b/deployments/charts/openim-rpc-third/templates/serviceaccount.yaml index 8a45872ce..27f2bf067 100644 --- a/deployments/charts/openim-rpc-third/templates/serviceaccount.yaml +++ b/deployments/charts/openim-rpc-third/templates/serviceaccount.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.serviceAccount.create -}} apiVersion: v1 kind: ServiceAccount diff --git a/deployments/charts/openim-rpc-third/values.yaml b/deployments/charts/openim-rpc-third/values.yaml index 8a92566a9..71d9a3ede 100644 --- a/deployments/charts/openim-rpc-third/values.yaml +++ b/deployments/charts/openim-rpc-third/values.yaml @@ -1,3 +1,17 @@ +# 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. + # Default values for openim-rpc-third. # This is a YAML-formatted file. # Declare variables to be passed into your templates. diff --git a/deployments/charts/openim-rpc-user/Chart.yaml b/deployments/charts/openim-rpc-user/Chart.yaml index 7a2118e46..feb5a3195 100644 --- a/deployments/charts/openim-rpc-user/Chart.yaml +++ b/deployments/charts/openim-rpc-user/Chart.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: v2 name: openim-rpc-user description: A Helm chart for Kubernetes diff --git a/deployments/charts/openim-rpc-user/templates/deployment.yaml b/deployments/charts/openim-rpc-user/templates/deployment.yaml index f6f679c2d..62106e5a2 100644 --- a/deployments/charts/openim-rpc-user/templates/deployment.yaml +++ b/deployments/charts/openim-rpc-user/templates/deployment.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: apps/v1 kind: Deployment metadata: diff --git a/deployments/charts/openim-rpc-user/templates/hpa.yaml b/deployments/charts/openim-rpc-user/templates/hpa.yaml index 7c00c9d64..012b15ae3 100644 --- a/deployments/charts/openim-rpc-user/templates/hpa.yaml +++ b/deployments/charts/openim-rpc-user/templates/hpa.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.autoscaling.enabled }} apiVersion: autoscaling/v2beta1 kind: HorizontalPodAutoscaler diff --git a/deployments/charts/openim-rpc-user/templates/ingress.yaml b/deployments/charts/openim-rpc-user/templates/ingress.yaml index 7ed5a0328..38aa6fdff 100644 --- a/deployments/charts/openim-rpc-user/templates/ingress.yaml +++ b/deployments/charts/openim-rpc-user/templates/ingress.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.ingress.enabled -}} {{- $fullName := include "openim-rpc-user.fullname" . -}} {{- $svcPort := .Values.service.port -}} diff --git a/deployments/charts/openim-rpc-user/templates/service.yaml b/deployments/charts/openim-rpc-user/templates/service.yaml index 728c5de92..f89be1c44 100644 --- a/deployments/charts/openim-rpc-user/templates/service.yaml +++ b/deployments/charts/openim-rpc-user/templates/service.yaml @@ -1,3 +1,17 @@ +# 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. + apiVersion: v1 kind: Service metadata: diff --git a/deployments/charts/openim-rpc-user/templates/serviceaccount.yaml b/deployments/charts/openim-rpc-user/templates/serviceaccount.yaml index d3395f00d..ebe3e3d68 100644 --- a/deployments/charts/openim-rpc-user/templates/serviceaccount.yaml +++ b/deployments/charts/openim-rpc-user/templates/serviceaccount.yaml @@ -1,3 +1,17 @@ +# 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. + {{- if .Values.serviceAccount.create -}} apiVersion: v1 kind: ServiceAccount diff --git a/deployments/charts/openim-rpc-user/values.yaml b/deployments/charts/openim-rpc-user/values.yaml index d137f0ad7..4f1ad7ede 100644 --- a/deployments/charts/openim-rpc-user/values.yaml +++ b/deployments/charts/openim-rpc-user/values.yaml @@ -1,3 +1,17 @@ +# 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. + # Default values for openim-rpc-user. # This is a YAML-formatted file. # Declare variables to be passed into your templates. diff --git a/deployments/openim-charts.yaml b/deployments/openim-charts.yaml index 59815dbd5..2b468dad0 100644 --- a/deployments/openim-charts.yaml +++ b/deployments/openim-charts.yaml @@ -1,3 +1,17 @@ +# 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. + --- # Source: openim-api/templates/app-cm.yaml apiVersion: v1 diff --git a/deployments/templates/alertmanager.yml b/deployments/templates/alertmanager.yml index ea99a9286..4e390b2bb 100644 --- a/deployments/templates/alertmanager.yml +++ b/deployments/templates/alertmanager.yml @@ -1,3 +1,17 @@ +# 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. + ###################### AlertManager Configuration ###################### # AlertManager configuration using environment variables # diff --git a/deployments/templates/charts-value.yaml b/deployments/templates/charts-value.yaml index 274d9b8d1..26bbe2926 100644 --- a/deployments/templates/charts-value.yaml +++ b/deployments/templates/charts-value.yaml @@ -1,3 +1,17 @@ +# 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. + #This configuration file is used to override the use of the value.yaml variable. #Currently, only the configuration with ingressName as nginx is provided. #If it is another gateway such as istio or treafik, please modify the corresponding gateway requirements diff --git a/deployments/templates/chat.yaml b/deployments/templates/chat.yaml deleted file mode 100644 index 561d45d6e..000000000 --- a/deployments/templates/chat.yaml +++ /dev/null @@ -1,118 +0,0 @@ -# Copyright © 2023 OpenIM. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Configuration for OpenIMServer - -# ----------------------------------------------------------------- -# TODO: This config file is the template file -# --| source: deployments/templates/chat.yaml -# --| env: scripts/install/environment -# --| target: config/config.yaml -# ----------------------------------------------------------------- - -###################### Zookeeper ###################### -# Zookeeper configuration -# It's not recommended to modify the schema -zookeeper: - schema: ${ZOOKEEPER_SCHEMA} - zkAddr: - - ${ZOOKEEPER_ADDRESS}:${ZOOKEEPER_PORT} - username: ${ZOOKEEPER_USERNAME} - password: ${ZOOKEEPER_PASSWORD} - -###################### Chat API ###################### -chatApi: - openImChatApiPort: [ ${OPENIM_CHAT_API_PORT} ] - listenIP: ${CHAT_API_LISTEN_IP} - -###################### Admin API ###################### -adminApi: - openImAdminApiPort: [ ${OPENIM_ADMIN_API_PORT} ] - listenIP: ${ADMIN_API_LISTEN_IP} - -###################### RPC ###################### -rpc: - registerIP: #作为rpc启动时,注册到zookeeper的IP,api/gateway能访问到此ip和对应的rpcPort中的端口 - listenIP: #默认为0.0.0.0 - -rpcPort: - openImAdminPort: [ ${OPENIM_ADMIN_PORT} ] - openImChatPort: [ ${OPENIM_CHAT_PORT} ] -rpcRegisterName: - openImAdminName: ${OPENIM_ADMIN_NAME} - openImChatName: ${OPENIM_CHAT_NAME} - -###################### Log ###################### -log: - storageLocation: ../logs/ #存放目录 -# rotationTime: 24 #日志旋转时间 -# remainRotationCount: 2 #日志数量 -# remainLogLevel: 6 #日志级别 6表示全都打印, -# isStdout: false -# isJson: false -# withStack: false - -###################### Secret & Token Policy ###################### -# secret: openIM123 -#tokenPolicy: -# expire: 86400 - -###################### Verify Code ###################### -verifyCode: - validTime: 300 # 验证码有效时间 - validCount: 5 # 验证码有效次数 - uintTime: 86400 # 单位时间间隔 - maxCount: 10 # 单位时间内最大获取次数 - superCode: "666666" # 超级验证码(只有use为空时使用) - len: 6 # 验证码长度 - use: "" # 使用的验证码服务(use: "ali") - ali: - endpoint: "dysmsapi.aliyuncs.com" - accessKeyId: "" - accessKeySecret: "" - signName: "" - verificationCodeTemplateCode: "" - mail: # 根据对应的发件邮箱更改 sendMail、senderAuthorizationCode、smtpAddr、smtpPort 即可 - title: "" - senderMail: "" # 发送者 - senderAuthorizationCode: "" # 授权码 - smtpAddr: "smtp.qq.com" # smtp 服务器地址 - smtpPort: 25 # smtp 服务器邮件发送端口 - testDepartMentID: 001 - imAPIURL: http://127.0.0.1:10002 - -###################### Proxy Header ###################### -# 获取ip的header,没有配置直接获取远程地址 -#proxyHeader: "X-Forwarded-For" - -###################### Admin List ###################### -adminList: - - adminID: admin1 - nickname: chat1 - imAdmin: openIM123456 - - adminID: admin2 - nickname: chat2 - imAdmin: openIM654321 - - adminID: admin3 - nickname: chat3 - imAdmin: openIMAdmin - -###################### OpenIM URL ###################### -openIMUrl: ${OPENIM_SERVER_ADDRESS}:${API_OPENIM_PORT} - -###################### Redis ###################### -redis: - # address: [ 127.0.0.1:16379 ] - # username: - # password: openIM123 diff --git a/deployments/templates/email.tmpl b/deployments/templates/email.tmpl new file mode 100644 index 000000000..0385601d0 --- /dev/null +++ b/deployments/templates/email.tmpl @@ -0,0 +1,16 @@ +{{ define "email.to.html" }} +{{ range .Alerts }} + +
+

OpenIM Alert

+

Alert Program: Prometheus Alert

+

Severity Level: {{ .Labels.severity }}

+

Alert Type: {{ .Labels.alertname }}

+

Affected Host: {{ .Labels.instance }}

+

Affected Service: {{ .Labels.job }}

+

Alert Subject: {{ .Annotations.summary }}

+

Trigger Time: {{ .StartsAt.Format "2006-01-02 15:04:05" }}

+
+ +{{ end }} +{{ end }} diff --git a/deployments/templates/env-template.yaml b/deployments/templates/env-template.yaml index b4118b9ce..ab9c87c02 100644 --- a/deployments/templates/env-template.yaml +++ b/deployments/templates/env-template.yaml @@ -1,3 +1,17 @@ +# 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. + # ====================================== # ========= Basic Configuration ======== # ====================================== @@ -10,10 +24,6 @@ USER=${OPENIM_USER} # Default: PASSWORD=openIM123 PASSWORD=${PASSWORD} -# Endpoint for the MinIO object storage service. -# Default: MINIO_ENDPOINT=http://172.28.0.1:10005 -MINIO_ENDPOINT=${MINIO_ENDPOINT} - # Base URL for the application programming interface (API). # Default: API_URL=http://172.28.0.1:10002 API_URL=${API_URL} diff --git a/deployments/templates/helm-image.yaml b/deployments/templates/helm-image.yaml index 317bc34ac..ef64abf91 100644 --- a/deployments/templates/helm-image.yaml +++ b/deployments/templates/helm-image.yaml @@ -1,3 +1,17 @@ +# 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. + #This configuration file is used to override the use of the value.yaml variable. #Currently, only the configuration with ingressName as nginx is provided. #If it is another gateway such as istio or treafik, please modify the corresponding gateway requirements diff --git a/config/instance-down-rules.yml b/deployments/templates/instance-down-rules.yml similarity index 61% rename from config/instance-down-rules.yml rename to deployments/templates/instance-down-rules.yml index 5541d2c54..7a6e9fda9 100644 --- a/config/instance-down-rules.yml +++ b/deployments/templates/instance-down-rules.yml @@ -1,3 +1,17 @@ +# 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. + groups: - name: instance_down rules: diff --git a/config/notification.yaml b/deployments/templates/notification.yaml similarity index 88% rename from config/notification.yaml rename to deployments/templates/notification.yaml index 5e5223a00..665c21261 100644 --- a/config/notification.yaml +++ b/deployments/templates/notification.yaml @@ -12,18 +12,36 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Determines if a message should be sent. If set to false, it triggers a silent sync without a message. If true, it requires triggering a conversation. +# For rpc notification, send twice: once as a message and once as a notification. +# The options field 'isNotification' indicates if it's a notification. groupCreated: - isSendMsg: true #是否发送消息,false不发消息为无声的触发同步。true发消息需要触发会话,rpc notification直接发两次,一次消息一次通知, options字段isNotification是否为通知 - reliabilityLevel: 1 # 1为online才发送 2为必达 - unreadCount: false # 只在isSendMsg为true的情况下有作用 + isSendMsg: true + +# Reliability level of the message sending. +# Set to 1 to send only when online, 2 for guaranteed delivery. + reliabilityLevel: 1 + +# This setting is effective only when 'isSendMsg' is true. +# It controls whether to count unread messages. + unreadCount: false + +# Configuration for offline push notifications. offlinePush: - enable: false # 开启该开关 - title: "create group title" # xx create the group + # Enables or disables offline push notifications. + enable: false + + # Title for the notification when a group is created. + title: "create group title" + + # Description for the notification. desc: "create group desc" - ext: "create group ext" -# 不加消息contentType,content统一json 结构体使用pb的 + # Additional information for the notification. + ext: "create group ext" +# Content type is not added here. +# Content should use a JSON structure conforming to the protobuf format. groupInfoSet: isSendMsg: false @@ -334,4 +352,3 @@ conversationSetPrivate: title: "burn after reading" desc: "burn after reading" ext: "burn after reading" - diff --git a/deployments/templates/openim.yaml b/deployments/templates/openim.yaml index d822fec13..ed5dc4fe1 100644 --- a/deployments/templates/openim.yaml +++ b/deployments/templates/openim.yaml @@ -37,13 +37,20 @@ zookeeper: ###################### Mongo ###################### # MongoDB configuration -# If uri is not empty, it will be used directly -# -# MongoDB address for standalone setup, Mongos address for sharded cluster setup -# Default MongoDB database name -# Maximum connection pool size + +# If uri is not empty, it will be used directly for the MongoDB connection. +# This is a complete MongoDB URI string. +# Example: mongodb://user:password@host1:port1,host2:port2/dbname?options mongo: uri: ${MONGO_URI} + +# List of MongoDB server addresses. +# Used for constructing the MongoDB URI if 'uri' above is empty. +# For a standalone setup, specify the address of the single server. +# For a sharded cluster, specify the addresses of the Mongos servers. +# Example: [ '172.28.0.1:37017', '172.28.0.2:37017' ] +# Default MongoDB database name +# Maximum connection pool size address: [ ${MONGO_ADDRESS}:${MONGO_PORT} ] database: ${MONGO_DATABASE} username: ${MONGO_USERNAME} diff --git a/deployments/templates/prometheus.yml b/deployments/templates/prometheus.yml index fb07a8129..5c3e0af66 100644 --- a/deployments/templates/prometheus.yml +++ b/deployments/templates/prometheus.yml @@ -1,3 +1,17 @@ +# 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. + # my global config global: scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. diff --git a/internal/api/msg.go b/internal/api/msg.go index 22182d985..664ee505a 100644 --- a/internal/api/msg.go +++ b/internal/api/msg.go @@ -27,6 +27,7 @@ import ( "github.com/gin-gonic/gin" "github.com/go-playground/validator/v10" "github.com/mitchellh/mapstructure" + "github.com/openimsdk/open-im-server/v3/pkg/authverify" "github.com/openimsdk/open-im-server/v3/pkg/common/config" diff --git a/internal/msggateway/compressor_test.go b/internal/msggateway/compressor_test.go index d41c57bf3..b1544f063 100644 --- a/internal/msggateway/compressor_test.go +++ b/internal/msggateway/compressor_test.go @@ -1,3 +1,17 @@ +// Copyright © 2023 OpenIM. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package msggateway import ( diff --git a/internal/push/offlinepush/dummy/push.go b/internal/push/offlinepush/dummy/push.go index 2b15bc05d..f147886d9 100644 --- a/internal/push/offlinepush/dummy/push.go +++ b/internal/push/offlinepush/dummy/push.go @@ -1,3 +1,17 @@ +// 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 dummy import ( diff --git a/internal/push/push_rpc_server.go b/internal/push/push_rpc_server.go index 9e66f8f73..188ddc0e1 100644 --- a/internal/push/push_rpc_server.go +++ b/internal/push/push_rpc_server.go @@ -16,9 +16,10 @@ package push import ( "context" - "github.com/OpenIMSDK/tools/utils" "sync" + "github.com/OpenIMSDK/tools/utils" + "google.golang.org/grpc" "github.com/OpenIMSDK/protocol/constant" diff --git a/internal/rpc/friend/callback.go b/internal/rpc/friend/callback.go index d541071f5..e5054d9a9 100644 --- a/internal/rpc/friend/callback.go +++ b/internal/rpc/friend/callback.go @@ -16,8 +16,10 @@ package friend import ( "context" + pbfriend "github.com/OpenIMSDK/protocol/friend" "github.com/OpenIMSDK/tools/utils" + cbapi "github.com/openimsdk/open-im-server/v3/pkg/callbackstruct" "github.com/openimsdk/open-im-server/v3/pkg/common/config" "github.com/openimsdk/open-im-server/v3/pkg/common/http" diff --git a/internal/rpc/friend/friend.go b/internal/rpc/friend/friend.go index 21422fae3..20c47ad8f 100644 --- a/internal/rpc/friend/friend.go +++ b/internal/rpc/friend/friend.go @@ -16,6 +16,7 @@ package friend import ( "context" + "github.com/OpenIMSDK/tools/tx" "github.com/OpenIMSDK/protocol/sdkws" diff --git a/internal/rpc/group/callback.go b/internal/rpc/group/callback.go index 1599cc7b4..4a89a16fb 100644 --- a/internal/rpc/group/callback.go +++ b/internal/rpc/group/callback.go @@ -16,9 +16,10 @@ package group import ( "context" - "github.com/OpenIMSDK/tools/log" "time" + "github.com/OpenIMSDK/tools/log" + "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/group" "github.com/OpenIMSDK/protocol/wrapperspb" diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index b05b14b59..2c3c6fc43 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -17,13 +17,14 @@ package group import ( "context" "fmt" - "github.com/openimsdk/open-im-server/v3/pkg/callbackstruct" "math/big" "math/rand" "strconv" "strings" "time" + "github.com/openimsdk/open-im-server/v3/pkg/callbackstruct" + pbconversation "github.com/OpenIMSDK/protocol/conversation" "github.com/OpenIMSDK/protocol/wrapperspb" "github.com/OpenIMSDK/tools/tx" diff --git a/internal/rpc/msg/as_read.go b/internal/rpc/msg/as_read.go index 061498abb..5324ccba8 100644 --- a/internal/rpc/msg/as_read.go +++ b/internal/rpc/msg/as_read.go @@ -16,16 +16,18 @@ package msg import ( "context" + utils2 "github.com/OpenIMSDK/tools/utils" "github.com/redis/go-redis/v9" - cbapi "github.com/openimsdk/open-im-server/v3/pkg/callbackstruct" "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/msg" "github.com/OpenIMSDK/protocol/sdkws" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/log" + + cbapi "github.com/openimsdk/open-im-server/v3/pkg/callbackstruct" ) func (m *msgServer) GetConversationsHasReadAndMaxSeq(ctx context.Context, req *msg.GetConversationsHasReadAndMaxSeqReq) (resp *msg.GetConversationsHasReadAndMaxSeqResp, err error) { @@ -173,7 +175,7 @@ func (m *msgServer) MarkConversationAsRead( m.conversationAndGetRecvID(conversation, req.UserID), seqs, hasReadSeq); err != nil { return nil, err } - + } else if conversation.ConversationType == constant.SuperGroupChatType || conversation.ConversationType == constant.NotificationChatType { if req.HasReadSeq > hasReadSeq { @@ -222,4 +224,4 @@ func (m *msgServer) sendMarkAsReadNotification( log.ZWarn(ctx, "send has read Receipt err", err) } return nil -} \ No newline at end of file +} diff --git a/internal/rpc/msg/callback.go b/internal/rpc/msg/callback.go index 4ce5a5443..0bd71d9f7 100644 --- a/internal/rpc/msg/callback.go +++ b/internal/rpc/msg/callback.go @@ -16,6 +16,7 @@ package msg import ( "context" + "github.com/OpenIMSDK/protocol/sdkws" "google.golang.org/protobuf/proto" @@ -24,6 +25,7 @@ import ( "github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/mcontext" "github.com/OpenIMSDK/tools/utils" + cbapi "github.com/openimsdk/open-im-server/v3/pkg/callbackstruct" "github.com/openimsdk/open-im-server/v3/pkg/common/config" diff --git a/internal/rpc/third/log.go b/internal/rpc/third/log.go index 57d4f536e..11c7467b8 100644 --- a/internal/rpc/third/log.go +++ b/internal/rpc/third/log.go @@ -1,3 +1,17 @@ +// 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 third import ( diff --git a/internal/rpc/user/callback.go b/internal/rpc/user/callback.go index e87b4674e..7d865af5f 100644 --- a/internal/rpc/user/callback.go +++ b/internal/rpc/user/callback.go @@ -16,6 +16,7 @@ package user import ( "context" + pbuser "github.com/OpenIMSDK/protocol/user" "github.com/OpenIMSDK/tools/utils" diff --git a/internal/tools/cron_task_test.go b/internal/tools/cron_task_test.go index 1f4f1f5c1..28bc2c945 100644 --- a/internal/tools/cron_task_test.go +++ b/internal/tools/cron_task_test.go @@ -1,3 +1,17 @@ +// 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 tools import ( diff --git a/pkg/apistruct/msg.go b/pkg/apistruct/msg.go index 61b4d832b..4b7bd1e6f 100644 --- a/pkg/apistruct/msg.go +++ b/pkg/apistruct/msg.go @@ -16,11 +16,11 @@ package apistruct type PictureBaseInfo struct { UUID string `mapstructure:"uuid"` - Type string `mapstructure:"type" validate:"required"` + Type string `mapstructure:"type" validate:"required"` Size int64 `mapstructure:"size"` - Width int32 `mapstructure:"width" validate:"required"` + Width int32 `mapstructure:"width" validate:"required"` Height int32 `mapstructure:"height" validate:"required"` - Url string `mapstructure:"url" validate:"required"` + Url string `mapstructure:"url" validate:"required"` } type PictureElem struct { @@ -34,28 +34,28 @@ type SoundElem struct { SoundPath string `mapstructure:"soundPath"` SourceURL string `mapstructure:"sourceUrl" validate:"required"` DataSize int64 `mapstructure:"dataSize"` - Duration int64 `mapstructure:"duration" validate:"required,min=1"` + Duration int64 `mapstructure:"duration" validate:"required,min=1"` } type VideoElem struct { - VideoPath string `mapstructure:"videoPath" ` + VideoPath string `mapstructure:"videoPath"` VideoUUID string `mapstructure:"videoUUID"` - VideoURL string `mapstructure:"videoUrl" validate:"required"` - VideoType string `mapstructure:"videoType" validate:"required"` - VideoSize int64 `mapstructure:"videoSize" validate:"required"` - Duration int64 `mapstructure:"duration" validate:"required"` + VideoURL string `mapstructure:"videoUrl" validate:"required"` + VideoType string `mapstructure:"videoType" validate:"required"` + VideoSize int64 `mapstructure:"videoSize" validate:"required"` + Duration int64 `mapstructure:"duration" validate:"required"` SnapshotPath string `mapstructure:"snapshotPath"` SnapshotUUID string `mapstructure:"snapshotUUID"` SnapshotSize int64 `mapstructure:"snapshotSize"` - SnapshotURL string `mapstructure:"snapshotUrl" validate:"required"` - SnapshotWidth int32 `mapstructure:"snapshotWidth" validate:"required"` + SnapshotURL string `mapstructure:"snapshotUrl" validate:"required"` + SnapshotWidth int32 `mapstructure:"snapshotWidth" validate:"required"` SnapshotHeight int32 `mapstructure:"snapshotHeight" validate:"required"` } type FileElem struct { - FilePath string `mapstructure:"filePath" ` + FilePath string `mapstructure:"filePath"` UUID string `mapstructure:"uuid"` SourceURL string `mapstructure:"sourceUrl" validate:"required"` - FileName string `mapstructure:"fileName" validate:"required"` - FileSize int64 `mapstructure:"fileSize" validate:"required"` + FileName string `mapstructure:"fileName" validate:"required"` + FileSize int64 `mapstructure:"fileSize" validate:"required"` } type AtElem struct { Text string `mapstructure:"text"` @@ -63,9 +63,9 @@ type AtElem struct { IsAtSelf bool `mapstructure:"isAtSelf"` } type LocationElem struct { - Description string `mapstructure:"description" ` - Longitude float64 `mapstructure:"longitude" validate:"required"` - Latitude float64 `mapstructure:"latitude" validate:"required"` + Description string `mapstructure:"description"` + Longitude float64 `mapstructure:"longitude" validate:"required"` + Latitude float64 `mapstructure:"latitude" validate:"required"` } type CustomElem struct { Data string `mapstructure:"data" validate:"required"` @@ -87,7 +87,7 @@ type OANotificationElem struct { NotificationType int32 `mapstructure:"notificationType" json:"notificationType" validate:"required"` Text string `mapstructure:"text" json:"text" validate:"required"` Url string `mapstructure:"url" json:"url"` - MixType int32 `mapstructure:"mixType" json:"mixType" validate:"required"` + MixType int32 `mapstructure:"mixType" json:"mixType" validate:"required"` PictureElem *PictureElem `mapstructure:"pictureElem" json:"pictureElem"` SoundElem *SoundElem `mapstructure:"soundElem" json:"soundElem"` VideoElem *VideoElem `mapstructure:"videoElem" json:"videoElem"` diff --git a/pkg/callbackstruct/constant.go b/pkg/callbackstruct/constant.go index 2af337ac6..0a03a1ef1 100644 --- a/pkg/callbackstruct/constant.go +++ b/pkg/callbackstruct/constant.go @@ -1,3 +1,17 @@ +// 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 callbackstruct const CallbackBeforeInviteJoinGroupCommand = "callbackBeforeInviteJoinGroupCommand" diff --git a/pkg/callbackstruct/revoke.go b/pkg/callbackstruct/revoke.go index 364c0162b..1f5e0b0c1 100644 --- a/pkg/callbackstruct/revoke.go +++ b/pkg/callbackstruct/revoke.go @@ -1,3 +1,17 @@ +// 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 callbackstruct type CallbackAfterRevokeMsgReq struct { diff --git a/pkg/common/cmd/constant.go b/pkg/common/cmd/constant.go index 835593bbe..c332ce3a6 100644 --- a/pkg/common/cmd/constant.go +++ b/pkg/common/cmd/constant.go @@ -1,3 +1,17 @@ +// 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 cmd const ( diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go index 5fb8fe7e2..6da89fc8f 100644 --- a/pkg/common/config/config.go +++ b/pkg/common/config/config.go @@ -16,6 +16,7 @@ package config import ( "bytes" + "github.com/OpenIMSDK/tools/discoveryregistry" "gopkg.in/yaml.v3" ) diff --git a/pkg/common/config/parse.go b/pkg/common/config/parse.go index 22e458e00..1410a5a4a 100644 --- a/pkg/common/config/parse.go +++ b/pkg/common/config/parse.go @@ -35,7 +35,7 @@ const ( DefaultFolderPath = "../config/" ) -// return absolude path join ../config/, this is k8s container config path +// return absolude path join ../config/, this is k8s container config path. func GetDefaultConfigPath() string { b, err := filepath.Abs(os.Args[0]) if err != nil { @@ -45,7 +45,7 @@ func GetDefaultConfigPath() string { return filepath.Join(filepath.Dir(b), "../config/") } -// getProjectRoot returns the absolute path of the project root directory +// getProjectRoot returns the absolute path of the project root directory. func GetProjectRoot() string { b, _ := filepath.Abs(os.Args[0]) diff --git a/pkg/common/convert/user.go b/pkg/common/convert/user.go index 0c71aac22..8d960546a 100644 --- a/pkg/common/convert/user.go +++ b/pkg/common/convert/user.go @@ -15,9 +15,10 @@ package convert import ( - "github.com/OpenIMSDK/protocol/sdkws" "time" + "github.com/OpenIMSDK/protocol/sdkws" + relationtb "github.com/openimsdk/open-im-server/v3/pkg/common/db/table/relation" ) diff --git a/pkg/common/db/cache/group.go b/pkg/common/db/cache/group.go index 603d8e534..57fcf1a9b 100644 --- a/pkg/common/db/cache/group.go +++ b/pkg/common/db/cache/group.go @@ -39,7 +39,7 @@ const ( groupMemberIDsKey = "GROUP_MEMBER_IDS:" groupMembersHashKey = "GROUP_MEMBERS_HASH2:" groupMemberInfoKey = "GROUP_MEMBER_INFO:" - //groupOwnerInfoKey = "GROUP_OWNER_INFO:" + //groupOwnerInfoKey = "GROUP_OWNER_INFO:". joinedGroupsKey = "JOIN_GROUPS_KEY:" groupMemberNumKey = "GROUP_MEMBER_NUM_CACHE:" groupRoleLevelMemberIDsKey = "GROUP_ROLE_LEVEL_MEMBER_IDS:" diff --git a/pkg/common/db/cache/init_redis.go b/pkg/common/db/cache/init_redis.go index 77b38d9b7..63d2f5707 100644 --- a/pkg/common/db/cache/init_redis.go +++ b/pkg/common/db/cache/init_redis.go @@ -18,6 +18,8 @@ import ( "context" "errors" "fmt" + "os" + "strings" "time" "github.com/redis/go-redis/v9" @@ -43,6 +45,9 @@ func NewRedis() (redis.UniversalClient, error) { return redisClient, nil } + // Read configuration from environment variables + overrideConfigFromEnv() + if len(config.Config.Redis.Address) == 0 { return nil, errors.New("redis address is empty") } @@ -60,9 +65,9 @@ func NewRedis() (redis.UniversalClient, error) { rdb = redis.NewClient(&redis.Options{ Addr: config.Config.Redis.Address[0], Username: config.Config.Redis.Username, - Password: config.Config.Redis.Password, // no password set - DB: 0, // use default DB - PoolSize: 100, // connection pool size + Password: config.Config.Redis.Password, + DB: 0, // use default DB + PoolSize: 100, // connection pool size MaxRetries: maxRetry, }) } @@ -78,3 +83,16 @@ func NewRedis() (redis.UniversalClient, error) { redisClient = rdb return rdb, err } + +// overrideConfigFromEnv overrides configuration fields with environment variables if present. +func overrideConfigFromEnv() { + if envAddr := os.Getenv("REDIS_ADDRESS"); envAddr != "" { + config.Config.Redis.Address = strings.Split(envAddr, ",") // Assuming addresses are comma-separated + } + if envUser := os.Getenv("REDIS_USERNAME"); envUser != "" { + config.Config.Redis.Username = envUser + } + if envPass := os.Getenv("REDIS_PASSWORD"); envPass != "" { + config.Config.Redis.Password = envPass + } +} diff --git a/pkg/common/db/cache/msg_test.go b/pkg/common/db/cache/msg_test.go index 3fddf5965..65413199a 100644 --- a/pkg/common/db/cache/msg_test.go +++ b/pkg/common/db/cache/msg_test.go @@ -1,3 +1,17 @@ +// 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 cache import ( diff --git a/pkg/common/db/cache/s3.go b/pkg/common/db/cache/s3.go index ba40ceacc..1e68cedf8 100644 --- a/pkg/common/db/cache/s3.go +++ b/pkg/common/db/cache/s3.go @@ -1,3 +1,17 @@ +// 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 cache import ( diff --git a/pkg/common/db/mgo/black.go b/pkg/common/db/mgo/black.go index 6235639aa..1047e5c30 100644 --- a/pkg/common/db/mgo/black.go +++ b/pkg/common/db/mgo/black.go @@ -1,3 +1,17 @@ +// 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 mgo import ( diff --git a/pkg/common/db/mgo/conversation.go b/pkg/common/db/mgo/conversation.go index 72d04ebb3..bf5d1a145 100644 --- a/pkg/common/db/mgo/conversation.go +++ b/pkg/common/db/mgo/conversation.go @@ -1,3 +1,17 @@ +// 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 mgo import ( diff --git a/pkg/common/db/mgo/friend.go b/pkg/common/db/mgo/friend.go index aa9cb0301..8f3528d91 100644 --- a/pkg/common/db/mgo/friend.go +++ b/pkg/common/db/mgo/friend.go @@ -1,3 +1,17 @@ +// 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 mgo import ( diff --git a/pkg/common/db/mgo/friend_request.go b/pkg/common/db/mgo/friend_request.go index c1be87ca2..bfc101917 100644 --- a/pkg/common/db/mgo/friend_request.go +++ b/pkg/common/db/mgo/friend_request.go @@ -1,3 +1,17 @@ +// 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 mgo import ( diff --git a/pkg/common/db/mgo/group.go b/pkg/common/db/mgo/group.go index 3553b6b56..65dbbca59 100644 --- a/pkg/common/db/mgo/group.go +++ b/pkg/common/db/mgo/group.go @@ -1,3 +1,17 @@ +// 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 mgo import ( diff --git a/pkg/common/db/mgo/group_member.go b/pkg/common/db/mgo/group_member.go index ed09a028b..8c3041901 100644 --- a/pkg/common/db/mgo/group_member.go +++ b/pkg/common/db/mgo/group_member.go @@ -1,3 +1,17 @@ +// 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 mgo import ( diff --git a/pkg/common/db/mgo/group_request.go b/pkg/common/db/mgo/group_request.go index e88a39bf5..cb04d2308 100644 --- a/pkg/common/db/mgo/group_request.go +++ b/pkg/common/db/mgo/group_request.go @@ -1,3 +1,17 @@ +// 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 mgo import ( diff --git a/pkg/common/db/mgo/log.go b/pkg/common/db/mgo/log.go index aa280fcf2..09f002ee3 100644 --- a/pkg/common/db/mgo/log.go +++ b/pkg/common/db/mgo/log.go @@ -1,3 +1,17 @@ +// 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 mgo import ( diff --git a/pkg/common/db/mgo/object.go b/pkg/common/db/mgo/object.go index 5976b2d28..88bfde213 100644 --- a/pkg/common/db/mgo/object.go +++ b/pkg/common/db/mgo/object.go @@ -1,3 +1,17 @@ +// 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 mgo import ( diff --git a/pkg/common/db/mgo/user.go b/pkg/common/db/mgo/user.go index 4a53cb3c4..37e354cbb 100644 --- a/pkg/common/db/mgo/user.go +++ b/pkg/common/db/mgo/user.go @@ -1,3 +1,17 @@ +// 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 mgo import ( diff --git a/pkg/common/db/s3/cos/internal.go b/pkg/common/db/s3/cos/internal.go index 02afde684..064546953 100644 --- a/pkg/common/db/s3/cos/internal.go +++ b/pkg/common/db/s3/cos/internal.go @@ -1,3 +1,17 @@ +// 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 cos import ( diff --git a/pkg/common/db/s3/minio/internal.go b/pkg/common/db/s3/minio/internal.go index 41129ce31..7e9dcd9e4 100644 --- a/pkg/common/db/s3/minio/internal.go +++ b/pkg/common/db/s3/minio/internal.go @@ -1,3 +1,17 @@ +// 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 minio import ( diff --git a/pkg/common/db/s3/minio/thumbnail.go b/pkg/common/db/s3/minio/thumbnail.go index 01b14541b..49c376c9f 100644 --- a/pkg/common/db/s3/minio/thumbnail.go +++ b/pkg/common/db/s3/minio/thumbnail.go @@ -1,3 +1,17 @@ +// 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 minio import ( diff --git a/pkg/common/db/table/relation/log.go b/pkg/common/db/table/relation/log.go index f690ff8aa..ba63c0c2b 100644 --- a/pkg/common/db/table/relation/log.go +++ b/pkg/common/db/table/relation/log.go @@ -1,3 +1,17 @@ +// 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 relation import ( diff --git a/pkg/common/db/unrelation/mongo.go b/pkg/common/db/unrelation/mongo.go index 38a335567..2c1dc6f38 100644 --- a/pkg/common/db/unrelation/mongo.go +++ b/pkg/common/db/unrelation/mongo.go @@ -17,11 +17,11 @@ package unrelation import ( "context" "fmt" + "os" "strings" "time" "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" @@ -34,7 +34,8 @@ import ( ) const ( - maxRetry = 10 // number of retries + maxRetry = 10 // number of retries + mongoConnTimeout = 10 * time.Second ) type Mongo struct { @@ -44,90 +45,122 @@ type Mongo struct { // NewMongo Initialize MongoDB connection. func NewMongo() (*Mongo, error) { specialerror.AddReplace(mongo.ErrNoDocuments, errs.ErrRecordNotFound) - uri := "mongodb://sample.host:27017/?maxPoolSize=20&w=majority" - if config.Config.Mongo.Uri != "" { - uri = config.Config.Mongo.Uri - } else { - mongodbHosts := "" - for i, v := range config.Config.Mongo.Address { - if i == len(config.Config.Mongo.Address)-1 { - mongodbHosts += v - } else { - mongodbHosts += v + "," - } - } - if config.Config.Mongo.Password != "" && config.Config.Mongo.Username != "" { - uri = fmt.Sprintf("mongodb://%s:%s@%s/%s?maxPoolSize=%d&authSource=admin", - config.Config.Mongo.Username, config.Config.Mongo.Password, mongodbHosts, - config.Config.Mongo.Database, config.Config.Mongo.MaxPoolSize) - } else { - uri = fmt.Sprintf("mongodb://%s/%s/?maxPoolSize=%d&authSource=admin", - mongodbHosts, config.Config.Mongo.Database, - config.Config.Mongo.MaxPoolSize) - } - } - fmt.Println("mongo:", uri) + uri := buildMongoURI() + var mongoClient *mongo.Client - var err error = nil + var err error + + // Retry connecting to MongoDB for i := 0; i <= maxRetry; i++ { - ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) + ctx, cancel := context.WithTimeout(context.Background(), mongoConnTimeout) defer cancel() mongoClient, err = mongo.Connect(ctx, options.Client().ApplyURI(uri)) if err == nil { return &Mongo{db: mongoClient}, nil } - if cmdErr, ok := err.(mongo.CommandError); ok { - if cmdErr.Code == 13 || cmdErr.Code == 18 { - return nil, err - } else { - fmt.Printf("Failed to connect to MongoDB: %s\n", err) - } + if shouldRetry(err) { + fmt.Printf("Failed to connect to MongoDB, retrying: %s\n", err) + time.Sleep(time.Second) // exponential backoff could be implemented here + continue } + return nil, err } return nil, err } +func buildMongoURI() string { + uri := os.Getenv("MONGO_URI") + if uri != "" { + return uri + } + + username := os.Getenv("MONGO_USERNAME") + password := os.Getenv("MONGO_PASSWORD") + address := os.Getenv("MONGO_ADDRESS") + port := os.Getenv("MONGO_PORT") + database := os.Getenv("MONGO_DATABASE") + maxPoolSize := os.Getenv("MONGO_MAX_POOL_SIZE") + + if username == "" { + username = config.Config.Mongo.Username + } + if password == "" { + password = config.Config.Mongo.Password + } + if address == "" { + address = strings.Join(config.Config.Mongo.Address, ",") + } else if port != "" { + address = fmt.Sprintf("%s:%s", address, port) + } + if database == "" { + database = config.Config.Mongo.Database + } + if maxPoolSize == "" { + maxPoolSize = fmt.Sprint(config.Config.Mongo.MaxPoolSize) + } + + uriFormat := "mongodb://%s/%s?maxPoolSize=%s&authSource=admin" + if username != "" && password != "" { + uriFormat = "mongodb://%s:%s@%s/%s?maxPoolSize=%s&authSource=admin" + return fmt.Sprintf(uriFormat, username, password, address, database, maxPoolSize) + } + return fmt.Sprintf(uriFormat, address, database, maxPoolSize) +} + +func shouldRetry(err error) bool { + if cmdErr, ok := err.(mongo.CommandError); ok { + return cmdErr.Code != 13 && cmdErr.Code != 18 + } + return true +} + +// GetClient returns the MongoDB client. func (m *Mongo) GetClient() *mongo.Client { return m.db } +// GetDatabase returns the specific database from MongoDB. func (m *Mongo) GetDatabase() *mongo.Database { return m.db.Database(config.Config.Mongo.Database) } +// CreateMsgIndex creates an index for messages in MongoDB. func (m *Mongo) CreateMsgIndex() error { return m.createMongoIndex(unrelation.Msg, true, "doc_id") } +// createMongoIndex creates an index in a MongoDB collection. func (m *Mongo) createMongoIndex(collection string, isUnique bool, keys ...string) error { - db := m.db.Database(config.Config.Mongo.Database).Collection(collection) + db := m.GetDatabase().Collection(collection) opts := options.CreateIndexes().SetMaxTime(10 * time.Second) indexView := db.Indexes() - keysDoc := bson.D{} - // create composite indexes - for _, key := range keys { - if strings.HasPrefix(key, "-") { - keysDoc = append(keysDoc, bson.E{Key: strings.TrimLeft(key, "-"), Value: -1}) - // keysDoc = keysDoc.Append(strings.TrimLeft(key, "-"), bsonx.Int32(-1)) - } else { - keysDoc = append(keysDoc, bson.E{Key: key, Value: 1}) - // keysDoc = keysDoc.Append(key, bsonx.Int32(1)) - } - } - // create index + + keysDoc := buildIndexKeys(keys) + index := mongo.IndexModel{ Keys: keysDoc, } if isUnique { index.Options = options.Index().SetUnique(true) } - result, err := indexView.CreateOne( - context.Background(), - index, - opts, - ) + + _, err := indexView.CreateOne(context.Background(), index, opts) if err != nil { - return utils.Wrap(err, result) + return utils.Wrap(err, "CreateIndex") } return nil } + +// buildIndexKeys builds the BSON document for index keys. +func buildIndexKeys(keys []string) bson.D { + keysDoc := bson.D{} + for _, key := range keys { + direction := 1 // default direction is ascending + if strings.HasPrefix(key, "-") { + direction = -1 // descending order for prefixed with "-" + key = strings.TrimLeft(key, "-") + } + keysDoc = append(keysDoc, bson.E{Key: key, Value: direction}) + } + return keysDoc +} diff --git a/pkg/common/discoveryregister/discoveryregister.go b/pkg/common/discoveryregister/discoveryregister.go index 62c1f4a31..c14323027 100644 --- a/pkg/common/discoveryregister/discoveryregister.go +++ b/pkg/common/discoveryregister/discoveryregister.go @@ -1,159 +1,42 @@ +// 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 discoveryregister import ( - "context" "errors" - "fmt" "os" - "strconv" - "strings" - "time" - "github.com/OpenIMSDK/tools/discoveryregistry" - openkeeper "github.com/OpenIMSDK/tools/discoveryregistry/zookeeper" - "github.com/OpenIMSDK/tools/log" - "google.golang.org/grpc" + "github.com/openimsdk/open-im-server/v3/pkg/common/discoveryregister/kubernetes" + "github.com/openimsdk/open-im-server/v3/pkg/common/discoveryregister/zookeeper" - "github.com/openimsdk/open-im-server/v3/pkg/common/config" + "github.com/OpenIMSDK/tools/discoveryregistry" ) +// NewDiscoveryRegister creates a new service discovery and registry client based on the provided environment type. func NewDiscoveryRegister(envType string) (discoveryregistry.SvcDiscoveryRegistry, error) { - var client discoveryregistry.SvcDiscoveryRegistry - var err error + + if os.Getenv("ENVS_DISCOVERY") != "" { + envType = os.Getenv("ENVS_DISCOVERY") + } + switch envType { case "zookeeper": - client, err = openkeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema, - openkeeper.WithFreq(time.Hour), openkeeper.WithUserNameAndPassword( - config.Config.Zookeeper.Username, - config.Config.Zookeeper.Password, - ), openkeeper.WithRoundRobin(), openkeeper.WithTimeout(10), openkeeper.WithLogger(log.NewZkLogger())) + return zookeeper.NewZookeeperDiscoveryRegister() case "k8s": - client, err = NewK8sDiscoveryRegister() + return kubernetes.NewK8sDiscoveryRegister() default: - client = nil - err = errors.New("envType not correct") + return nil, errors.New("envType not correct") } - return client, err -} - -type K8sDR struct { - options []grpc.DialOption - rpcRegisterAddr string -} - -func NewK8sDiscoveryRegister() (discoveryregistry.SvcDiscoveryRegistry, error) { - return &K8sDR{}, nil -} - -func (cli *K8sDR) Register(serviceName, host string, port int, opts ...grpc.DialOption) error { - if serviceName != config.Config.RpcRegisterName.OpenImMessageGatewayName { - cli.rpcRegisterAddr = serviceName - } else { - cli.rpcRegisterAddr = cli.getSelfHost(context.Background()) - } - - return nil -} -func (cli *K8sDR) UnRegister() error { - - return nil -} -func (cli *K8sDR) CreateRpcRootNodes(serviceNames []string) error { - - return nil -} -func (cli *K8sDR) RegisterConf2Registry(key string, conf []byte) error { - - return nil -} - -func (cli *K8sDR) GetConfFromRegistry(key string) ([]byte, error) { - - return nil, nil -} -func (cli *K8sDR) getSelfHost(ctx context.Context) string { - port := 88 - instance := "openimserver" - selfPodName := os.Getenv("MY_POD_NAME") - ns := os.Getenv("MY_POD_NAMESPACE") - statefuleIndex := 0 - gatewayEnds := strings.Split(config.Config.RpcRegisterName.OpenImMessageGatewayName, ":") - if len(gatewayEnds) != 2 { - log.ZError(ctx, "msggateway RpcRegisterName is error:config.Config.RpcRegisterName.OpenImMessageGatewayName", errors.New("config error")) - } else { - port, _ = strconv.Atoi(gatewayEnds[1]) - } - podInfo := strings.Split(selfPodName, "-") - instance = podInfo[0] - count := len(podInfo) - statefuleIndex, _ = strconv.Atoi(podInfo[count-1]) - host := fmt.Sprintf("%s-openim-msggateway-%d.%s-openim-msggateway-headless.%s.svc.cluster.local:%d", instance, statefuleIndex, instance, ns, port) - return host -} - -// like openimserver-openim-msggateway-0.openimserver-openim-msggateway-headless.openim-lin.svc.cluster.local:88 -func (cli *K8sDR) getMsgGatewayHost(ctx context.Context) []string { - port := 88 - instance := "openimserver" - selfPodName := os.Getenv("MY_POD_NAME") - replicas := os.Getenv("MY_MSGGATEWAY_REPLICACOUNT") - ns := os.Getenv("MY_POD_NAMESPACE") - gatewayEnds := strings.Split(config.Config.RpcRegisterName.OpenImMessageGatewayName, ":") - if len(gatewayEnds) != 2 { - log.ZError(ctx, "msggateway RpcRegisterName is error:config.Config.RpcRegisterName.OpenImMessageGatewayName", errors.New("config error")) - } else { - port, _ = strconv.Atoi(gatewayEnds[1]) - } - nReplicas, _ := strconv.Atoi(replicas) - podInfo := strings.Split(selfPodName, "-") - instance = podInfo[0] - var ret []string - for i := 0; i < nReplicas; i++ { - host := fmt.Sprintf("%s-openim-msggateway-%d.%s-openim-msggateway-headless.%s.svc.cluster.local:%d", instance, i, instance, ns, port) - ret = append(ret, host) - } - log.ZInfo(ctx, "getMsgGatewayHost", "instance", instance, "selfPodName", selfPodName, "replicas", replicas, "ns", ns, "ret", ret) - return ret -} -func (cli *K8sDR) GetConns(ctx context.Context, serviceName string, opts ...grpc.DialOption) ([]*grpc.ClientConn, error) { - - if serviceName != config.Config.RpcRegisterName.OpenImMessageGatewayName { - conn, err := grpc.DialContext(ctx, serviceName, append(cli.options, opts...)...) - return []*grpc.ClientConn{conn}, err - } else { - var ret []*grpc.ClientConn - gatewayHosts := cli.getMsgGatewayHost(ctx) - for _, host := range gatewayHosts { - conn, err := grpc.DialContext(ctx, host, append(cli.options, opts...)...) - if err != nil { - return nil, err - } else { - ret = append(ret, conn) - } - } - return ret, nil - } -} -func (cli *K8sDR) GetConn(ctx context.Context, serviceName string, opts ...grpc.DialOption) (*grpc.ClientConn, error) { - - return grpc.DialContext(ctx, serviceName, append(cli.options, opts...)...) -} -func (cli *K8sDR) GetSelfConnTarget() string { - - return cli.rpcRegisterAddr -} -func (cli *K8sDR) AddOption(opts ...grpc.DialOption) { - cli.options = append(cli.options, opts...) -} -func (cli *K8sDR) CloseConn(conn *grpc.ClientConn) { - conn.Close() -} - -// do not use this method for call rpc -func (cli *K8sDR) GetClientLocalConns() map[string][]*grpc.ClientConn { - fmt.Println("should not call this function!!!!!!!!!!!!!!!!!!!!!!!!!") - return nil -} -func (cli *K8sDR) Close() { - return } diff --git a/pkg/common/discoveryregister/discoveryregister_test.go b/pkg/common/discoveryregister/discoveryregister_test.go index 8426598f9..d4a634b91 100644 --- a/pkg/common/discoveryregister/discoveryregister_test.go +++ b/pkg/common/discoveryregister/discoveryregister_test.go @@ -1,407 +1,59 @@ +// 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 discoveryregister import ( - "context" - "reflect" + "os" "testing" "github.com/OpenIMSDK/tools/discoveryregistry" - "google.golang.org/grpc" + "github.com/stretchr/testify/assert" ) -func TestNewDiscoveryRegister(t *testing.T) { - type args struct { - envType string - } - tests := []struct { - name string - args args - want discoveryregistry.SvcDiscoveryRegistry - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - got, err := NewDiscoveryRegister(tt.args.envType) - if (err != nil) != tt.wantErr { - t.Errorf("NewDiscoveryRegister() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("NewDiscoveryRegister() = %v, want %v", got, tt.want) - } - }) - } -} - -func TestNewK8sDiscoveryRegister(t *testing.T) { - tests := []struct { - name string - want discoveryregistry.SvcDiscoveryRegistry - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - got, err := NewK8sDiscoveryRegister() - if (err != nil) != tt.wantErr { - t.Errorf("NewK8sDiscoveryRegister() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("NewK8sDiscoveryRegister() = %v, want %v", got, tt.want) - } - }) - } -} - -func TestK8sDR_Register(t *testing.T) { - type fields struct { - options []grpc.DialOption - rpcRegisterAddr string - } - type args struct { - serviceName string - host string - port int - opts []grpc.DialOption - } - tests := []struct { - name string - fields fields - args args - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - cli := &K8sDR{ - options: tt.fields.options, - rpcRegisterAddr: tt.fields.rpcRegisterAddr, - } - if err := cli.Register(tt.args.serviceName, tt.args.host, tt.args.port, tt.args.opts...); (err != nil) != tt.wantErr { - t.Errorf("K8sDR.Register() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} - -func TestK8sDR_UnRegister(t *testing.T) { - type fields struct { - options []grpc.DialOption - rpcRegisterAddr string - } - tests := []struct { - name string - fields fields - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - cli := &K8sDR{ - options: tt.fields.options, - rpcRegisterAddr: tt.fields.rpcRegisterAddr, - } - if err := cli.UnRegister(); (err != nil) != tt.wantErr { - t.Errorf("K8sDR.UnRegister() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} - -func TestK8sDR_CreateRpcRootNodes(t *testing.T) { - type fields struct { - options []grpc.DialOption - rpcRegisterAddr string - } - type args struct { - serviceNames []string - } - tests := []struct { - name string - fields fields - args args - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - cli := &K8sDR{ - options: tt.fields.options, - rpcRegisterAddr: tt.fields.rpcRegisterAddr, - } - if err := cli.CreateRpcRootNodes(tt.args.serviceNames); (err != nil) != tt.wantErr { - t.Errorf("K8sDR.CreateRpcRootNodes() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} - -func TestK8sDR_RegisterConf2Registry(t *testing.T) { - type fields struct { - options []grpc.DialOption - rpcRegisterAddr string - } - type args struct { - key string - conf []byte - } - tests := []struct { - name string - fields fields - args args - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - cli := &K8sDR{ - options: tt.fields.options, - rpcRegisterAddr: tt.fields.rpcRegisterAddr, - } - if err := cli.RegisterConf2Registry(tt.args.key, tt.args.conf); (err != nil) != tt.wantErr { - t.Errorf("K8sDR.RegisterConf2Registry() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} - -func TestK8sDR_GetConfFromRegistry(t *testing.T) { - type fields struct { - options []grpc.DialOption - rpcRegisterAddr string - } - type args struct { - key string - } - tests := []struct { - name string - fields fields - args args - want []byte - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - cli := &K8sDR{ - options: tt.fields.options, - rpcRegisterAddr: tt.fields.rpcRegisterAddr, - } - got, err := cli.GetConfFromRegistry(tt.args.key) - if (err != nil) != tt.wantErr { - t.Errorf("K8sDR.GetConfFromRegistry() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("K8sDR.GetConfFromRegistry() = %v, want %v", got, tt.want) - } - }) - } -} - -func TestK8sDR_GetConns(t *testing.T) { - type fields struct { - options []grpc.DialOption - rpcRegisterAddr string - } - type args struct { - ctx context.Context - serviceName string - opts []grpc.DialOption - } - tests := []struct { - name string - fields fields - args args - want []*grpc.ClientConn - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - cli := &K8sDR{ - options: tt.fields.options, - rpcRegisterAddr: tt.fields.rpcRegisterAddr, - } - got, err := cli.GetConns(tt.args.ctx, tt.args.serviceName, tt.args.opts...) - if (err != nil) != tt.wantErr { - t.Errorf("K8sDR.GetConns() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("K8sDR.GetConns() = %v, want %v", got, tt.want) - } - }) - } -} - -func TestK8sDR_GetConn(t *testing.T) { - type fields struct { - options []grpc.DialOption - rpcRegisterAddr string - } - type args struct { - ctx context.Context - serviceName string - opts []grpc.DialOption - } - tests := []struct { - name string - fields fields - args args - want *grpc.ClientConn - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - cli := &K8sDR{ - options: tt.fields.options, - rpcRegisterAddr: tt.fields.rpcRegisterAddr, - } - got, err := cli.GetConn(tt.args.ctx, tt.args.serviceName, tt.args.opts...) - if (err != nil) != tt.wantErr { - t.Errorf("K8sDR.GetConn() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("K8sDR.GetConn() = %v, want %v", got, tt.want) - } - }) - } -} - -func TestK8sDR_GetSelfConnTarget(t *testing.T) { - type fields struct { - options []grpc.DialOption - rpcRegisterAddr string - } - tests := []struct { - name string - fields fields - want string - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - cli := &K8sDR{ - options: tt.fields.options, - rpcRegisterAddr: tt.fields.rpcRegisterAddr, - } - if got := cli.GetSelfConnTarget(); got != tt.want { - t.Errorf("K8sDR.GetSelfConnTarget() = %v, want %v", got, tt.want) - } - }) - } +func setupTestEnvironment() { + os.Setenv("ZOOKEEPER_SCHEMA", "openim") + os.Setenv("ZOOKEEPER_ADDRESS", "172.28.0.1:12181") + os.Setenv("ZOOKEEPER_USERNAME", "") + os.Setenv("ZOOKEEPER_PASSWORD", "") } -func TestK8sDR_AddOption(t *testing.T) { - type fields struct { - options []grpc.DialOption - rpcRegisterAddr string - } - type args struct { - opts []grpc.DialOption - } - tests := []struct { - name string - fields fields - args args - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - cli := &K8sDR{ - options: tt.fields.options, - rpcRegisterAddr: tt.fields.rpcRegisterAddr, - } - cli.AddOption(tt.args.opts...) - }) - } -} +func TestNewDiscoveryRegister(t *testing.T) { + setupTestEnvironment() -func TestK8sDR_CloseConn(t *testing.T) { - type fields struct { - options []grpc.DialOption - rpcRegisterAddr string - } - type args struct { - conn *grpc.ClientConn - } tests := []struct { - name string - fields fields - args args + envType string + expectedError bool + expectedResult bool }{ - // TODO: Add test cases. + {"zookeeper", false, true}, + {"k8s", false, true}, // 假设 k8s 配置也已正确设置 + {"invalid", true, false}, } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - cli := &K8sDR{ - options: tt.fields.options, - rpcRegisterAddr: tt.fields.rpcRegisterAddr, - } - cli.CloseConn(tt.args.conn) - }) - } -} -func TestK8sDR_GetClientLocalConns(t *testing.T) { - type fields struct { - options []grpc.DialOption - rpcRegisterAddr string - } - tests := []struct { - name string - fields fields - want map[string][]*grpc.ClientConn - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - cli := &K8sDR{ - options: tt.fields.options, - rpcRegisterAddr: tt.fields.rpcRegisterAddr, - } - if got := cli.GetClientLocalConns(); !reflect.DeepEqual(got, tt.want) { - t.Errorf("K8sDR.GetClientLocalConns() = %v, want %v", got, tt.want) - } - }) - } -} + for _, test := range tests { + client, err := NewDiscoveryRegister(test.envType) -func TestK8sDR_Close(t *testing.T) { - type fields struct { - options []grpc.DialOption - rpcRegisterAddr string - } - tests := []struct { - name string - fields fields - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - cli := &K8sDR{ - options: tt.fields.options, - rpcRegisterAddr: tt.fields.rpcRegisterAddr, + if test.expectedError { + assert.Error(t, err) + } else { + assert.NoError(t, err) + if test.expectedResult { + assert.Implements(t, (*discoveryregistry.SvcDiscoveryRegistry)(nil), client) + } else { + assert.Nil(t, client) } - cli.Close() - }) + } } } diff --git a/pkg/common/discoveryregister/kubernetes/kubernetes.go b/pkg/common/discoveryregister/kubernetes/kubernetes.go new file mode 100644 index 000000000..cd5fb0a36 --- /dev/null +++ b/pkg/common/discoveryregister/kubernetes/kubernetes.go @@ -0,0 +1,174 @@ +// 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 kubernetes + +import ( + "context" + "errors" + "fmt" + "os" + "strconv" + "strings" + + "google.golang.org/grpc" + + "github.com/OpenIMSDK/tools/discoveryregistry" + "github.com/OpenIMSDK/tools/log" + "github.com/openimsdk/open-im-server/v3/pkg/common/config" +) + +// K8sDR represents the Kubernetes service discovery and registration client. +type K8sDR struct { + options []grpc.DialOption + rpcRegisterAddr string +} + +// NewK8sDiscoveryRegister creates a new instance of K8sDR for Kubernetes service discovery and registration. +func NewK8sDiscoveryRegister() (discoveryregistry.SvcDiscoveryRegistry, error) { + + return &K8sDR{}, nil +} + +// Register registers a service with Kubernetes. +func (cli *K8sDR) Register(serviceName, host string, port int, opts ...grpc.DialOption) error { + if serviceName != config.Config.RpcRegisterName.OpenImMessageGatewayName { + cli.rpcRegisterAddr = serviceName + } else { + cli.rpcRegisterAddr = cli.getSelfHost(context.Background()) + } + + return nil +} + +// UnRegister removes a service registration from Kubernetes. +func (cli *K8sDR) UnRegister() error { + + return nil +} + +// CreateRpcRootNodes creates root nodes for RPC in Kubernetes. +func (cli *K8sDR) CreateRpcRootNodes(serviceNames []string) error { + + return nil +} + +// RegisterConf2Registry registers a configuration to the registry. +func (cli *K8sDR) RegisterConf2Registry(key string, conf []byte) error { + + return nil +} + +// GetConfFromRegistry retrieves a configuration from the registry. +func (cli *K8sDR) GetConfFromRegistry(key string) ([]byte, error) { + return nil, nil +} + +func (cli *K8sDR) getSelfHost(ctx context.Context) string { + port := 88 + instance := "openimserver" + selfPodName := os.Getenv("MY_POD_NAME") + ns := os.Getenv("MY_POD_NAMESPACE") + statefuleIndex := 0 + gatewayEnds := strings.Split(config.Config.RpcRegisterName.OpenImMessageGatewayName, ":") + if len(gatewayEnds) != 2 { + log.ZError(ctx, "msggateway RpcRegisterName is error:config.Config.RpcRegisterName.OpenImMessageGatewayName", errors.New("config error")) + } else { + port, _ = strconv.Atoi(gatewayEnds[1]) + } + podInfo := strings.Split(selfPodName, "-") + instance = podInfo[0] + count := len(podInfo) + statefuleIndex, _ = strconv.Atoi(podInfo[count-1]) + host := fmt.Sprintf("%s-openim-msggateway-%d.%s-openim-msggateway-headless.%s.svc.cluster.local:%d", instance, statefuleIndex, instance, ns, port) + return host +} + +// GetConns returns a list of gRPC client connections for a given service. +func (cli *K8sDR) GetConns(ctx context.Context, serviceName string, opts ...grpc.DialOption) ([]*grpc.ClientConn, error) { + if serviceName != config.Config.RpcRegisterName.OpenImMessageGatewayName { + conn, err := grpc.DialContext(ctx, serviceName, append(cli.options, opts...)...) + return []*grpc.ClientConn{conn}, err + } + var ret []*grpc.ClientConn + gatewayHosts := cli.getMsgGatewayHost(ctx) + for _, host := range gatewayHosts { + conn, err := grpc.DialContext(ctx, host, append(cli.options, opts...)...) + if err != nil { + return nil, err + } + ret = append(ret, conn) + } + return ret, nil +} + +// like openimserver-openim-msggateway-0.openimserver-openim-msggateway-headless.openim-lin.svc.cluster.local:88 +func (cli *K8sDR) getMsgGatewayHost(ctx context.Context) []string { + port := 88 + instance := "openimserver" + selfPodName := os.Getenv("MY_POD_NAME") + replicas := os.Getenv("MY_MSGGATEWAY_REPLICACOUNT") + ns := os.Getenv("MY_POD_NAMESPACE") + gatewayEnds := strings.Split(config.Config.RpcRegisterName.OpenImMessageGatewayName, ":") + if len(gatewayEnds) != 2 { + log.ZError(ctx, "msggateway RpcRegisterName is error:config.Config.RpcRegisterName.OpenImMessageGatewayName", errors.New("config error")) + } else { + port, _ = strconv.Atoi(gatewayEnds[1]) + } + nReplicas, _ := strconv.Atoi(replicas) + podInfo := strings.Split(selfPodName, "-") + instance = podInfo[0] + var ret []string + for i := 0; i < nReplicas; i++ { + host := fmt.Sprintf("%s-openim-msggateway-%d.%s-openim-msggateway-headless.%s.svc.cluster.local:%d", instance, i, instance, ns, port) + ret = append(ret, host) + } + log.ZInfo(ctx, "getMsgGatewayHost", "instance", instance, "selfPodName", selfPodName, "replicas", replicas, "ns", ns, "ret", ret) + + return ret +} + +// GetConn returns a single gRPC client connection for a given service. +func (cli *K8sDR) GetConn(ctx context.Context, serviceName string, opts ...grpc.DialOption) (*grpc.ClientConn, error) { + return grpc.DialContext(ctx, serviceName, append(cli.options, opts...)...) +} + +// GetSelfConnTarget returns the connection target of the client itself. +func (cli *K8sDR) GetSelfConnTarget() string { + return cli.rpcRegisterAddr +} + +// AddOption adds gRPC dial options to the client. +func (cli *K8sDR) AddOption(opts ...grpc.DialOption) { + cli.options = append(cli.options, opts...) +} + +// CloseConn closes a given gRPC client connection. +func (cli *K8sDR) CloseConn(conn *grpc.ClientConn) { + conn.Close() +} + +// do not use this method for call rpc. +func (cli *K8sDR) GetClientLocalConns() map[string][]*grpc.ClientConn { + fmt.Println("should not call this function!!!!!!!!!!!!!!!!!!!!!!!!!") + + return nil +} + +// Close closes the K8sDR client. +func (cli *K8sDR) Close() { + + // Close any open resources here (if applicable) + return +} diff --git a/pkg/common/discoveryregister/zookeeper/zookeeper.go b/pkg/common/discoveryregister/zookeeper/zookeeper.go new file mode 100644 index 000000000..a4edffc43 --- /dev/null +++ b/pkg/common/discoveryregister/zookeeper/zookeeper.go @@ -0,0 +1,61 @@ +// 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 zookeeper + +import ( + "os" + "strings" + "time" + + "github.com/OpenIMSDK/tools/discoveryregistry" + openkeeper "github.com/OpenIMSDK/tools/discoveryregistry/zookeeper" + "github.com/OpenIMSDK/tools/log" + + "github.com/openimsdk/open-im-server/v3/pkg/common/config" +) + +// NewZookeeperDiscoveryRegister creates a new instance of ZookeeperDR for Zookeeper service discovery and registration. +func NewZookeeperDiscoveryRegister() (discoveryregistry.SvcDiscoveryRegistry, error) { + schema := getEnv("ZOOKEEPER_SCHEMA", config.Config.Zookeeper.Schema) + zkAddr := getZkAddrFromEnv(config.Config.Zookeeper.ZkAddr) + username := getEnv("ZOOKEEPER_USERNAME", config.Config.Zookeeper.Username) + password := getEnv("ZOOKEEPER_PASSWORD", config.Config.Zookeeper.Password) + + return openkeeper.NewClient( + zkAddr, + schema, + openkeeper.WithFreq(time.Hour), + openkeeper.WithUserNameAndPassword(username, password), + openkeeper.WithRoundRobin(), + openkeeper.WithTimeout(10), + openkeeper.WithLogger(log.NewZkLogger()), + ) +} + +// getEnv returns the value of an environment variable if it exists, otherwise it returns the fallback value. +func getEnv(key, fallback string) string { + if value, exists := os.LookupEnv(key); exists { + return value + } + return fallback +} + +// getZkAddrFromEnv returns the value of an environment variable if it exists, otherwise it returns the fallback value. +func getZkAddrFromEnv(fallback []string) []string { + if value, exists := os.LookupEnv("ZOOKEEPER_ADDRESS"); exists { + return strings.Split(value, ",") + } + return fallback +} diff --git a/pkg/common/ginprometheus/ginprometheus.go b/pkg/common/ginprometheus/ginprometheus.go index a325595d6..f116fc23a 100644 --- a/pkg/common/ginprometheus/ginprometheus.go +++ b/pkg/common/ginprometheus/ginprometheus.go @@ -1,3 +1,17 @@ +// 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 ginprometheus import ( diff --git a/pkg/common/kafka/producer.go b/pkg/common/kafka/producer.go index 1dad33f9c..9a06809b7 100644 --- a/pkg/common/kafka/producer.go +++ b/pkg/common/kafka/producer.go @@ -21,19 +21,18 @@ import ( "strings" "time" + "github.com/IBM/sarama" "github.com/OpenIMSDK/protocol/constant" - log "github.com/OpenIMSDK/tools/log" + "github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/mcontext" "github.com/OpenIMSDK/tools/utils" + "google.golang.org/protobuf/proto" "github.com/openimsdk/open-im-server/v3/pkg/common/config" - - "github.com/IBM/sarama" - "google.golang.org/protobuf/proto" ) const ( - maxRetry = 10 // number of retries + maxRetry = 10 // Maximum number of retries for producer creation ) var errEmptyMsg = errors.New("binary msg is empty") @@ -45,62 +44,85 @@ type Producer struct { producer sarama.SyncProducer } -// NewKafkaProducer Initialize kafka producer. +// NewKafkaProducer initializes a new Kafka producer. func NewKafkaProducer(addr []string, topic string) *Producer { - p := Producer{} - p.config = sarama.NewConfig() // Instantiate a sarama Config - p.config.Producer.Return.Successes = true // Whether to enable the successes channel to be notified after the message is sent successfully + p := Producer{ + addr: addr, + topic: topic, + config: sarama.NewConfig(), + } + + // Set producer return flags + p.config.Producer.Return.Successes = true p.config.Producer.Return.Errors = true - p.config.Producer.Partitioner = sarama.NewHashPartitioner // Set the hash-key automatic hash partition. When sending a message, you must specify the key value of the message. If there is no key, the partition will be selected randomly - var producerAck = sarama.WaitForAll // default: WaitForAll - switch strings.ToLower(config.Config.Kafka.ProducerAck) { - case "no_response": - producerAck = sarama.NoResponse - case "wait_for_local": - producerAck = sarama.WaitForLocal - case "wait_for_all": - producerAck = sarama.WaitForAll - } - p.config.Producer.RequiredAcks = producerAck + // Set partitioner strategy + p.config.Producer.Partitioner = sarama.NewHashPartitioner - var compress = sarama.CompressionNone // default: no compress - _ = compress.UnmarshalText(bytes.ToLower([]byte(config.Config.Kafka.CompressType))) - p.config.Producer.Compression = compress + // Configure producer acknowledgement level + configureProducerAck(&p, config.Config.Kafka.ProducerAck) + + // Configure message compression + configureCompression(&p, config.Config.Kafka.CompressType) + + // Get Kafka configuration from environment variables or fallback to config file + kafkaUsername := getEnvOrConfig("KAFKA_USERNAME", config.Config.Kafka.Username) + kafkaPassword := getEnvOrConfig("KAFKA_PASSWORD", config.Config.Kafka.Password) + kafkaAddr := getEnvOrConfig("KAFKA_ADDRESS", addr[0]) // Assuming addr[0] contains address from config - if config.Config.Kafka.Username != "" && config.Config.Kafka.Password != "" { + // Configure SASL authentication if credentials are provided + if kafkaUsername != "" && kafkaPassword != "" { p.config.Net.SASL.Enable = true - p.config.Net.SASL.User = config.Config.Kafka.Username - p.config.Net.SASL.Password = config.Config.Kafka.Password + p.config.Net.SASL.User = kafkaUsername + p.config.Net.SASL.Password = kafkaPassword } - p.addr = addr - p.topic = topic + + // Set the Kafka address + p.addr = []string{kafkaAddr} + + // Set up TLS configuration (if required) SetupTLSConfig(p.config) - var producer sarama.SyncProducer + + // Create the producer with retries var err error for i := 0; i <= maxRetry; i++ { - producer, err = sarama.NewSyncProducer(p.addr, p.config) // Initialize the client + p.producer, err = sarama.NewSyncProducer(p.addr, p.config) if err == nil { - p.producer = producer return &p } - //TODO If the password is wrong, exit directly - //if packetErr, ok := err.(*sarama.PacketEncodingError); ok { - //if _, ok := packetErr.Err.(sarama.AuthenticationError); ok { - // fmt.Println("Kafka password is wrong.") - //} - //} else { - // fmt.Printf("Failed to create Kafka producer: %v\n", err) - //} - time.Sleep(time.Duration(1) * time.Second) + time.Sleep(1 * time.Second) // Wait before retrying } + + // Panic if unable to create producer after retries if err != nil { - panic(err.Error()) + panic("Failed to create Kafka producer: " + err.Error()) } - p.producer = producer + return &p } +// configureProducerAck configures the producer's acknowledgement level. +func configureProducerAck(p *Producer, ackConfig string) { + switch strings.ToLower(ackConfig) { + case "no_response": + p.config.Producer.RequiredAcks = sarama.NoResponse + case "wait_for_local": + p.config.Producer.RequiredAcks = sarama.WaitForLocal + case "wait_for_all": + p.config.Producer.RequiredAcks = sarama.WaitForAll + default: + p.config.Producer.RequiredAcks = sarama.WaitForAll + } +} + +// configureCompression configures the message compression type for the producer. +func configureCompression(p *Producer, compressType string) { + var compress sarama.CompressionCodec = sarama.CompressionNone + compress.UnmarshalText(bytes.ToLower([]byte(compressType))) + p.config.Producer.Compression = compress +} + +// GetMQHeaderWithContext extracts message queue headers from the context. func GetMQHeaderWithContext(ctx context.Context) ([]sarama.RecordHeader, error) { operationID, opUserID, platform, connID, err := mcontext.GetCtxInfos(ctx) if err != nil { @@ -111,22 +133,23 @@ func GetMQHeaderWithContext(ctx context.Context) ([]sarama.RecordHeader, error) {Key: []byte(constant.OpUserID), Value: []byte(opUserID)}, {Key: []byte(constant.OpUserPlatform), Value: []byte(platform)}, {Key: []byte(constant.ConnID), Value: []byte(connID)}, - }, err + }, nil } +// GetContextWithMQHeader creates a context from message queue headers. func GetContextWithMQHeader(header []*sarama.RecordHeader) context.Context { var values []string for _, recordHeader := range header { values = append(values, string(recordHeader.Value)) } - return mcontext.WithMustInfoCtx(values) // TODO + return mcontext.WithMustInfoCtx(values) // Attach extracted values to context } +// SendMessage sends a message to the Kafka topic configured in the Producer. func (p *Producer) SendMessage(ctx context.Context, key string, msg proto.Message) (int32, int64, error) { log.ZDebug(ctx, "SendMessage", "msg", msg, "topic", p.topic, "key", key) - kMsg := &sarama.ProducerMessage{} - kMsg.Topic = p.topic - kMsg.Key = sarama.StringEncoder(key) + + // Marshal the protobuf message bMsg, err := proto.Marshal(msg) if err != nil { return 0, 0, utils.Wrap(err, "kafka proto Marshal err") @@ -134,20 +157,33 @@ func (p *Producer) SendMessage(ctx context.Context, key string, msg proto.Messag if len(bMsg) == 0 { return 0, 0, utils.Wrap(errEmptyMsg, "") } - kMsg.Value = sarama.ByteEncoder(bMsg) + + // Prepare Kafka message + kMsg := &sarama.ProducerMessage{ + Topic: p.topic, + Key: sarama.StringEncoder(key), + Value: sarama.ByteEncoder(bMsg), + } + + // Validate message key and value if kMsg.Key.Length() == 0 || kMsg.Value.Length() == 0 { return 0, 0, utils.Wrap(errEmptyMsg, "") } - kMsg.Metadata = ctx + + // Attach context metadata as headers header, err := GetMQHeaderWithContext(ctx) if err != nil { return 0, 0, utils.Wrap(err, "") } kMsg.Headers = header + + // Send the message partition, offset, err := p.producer.SendMessage(kMsg) - log.ZDebug(ctx, "ByteEncoder SendMessage end", "key ", kMsg.Key, "key length", kMsg.Value.Length()) if err != nil { log.ZWarn(ctx, "p.producer.SendMessage error", err) + return 0, 0, utils.Wrap(err, "") } - return partition, offset, utils.Wrap(err, "") + + log.ZDebug(ctx, "ByteEncoder SendMessage end", "key", kMsg.Key, "key length", kMsg.Value.Length()) + return partition, offset, nil } diff --git a/pkg/common/kafka/util.go b/pkg/common/kafka/util.go index 722205865..da0c5349b 100644 --- a/pkg/common/kafka/util.go +++ b/pkg/common/kafka/util.go @@ -15,6 +15,8 @@ package kafka import ( + "os" + "github.com/IBM/sarama" "github.com/openimsdk/open-im-server/v3/pkg/common/config" @@ -33,3 +35,12 @@ func SetupTLSConfig(cfg *sarama.Config) { ) } } + +// getEnvOrConfig returns the value of the environment variable if it exists, +// otherwise, it returns the value from the configuration file. +func getEnvOrConfig(envName string, configValue string) string { + if value, exists := os.LookupEnv(envName); exists { + return value + } + return configValue +} diff --git a/pkg/common/prommetrics/gin_api.go b/pkg/common/prommetrics/gin_api.go index 7cd82dad2..c5ef612a2 100644 --- a/pkg/common/prommetrics/gin_api.go +++ b/pkg/common/prommetrics/gin_api.go @@ -1,10 +1,24 @@ +// 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 prommetrics import ginProm "github.com/openimsdk/open-im-server/v3/pkg/common/ginprometheus" /* labels := prometheus.Labels{"label_one": "any", "label_two": "value"} -ApiCustomCnt.MetricCollector.(*prometheus.CounterVec).With(labels).Inc() +ApiCustomCnt.MetricCollector.(*prometheus.CounterVec).With(labels).Inc(). */ var ( ApiCustomCnt = &ginProm.Metric{ diff --git a/pkg/common/prommetrics/grpc_auth.go b/pkg/common/prommetrics/grpc_auth.go index e44c146be..30dd5f1b1 100644 --- a/pkg/common/prommetrics/grpc_auth.go +++ b/pkg/common/prommetrics/grpc_auth.go @@ -1,3 +1,17 @@ +// 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 prommetrics import ( diff --git a/pkg/common/prommetrics/grpc_msg.go b/pkg/common/prommetrics/grpc_msg.go index 88d4ef3ce..758879b90 100644 --- a/pkg/common/prommetrics/grpc_msg.go +++ b/pkg/common/prommetrics/grpc_msg.go @@ -1,3 +1,17 @@ +// 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 prommetrics import ( diff --git a/pkg/common/prommetrics/grpc_msggateway.go b/pkg/common/prommetrics/grpc_msggateway.go index bb62426e1..98d5a3267 100644 --- a/pkg/common/prommetrics/grpc_msggateway.go +++ b/pkg/common/prommetrics/grpc_msggateway.go @@ -1,3 +1,17 @@ +// 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 prommetrics import ( diff --git a/pkg/common/prommetrics/grpc_push.go b/pkg/common/prommetrics/grpc_push.go index aa5085c2c..0b6c3e76f 100644 --- a/pkg/common/prommetrics/grpc_push.go +++ b/pkg/common/prommetrics/grpc_push.go @@ -1,3 +1,17 @@ +// 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 prommetrics import ( diff --git a/pkg/common/prommetrics/prommetrics.go b/pkg/common/prommetrics/prommetrics.go index 26b02b16f..41719dd2d 100644 --- a/pkg/common/prommetrics/prommetrics.go +++ b/pkg/common/prommetrics/prommetrics.go @@ -1,3 +1,17 @@ +// 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 prommetrics import ( diff --git a/pkg/common/prommetrics/prommetrics_test.go b/pkg/common/prommetrics/prommetrics_test.go index babc5e410..1e48c63ba 100644 --- a/pkg/common/prommetrics/prommetrics_test.go +++ b/pkg/common/prommetrics/prommetrics_test.go @@ -1,3 +1,17 @@ +// 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 prommetrics import ( diff --git a/pkg/common/prommetrics/transfer.go b/pkg/common/prommetrics/transfer.go index 6b03870b5..197b6f7fc 100644 --- a/pkg/common/prommetrics/transfer.go +++ b/pkg/common/prommetrics/transfer.go @@ -1,3 +1,17 @@ +// 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 prommetrics import ( diff --git a/pkg/common/startrpc/start_test.go b/pkg/common/startrpc/start_test.go index 171cdb1c2..481986e15 100644 --- a/pkg/common/startrpc/start_test.go +++ b/pkg/common/startrpc/start_test.go @@ -1,3 +1,17 @@ +// 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 startrpc import ( diff --git a/pkg/common/version/base.go b/pkg/common/version/base.go index ac214269f..9a656e03a 100644 --- a/pkg/common/version/base.go +++ b/pkg/common/version/base.go @@ -1,3 +1,17 @@ +// 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 version // Base version information. @@ -15,7 +29,7 @@ package version // When releasing a new Kubernetes version, this file is updated by // build/mark_new_version.sh to reflect the new version, and then a // git annotated tag (using format vX.Y where X == Major version and Y -// == Minor version) is created to point to the commit that updates +// == Minor version) is created to point to the commit that updates. var ( // TODO: Deprecate gitMajor and gitMinor, use only gitVersion // instead. First step in deprecation, keep the fields but make diff --git a/pkg/common/version/types.go b/pkg/common/version/types.go index ee4664149..da9c1ed90 100644 --- a/pkg/common/version/types.go +++ b/pkg/common/version/types.go @@ -1,3 +1,17 @@ +// 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 version // Info contains versioning information. diff --git a/pkg/common/version/version.go b/pkg/common/version/version.go index b8ccfaf81..3b271b3f6 100644 --- a/pkg/common/version/version.go +++ b/pkg/common/version/version.go @@ -1,3 +1,17 @@ +// 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 version import ( @@ -25,7 +39,7 @@ func Get() Info { } } -// GetClientVersion returns the git version of the OpenIM client repository +// GetClientVersion returns the git version of the OpenIM client repository. func GetClientVersion() (*OpenIMClientVersion, error) { clientVersion, err := getClientVersion() if err != nil { @@ -52,7 +66,7 @@ func getClientVersion() (string, error) { return ref.Hash().String(), nil } -// GetSingleVersion returns single version of sealer +// GetSingleVersion returns single version of sealer. func GetSingleVersion() string { return gitVersion } diff --git a/pkg/rpcclient/grouphash/grouphash.go b/pkg/rpcclient/grouphash/grouphash.go index b5570dccd..dee47ad44 100644 --- a/pkg/rpcclient/grouphash/grouphash.go +++ b/pkg/rpcclient/grouphash/grouphash.go @@ -1,3 +1,17 @@ +// 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 grouphash import ( diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 5acae3498..30a4e422b 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -33,8 +33,8 @@ openim::log::info "\n# Begin to check all openim service" # OpenIM status # Elegant printing function print_services_and_ports() { - local -n service_names=$1 - local -n service_ports=$2 + declare -g service_names=("${!1}") + declare -g service_ports=("${!2}") echo "+-------------------------+----------+" echo "| Service Name | Port |" diff --git a/scripts/githooks/pre-push.sh b/scripts/githooks/pre-push.sh index 2985313b7..e341cf4f2 100644 --- a/scripts/githooks/pre-push.sh +++ b/scripts/githooks/pre-push.sh @@ -102,7 +102,7 @@ print_color "Deleted Files: ${deleted_files}" "${BACKGROUND_GREEN}" if [[ ! $local_branch =~ $valid_branch_regex ]] then printError "There is something wrong with your branch name. Branch names in this project must adhere to this contract: $valid_branch_regex. -Your commit will be rejected. You should rename your branch to a valid name(feat/name OR bug/name) and try again." +Your commit will be rejected. You should rename your branch to a valid name(feat/name OR fix/name) and try again." printError "For more on this, read on: https://gist.github.com/cubxxw/126b72104ac0b0ca484c9db09c3e5694" exit 1 fi diff --git a/scripts/init-config.sh b/scripts/init-config.sh index 0b9c0e615..c75fc5502 100755 --- a/scripts/init-config.sh +++ b/scripts/init-config.sh @@ -1,4 +1,17 @@ #!/usr/bin/env bash +# 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. # This script automatically initializes various configuration files and can generate example files. @@ -31,6 +44,20 @@ declare -A EXAMPLES=( ["${OPENIM_ROOT}/deployments/templates/alertmanager.yml"]="${OPENIM_ROOT}/config/templates/alertmanager.yml.template" ) +# Templates for config Copy file +declare -A COPY_TEMPLATES=( + ["${OPENIM_ROOT}/deployments/templates/email.tmpl"]="${OPENIM_ROOT}/config/email.tmpl" + ["${OPENIM_ROOT}/deployments/templates/instance-down-rules.yml"]="${OPENIM_ROOT}/config/instance-down-rules.yml" + ["${OPENIM_ROOT}/deployments/templates/notification.yaml"]="${OPENIM_ROOT}/config/notification.yaml" +) + +# Templates for config Copy file +declare -A COPY_EXAMPLES=( + ["${OPENIM_ROOT}/deployments/templates/email.tmpl"]="${OPENIM_ROOT}/config/templates/email.tmpl.template" + ["${OPENIM_ROOT}/deployments/templates/instance-down-rules.yml"]="${OPENIM_ROOT}/config/templates/instance-down-rules.yml.template" + ["${OPENIM_ROOT}/deployments/templates/notification.yaml"]="${OPENIM_ROOT}/config/templates/notification.yaml.template" +) + # Command-line options FORCE_OVERWRITE=false SKIP_EXISTING=false @@ -50,84 +77,101 @@ show_help() { echo " --clean-examples Clean all example files" } -# Function to generate configuration files +# Function to generate and copy configuration files generate_config_files() { + # Handle TEMPLATES array for template in "${!TEMPLATES[@]}"; do local output_file="${TEMPLATES[$template]}" - if [[ -f "${output_file}" ]]; then - if [[ "${FORCE_OVERWRITE}" == true ]]; then - openim::log::info "Force overwriting ${output_file}." - elif [[ "${SKIP_EXISTING}" == true ]]; then - openim::log::info "Skipping generation of ${output_file} as it already exists." - continue - else - echo -n "File ${output_file} already exists. Overwrite? (Y/N): " - read -r -n 1 REPLY - echo - if [[ ! $REPLY =~ ^[Yy]$ ]]; then - openim::log::info "Skipping generation of ${output_file}." - continue - fi - fi - else - if [[ "${SKIP_EXISTING}" == true ]]; then - openim::log::info "Generating ${output_file} as it does not exist." - fi - fi + process_file "$template" "$output_file" true + done - openim::log::info "⌚ Working with template file: ${template} to generate ${output_file}..." - if [[ ! -f "${OPENIM_ROOT}/scripts/genconfig.sh" ]]; then - openim::log::error "genconfig.sh script not found" - exit 1 - fi - "${OPENIM_ROOT}/scripts/genconfig.sh" "${ENV_FILE}" "${template}" > "${output_file}" || { - openim::log::error "Error processing template file ${template}" - exit 1 - } - sleep 0.5 + # Handle COPY_TEMPLATES array + for template in "${!COPY_TEMPLATES[@]}"; do + local output_file="${COPY_TEMPLATES[$template]}" + process_file "$template" "$output_file" false done } # Function to generate example files generate_example_files() { + env_cmd="env -i" + for var in "${!env_vars[@]}"; do + env_cmd+=" $var='${env_vars[$var]}'" + done + + # Processing EXAMPLES array for template in "${!EXAMPLES[@]}"; do local example_file="${EXAMPLES[$template]}" - if [[ -f "${example_file}" ]]; then - if [[ "${FORCE_OVERWRITE}" == true ]]; then - openim::log::info "Force overwriting example file: ${example_file}." - elif [[ "${SKIP_EXISTING}" == true ]]; then - openim::log::info "Skipping generation of example file: ${example_file} as it already exists." - continue - else - echo -n "Example file ${example_file} already exists. Overwrite? (Y/N): " - read -r -n 1 REPLY - echo - if [[ ! $REPLY =~ ^[Yy]$ ]]; then - openim::log::info "Skipping generation of example file: ${example_file}." - continue - fi - fi + process_file "$template" "$example_file" true + done + + # Processing COPY_EXAMPLES array + for template in "${!COPY_EXAMPLES[@]}"; do + local example_file="${COPY_EXAMPLES[$template]}" + process_file "$template" "$example_file" false + done + +} + +# Function to process a single file, either by generating or copying +process_file() { + local template=$1 + local output_file=$2 + local use_genconfig=$3 + + if [[ -f "${output_file}" ]]; then + if [[ "${FORCE_OVERWRITE}" == true ]]; then + openim::log::info "Force overwriting ${output_file}." elif [[ "${SKIP_EXISTING}" == true ]]; then - openim::log::info "Generating example file: ${example_file} as it does not exist." + openim::log::info "Skipping generation of ${output_file} as it already exists." + return + else + echo -n "File ${output_file} already exists. Overwrite? (Y/N): " + read -r -n 1 REPLY + echo + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + openim::log::info "Skipping generation of ${output_file}." + return + fi + fi + else + if [[ "${SKIP_EXISTING}" == true ]]; then + openim::log::info "Generating ${output_file} as it does not exist." fi + fi - openim::log::info "⌚ Working with template file: ${template} to generate example file: ${example_file}..." + if [[ "$use_genconfig" == true ]]; then + openim::log::info "⌚ Working with template file: ${template} to generate ${output_file}..." if [[ ! -f "${OPENIM_ROOT}/scripts/genconfig.sh" ]]; then openim::log::error "genconfig.sh script not found" exit 1 fi - "${OPENIM_ROOT}/scripts/genconfig.sh" "${ENV_FILE}" "${template}" > "${example_file}" || { - openim::log::error "Error processing template file ${template}" + if [[ -n "${env_cmd}" ]]; then + eval "$env_cmd ${OPENIM_ROOT}/scripts/genconfig.sh '${ENV_FILE}' '${template}' > '${output_file}'" || { + openim::log::error "Error processing template file ${template}" + exit 1 + } + else + "${OPENIM_ROOT}/scripts/genconfig.sh" "${ENV_FILE}" "${template}" > "${output_file}" || { + openim::log::error "Error processing template file ${template}" + exit 1 + } + fi + else + openim::log::info "📋 Copying ${template} to ${output_file}..." + cp "${template}" "${output_file}" || { + openim::log::error "Error copying template file ${template}" exit 1 } - sleep 0.5 - done -} + fi + sleep 0.5 +} -# Function to clean configuration files clean_config_files() { - for output_file in "${TEMPLATES[@]}"; do + local all_templates=("${TEMPLATES[@]}" "${COPY_TEMPLATES[@]}") + + for output_file in "${all_templates[@]}"; do if [[ -f "${output_file}" ]]; then rm -f "${output_file}" openim::log::info "Removed configuration file: ${output_file}" @@ -137,7 +181,10 @@ clean_config_files() { # Function to clean example files clean_example_files() { - for example_file in "${EXAMPLES[@]}"; do + # 合并 EXAMPLES 和 COPY_EXAMPLES 数组 + local all_examples=("${EXAMPLES[@]}" "${COPY_EXAMPLES[@]}") + + for example_file in "${all_examples[@]}"; do if [[ -f "${example_file}" ]]; then rm -f "${example_file}" openim::log::info "Removed example file: ${example_file}" diff --git a/test/e2e/api/token/token.go b/test/e2e/api/token/token.go index 4c578e8f7..88af72058 100644 --- a/test/e2e/api/token/token.go +++ b/test/e2e/api/token/token.go @@ -1,3 +1,17 @@ +// 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 token import ( @@ -9,7 +23,7 @@ import ( "net/http" ) -// API endpoints and other constants +// API endpoints and other constants. const ( APIHost = "http://127.0.0.1:10002" UserTokenURL = APIHost + "/auth/user_token" @@ -18,27 +32,27 @@ const ( OperationID = "1646445464564" ) -// UserTokenRequest represents a request to get a user token +// UserTokenRequest represents a request to get a user token. type UserTokenRequest struct { Secret string `json:"secret"` PlatformID int `json:"platformID"` UserID string `json:"userID"` } -// UserTokenResponse represents a response containing a user token +// UserTokenResponse represents a response containing a user token. type UserTokenResponse struct { Token string `json:"token"` ErrCode int `json:"errCode"` } -// User represents user data for registration +// User represents user data for registration. type User struct { UserID string `json:"userID"` Nickname string `json:"nickname"` FaceURL string `json:"faceURL"` } -// UserRegisterRequest represents a request to register a user +// UserRegisterRequest represents a request to register a user. type UserRegisterRequest struct { Secret string `json:"secret"` Users []User `json:"users"` @@ -58,7 +72,7 @@ func main() { } } -// GetUserToken requests a user token from the API +// GetUserToken requests a user token from the API. func GetUserToken(userID string) (string, error) { reqBody := UserTokenRequest{ Secret: SecretKey, @@ -88,7 +102,7 @@ func GetUserToken(userID string) (string, error) { return tokenResp.Token, nil } -// RegisterUser registers a new user using the API +// RegisterUser registers a new user using the API. func RegisterUser(token, userID, nickname, faceURL string) error { user := User{ UserID: userID, diff --git a/test/e2e/api/user/curd.go b/test/e2e/api/user/curd.go index c0380b235..1b56492b3 100644 --- a/test/e2e/api/user/curd.go +++ b/test/e2e/api/user/curd.go @@ -1,3 +1,17 @@ +// 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 user import ( @@ -7,18 +21,18 @@ import ( "github.com/openimsdk/open-im-server/v3/test/e2e/framework/config" ) -// UserInfoRequest represents a request to get or update user information +// UserInfoRequest represents a request to get or update user information. type UserInfoRequest struct { UserIDs []string `json:"userIDs,omitempty"` UserInfo *gettoken.User `json:"userInfo,omitempty"` } -// GetUsersOnlineStatusRequest represents a request to get users' online status +// GetUsersOnlineStatusRequest represents a request to get users' online status. type GetUsersOnlineStatusRequest struct { UserIDs []string `json:"userIDs"` } -// GetUsersInfo retrieves detailed information for a list of user IDs +// GetUsersInfo retrieves detailed information for a list of user IDs. func GetUsersInfo(token string, userIDs []string) error { url := fmt.Sprintf("http://%s:%s/user/get_users_info", config.LoadConfig().APIHost, config.LoadConfig().APIPort) @@ -29,7 +43,7 @@ func GetUsersInfo(token string, userIDs []string) error { return sendPostRequestWithToken(url, token, requestBody) } -// UpdateUserInfo updates the information for a user +// UpdateUserInfo updates the information for a user. func UpdateUserInfo(token, userID, nickname, faceURL string) error { url := fmt.Sprintf("http://%s:%s/user/update_user_info", config.LoadConfig().APIHost, config.LoadConfig().APIPort) @@ -44,7 +58,7 @@ func UpdateUserInfo(token, userID, nickname, faceURL string) error { return sendPostRequestWithToken(url, token, requestBody) } -// GetUsersOnlineStatus retrieves the online status for a list of user IDs +// GetUsersOnlineStatus retrieves the online status for a list of user IDs. func GetUsersOnlineStatus(token string, userIDs []string) error { url := fmt.Sprintf("http://%s:%s/user/get_users_online_status", config.LoadConfig().APIHost, config.LoadConfig().APIPort) diff --git a/test/e2e/api/user/user.go b/test/e2e/api/user/user.go index 9facf76ac..fd8144acd 100644 --- a/test/e2e/api/user/user.go +++ b/test/e2e/api/user/user.go @@ -1,3 +1,17 @@ +// 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 user import ( @@ -11,29 +25,29 @@ import ( "github.com/openimsdk/open-im-server/v3/test/e2e/framework/config" ) -// ForceLogoutRequest represents a request to force a user logout +// ForceLogoutRequest represents a request to force a user logout. type ForceLogoutRequest struct { PlatformID int `json:"platformID"` UserID string `json:"userID"` } -// CheckUserAccountRequest represents a request to check a user account +// CheckUserAccountRequest represents a request to check a user account. type CheckUserAccountRequest struct { CheckUserIDs []string `json:"checkUserIDs"` } -// GetUsersRequest represents a request to get a list of users +// GetUsersRequest represents a request to get a list of users. type GetUsersRequest struct { Pagination Pagination `json:"pagination"` } -// Pagination specifies the page number and number of items per page +// Pagination specifies the page number and number of items per page. type Pagination struct { PageNumber int `json:"pageNumber"` ShowNumber int `json:"showNumber"` } -// ForceLogout forces a user to log out +// ForceLogout forces a user to log out. func ForceLogout(token, userID string, platformID int) error { url := fmt.Sprintf("http://%s:%s/auth/force_logout", config.LoadConfig().APIHost, config.LoadConfig().APIPort) @@ -45,7 +59,7 @@ func ForceLogout(token, userID string, platformID int) error { return sendPostRequestWithToken(url, token, requestBody) } -// CheckUserAccount checks if the user accounts exist +// CheckUserAccount checks if the user accounts exist. func CheckUserAccount(token string, userIDs []string) error { url := fmt.Sprintf("http://%s:%s/user/account_check", config.LoadConfig().APIHost, config.LoadConfig().APIPort) @@ -56,7 +70,7 @@ func CheckUserAccount(token string, userIDs []string) error { return sendPostRequestWithToken(url, token, requestBody) } -// GetUsers retrieves a list of users with pagination +// GetUsers retrieves a list of users with pagination. func GetUsers(token string, pageNumber, showNumber int) error { url := fmt.Sprintf("http://%s:%s/user/account_check", config.LoadConfig().APIHost, config.LoadConfig().APIPort) @@ -70,7 +84,7 @@ func GetUsers(token string, pageNumber, showNumber int) error { return sendPostRequestWithToken(url, token, requestBody) } -// sendPostRequestWithToken sends a POST request with a token in the header +// sendPostRequestWithToken sends a POST request with a token in the header. func sendPostRequestWithToken(url, token string, body any) error { reqBytes, err := json.Marshal(body) if err != nil { diff --git a/test/e2e/e2e.go b/test/e2e/e2e.go index d1d6c5509..a3d3b1bcf 100644 --- a/test/e2e/e2e.go +++ b/test/e2e/e2e.go @@ -1,3 +1,17 @@ +// 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 e2e import ( diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index 8fe810789..a6496679c 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -1,3 +1,17 @@ +// 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 e2e import ( diff --git a/test/e2e/framework/config/config.go b/test/e2e/framework/config/config.go index ed3c6a258..14074fec1 100644 --- a/test/e2e/framework/config/config.go +++ b/test/e2e/framework/config/config.go @@ -1,3 +1,17 @@ +// 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 config import ( diff --git a/test/e2e/framework/config/config_test.go b/test/e2e/framework/config/config_test.go index c411df31e..b7259bf37 100644 --- a/test/e2e/framework/config/config_test.go +++ b/test/e2e/framework/config/config_test.go @@ -1,3 +1,17 @@ +// 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 config import ( diff --git a/test/e2e/framework/ginkgowrapper/ginkgowrapper.go b/test/e2e/framework/ginkgowrapper/ginkgowrapper.go index 16779440b..814d393bc 100644 --- a/test/e2e/framework/ginkgowrapper/ginkgowrapper.go +++ b/test/e2e/framework/ginkgowrapper/ginkgowrapper.go @@ -1 +1,15 @@ +// 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 ginkgowrapper diff --git a/test/e2e/framework/ginkgowrapper/ginkgowrapper_test.go b/test/e2e/framework/ginkgowrapper/ginkgowrapper_test.go index 16779440b..814d393bc 100644 --- a/test/e2e/framework/ginkgowrapper/ginkgowrapper_test.go +++ b/test/e2e/framework/ginkgowrapper/ginkgowrapper_test.go @@ -1 +1,15 @@ +// 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 ginkgowrapper diff --git a/test/e2e/framework/helpers/chat/chat.go b/test/e2e/framework/helpers/chat/chat.go index 4fca28f2a..a4ead528b 100644 --- a/test/e2e/framework/helpers/chat/chat.go +++ b/test/e2e/framework/helpers/chat/chat.go @@ -1,3 +1,17 @@ +// 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 main import ( @@ -10,7 +24,7 @@ import ( ) var ( - // The default template version + // The default template version. defaultTemplateVersion = "v1.3.0" ) @@ -84,7 +98,7 @@ func main() { select {} } -// getLatestVersion fetches the latest version number from a given URL +// getLatestVersion fetches the latest version number from a given URL. func getLatestVersion(url string) (string, error) { resp, err := http.Get(url) if err != nil { @@ -102,7 +116,7 @@ func getLatestVersion(url string) (string, error) { return latestVersion, nil } -// downloadAndExtract downloads a file from a URL and extracts it to a destination directory +// downloadAndExtract downloads a file from a URL and extracts it to a destination directory. func downloadAndExtract(url, destDir string) error { resp, err := http.Get(url) if err != nil { @@ -141,7 +155,7 @@ func downloadAndExtract(url, destDir string) error { return cmd.Run() } -// startProcess starts a process and prints any errors encountered +// startProcess starts a process and prints any errors encountered. func startProcess(cmdPath string) { cmd := exec.Command(cmdPath) cmd.Stdout = os.Stdout diff --git a/tools/component/component.go b/tools/component/component.go index 140313c30..7150c91af 100644 --- a/tools/component/component.go +++ b/tools/component/component.go @@ -16,7 +16,6 @@ package main import ( "context" - "database/sql" "flag" "fmt" "net" @@ -31,15 +30,11 @@ import ( "github.com/IBM/sarama" "github.com/OpenIMSDK/tools/errs" - "github.com/OpenIMSDK/tools/utils" "github.com/go-zookeeper/zk" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" - "gorm.io/driver/mysql" - "gorm.io/gorm" "github.com/openimsdk/open-im-server/v3/pkg/common/config" - "github.com/openimsdk/open-im-server/v3/pkg/common/kafka" "github.com/minio/minio-go/v7/pkg/credentials" ) @@ -53,6 +48,12 @@ const ( configErrCode = 6001 ) +const ( + colorRed = 31 + colorGreen = 32 + colorYellow = 33 +) + var ( cfgPath = flag.String("c", defaultCfgPath, "Path to the configuration file") @@ -132,127 +133,131 @@ func exactIP(urll string) string { return host } -func checkMysql() error { - if config.Config.Mysql == nil { - return nil +// Helper function to get environment variable or default value +func getEnv(key, fallback string) string { + if value, exists := os.LookupEnv(key); exists { + return value } - var sqlDB *sql.DB - defer func() { - if sqlDB != nil { - sqlDB.Close() - } - }() - dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local", - config.Config.Mysql.Username, config.Config.Mysql.Password, config.Config.Mysql.Address[0], "mysql") - db, err := gorm.Open(mysql.Open(dsn), nil) + return fallback +} + +// checkMongo checks the MongoDB connection +func checkMongo() error { + // Use environment variables or fallback to config + uri := getEnv("MONGO_URI", buildMongoURI()) + + client, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(uri)) if err != nil { return errs.Wrap(err) - } else { - sqlDB, err = db.DB() - err = sqlDB.Ping() - if err != nil { - return errs.Wrap(err) - } + } + defer client.Disconnect(context.TODO()) + + if err = client.Ping(context.TODO(), nil); err != nil { + return errs.Wrap(err) } return nil } -func checkMongo() error { - var client *mongo.Client - uri := "mongodb://sample.host:27017/?maxPoolSize=20&w=majority" - defer func() { - if client != nil { - client.Disconnect(context.TODO()) - } - }() - if config.Config.Mongo.Uri != "" { - uri = config.Config.Mongo.Uri - } else { - mongodbHosts := "" - for i, v := range config.Config.Mongo.Address { - if i == len(config.Config.Mongo.Address)-1 { - mongodbHosts += v - } else { - mongodbHosts += v + "," - } - } - if config.Config.Mongo.Password != "" && config.Config.Mongo.Username != "" { - uri = fmt.Sprintf("mongodb://%s:%s@%s/%s?maxPoolSize=%d&authSource=admin", - config.Config.Mongo.Username, config.Config.Mongo.Password, mongodbHosts, - config.Config.Mongo.Database, config.Config.Mongo.MaxPoolSize) - } else { - uri = fmt.Sprintf("mongodb://%s/%s/?maxPoolSize=%d&authSource=admin", - mongodbHosts, config.Config.Mongo.Database, - config.Config.Mongo.MaxPoolSize) - } +// buildMongoURI constructs the MongoDB URI using configuration settings +func buildMongoURI() string { + // Fallback to config if environment variables are not set + username := config.Config.Mongo.Username + password := config.Config.Mongo.Password + database := config.Config.Mongo.Database + maxPoolSize := config.Config.Mongo.MaxPoolSize + + mongodbHosts := strings.Join(config.Config.Mongo.Address, ",") + + if username != "" && password != "" { + return fmt.Sprintf("mongodb://%s:%s@%s/%s?maxPoolSize=%d&authSource=admin", + username, password, mongodbHosts, database, maxPoolSize) } - client, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(uri)) + return fmt.Sprintf("mongodb://%s/%s?maxPoolSize=%d&authSource=admin", + mongodbHosts, database, maxPoolSize) +} + +// checkMinio checks the MinIO connection +func checkMinio() error { + // Check if MinIO is enabled + if config.Config.Object.Enable != "minio" { + return nil + } + + // Prioritize environment variables + endpoint := getEnv("MINIO_ENDPOINT", config.Config.Object.Minio.Endpoint) + accessKeyID := getEnv("MINIO_ACCESS_KEY_ID", config.Config.Object.Minio.AccessKeyID) + secretAccessKey := getEnv("MINIO_SECRET_ACCESS_KEY", config.Config.Object.Minio.SecretAccessKey) + useSSL := getEnv("MINIO_USE_SSL", "false") // Assuming SSL is not used by default + + if endpoint == "" || accessKeyID == "" || secretAccessKey == "" { + return ErrConfig.Wrap("MinIO configuration missing") + } + + // Parse endpoint URL to determine if SSL is enabled + u, err := url.Parse(endpoint) if err != nil { return errs.Wrap(err) - } else { - err = client.Ping(context.TODO(), nil) - if err != nil { - return errs.Wrap(err) - } } + secure := u.Scheme == "https" || useSSL == "true" - return nil -} + // Initialize MinIO client + minioClient, err := minio.New(u.Host, &minio.Options{ + Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""), + Secure: secure, + }) + if err != nil { + return errs.Wrap(err) + } -func checkMinio() error { - if config.Config.Object.Enable == "minio" { - conf := config.Config.Object.Minio - u, _ := url.Parse(conf.Endpoint) - minioClient, err := minio.New(u.Host, &minio.Options{ - Creds: credentials.NewStaticV4(conf.AccessKeyID, conf.SecretAccessKey, ""), - Secure: u.Scheme == "https", - }) - if err != nil { - return errs.Wrap(err) - } + // Perform health check + cancel, err := minioClient.HealthCheck(time.Duration(minioHealthCheckDuration) * time.Second) + if err != nil { + return errs.Wrap(err) + } + defer cancel() - cancel, err := minioClient.HealthCheck(time.Duration(minioHealthCheckDuration) * time.Second) - defer func() { - if cancel != nil { - cancel() - } - }() - if err != nil { - return errs.Wrap(err) - } else { - if minioClient.IsOffline() { - return ErrComponentStart.Wrap("Minio server is offline") - } - } - if exactIP(config.Config.Object.ApiURL) == "127.0.0.1" || exactIP(config.Config.Object.Minio.SignEndpoint) == "127.0.0.1" { - return ErrConfig.Wrap("apiURL or Minio SignEndpoint endpoint contain 127.0.0.1") - } + if minioClient.IsOffline() { + return ErrComponentStart.Wrap("Minio server is offline") + } + + // Check for localhost in API URL and Minio SignEndpoint + if exactIP(config.Config.Object.ApiURL) == "127.0.0.1" || exactIP(config.Config.Object.Minio.SignEndpoint) == "127.0.0.1" { + return ErrConfig.Wrap("apiURL or Minio SignEndpoint endpoint contain 127.0.0.1") } return nil } +// checkRedis checks the Redis connection func checkRedis() error { + // Prioritize environment variables + address := getEnv("REDIS_ADDRESS", strings.Join(config.Config.Redis.Address, ",")) + username := getEnv("REDIS_USERNAME", config.Config.Redis.Username) + password := getEnv("REDIS_PASSWORD", config.Config.Redis.Password) + + // Split address to handle multiple addresses for cluster setup + redisAddresses := strings.Split(address, ",") + var redisClient redis.UniversalClient - defer func() { - if redisClient != nil { - redisClient.Close() - } - }() - if len(config.Config.Redis.Address) > 1 { + if len(redisAddresses) > 1 { + // Use cluster client for multiple addresses redisClient = redis.NewClusterClient(&redis.ClusterOptions{ - Addrs: config.Config.Redis.Address, - Username: config.Config.Redis.Username, - Password: config.Config.Redis.Password, + Addrs: redisAddresses, + Username: username, + Password: password, }) } else { + // Use regular client for single address redisClient = redis.NewClient(&redis.Options{ - Addr: config.Config.Redis.Address[0], - Username: config.Config.Redis.Username, - Password: config.Config.Redis.Password, + Addr: redisAddresses[0], + Username: username, + Password: password, }) } + defer redisClient.Close() + + // Ping Redis to check connectivity _, err := redisClient.Ping(context.Background()).Result() if err != nil { return errs.Wrap(err) @@ -261,75 +266,110 @@ func checkRedis() error { return nil } +// checkZookeeper checks the Zookeeper connection func checkZookeeper() error { - var c *zk.Conn - defer func() { - if c != nil { - c.Close() - } - }() - c, _, err := zk.Connect(config.Config.Zookeeper.ZkAddr, time.Second) + // Prioritize environment variables + schema := getEnv("ZOOKEEPER_SCHEMA", "digest") + address := getEnv("ZOOKEEPER_ADDRESS", strings.Join(config.Config.Zookeeper.ZkAddr, ",")) + username := getEnv("ZOOKEEPER_USERNAME", config.Config.Zookeeper.Username) + password := getEnv("ZOOKEEPER_PASSWORD", config.Config.Zookeeper.Password) + + // Split addresses to handle multiple Zookeeper nodes + zookeeperAddresses := strings.Split(address, ",") + + // Connect to Zookeeper + c, _, err := zk.Connect(zookeeperAddresses, time.Second) // Adjust the timeout as necessary if err != nil { return errs.Wrap(err) - } else { - if config.Config.Zookeeper.Username != "" && config.Config.Zookeeper.Password != "" { - if err := c.AddAuth("digest", []byte(config.Config.Zookeeper.Username+":"+config.Config.Zookeeper.Password)); err != nil { - return errs.Wrap(err) - } - } - _, _, err = c.Get("/") - if err != nil { + } + defer c.Close() + + // Set authentication if username and password are provided + if username != "" && password != "" { + if err := c.AddAuth(schema, []byte(username+":"+password)); err != nil { return errs.Wrap(err) } } + // Check if Zookeeper is reachable + _, _, err = c.Get("/") + if err != nil { + return errs.Wrap(err) + } + return nil } +// checkKafka checks the Kafka connection func checkKafka() error { - var kafkaClient sarama.Client - defer func() { - if kafkaClient != nil { - kafkaClient.Close() - } - }() + // Prioritize environment variables + username := getEnv("KAFKA_USERNAME", config.Config.Kafka.Username) + password := getEnv("KAFKA_PASSWORD", config.Config.Kafka.Password) + address := getEnv("KAFKA_ADDRESS", strings.Join(config.Config.Kafka.Addr, ",")) + + // Split addresses to handle multiple Kafka brokers + kafkaAddresses := strings.Split(address, ",") + + // Configure Kafka client cfg := sarama.NewConfig() - if config.Config.Kafka.Username != "" && config.Config.Kafka.Password != "" { + if username != "" && password != "" { cfg.Net.SASL.Enable = true - cfg.Net.SASL.User = config.Config.Kafka.Username - cfg.Net.SASL.Password = config.Config.Kafka.Password + cfg.Net.SASL.User = username + cfg.Net.SASL.Password = password } - kafka.SetupTLSConfig(cfg) - kafkaClient, err := sarama.NewClient(config.Config.Kafka.Addr, cfg) + // Additional Kafka setup (e.g., TLS configuration) can be added here + // kafka.SetupTLSConfig(cfg) + + // Create Kafka client + kafkaClient, err := sarama.NewClient(kafkaAddresses, cfg) if err != nil { return errs.Wrap(err) - } else { - topics, err := kafkaClient.Topics() - if err != nil { - return err - } - if !utils.IsContain(config.Config.Kafka.MsgToMongo.Topic, topics) { - return ErrComponentStart.Wrap(fmt.Sprintf("kafka doesn't contain topic:%v", config.Config.Kafka.MsgToMongo.Topic)) - } - if !utils.IsContain(config.Config.Kafka.MsgToPush.Topic, topics) { - return ErrComponentStart.Wrap(fmt.Sprintf("kafka doesn't contain topic:%v", config.Config.Kafka.MsgToPush.Topic)) - } - if !utils.IsContain(config.Config.Kafka.LatestMsgToRedis.Topic, topics) { - return ErrComponentStart.Wrap(fmt.Sprintf("kafka doesn't contain topic:%v", config.Config.Kafka.LatestMsgToRedis.Topic)) + } + defer kafkaClient.Close() + + // Verify if necessary topics exist + topics, err := kafkaClient.Topics() + if err != nil { + return errs.Wrap(err) + } + + requiredTopics := []string{ + config.Config.Kafka.MsgToMongo.Topic, + config.Config.Kafka.MsgToPush.Topic, + config.Config.Kafka.LatestMsgToRedis.Topic, + } + + for _, requiredTopic := range requiredTopics { + if !isTopicPresent(requiredTopic, topics) { + return ErrComponentStart.Wrap(fmt.Sprintf("Kafka doesn't contain topic: %v", requiredTopic)) } } return nil } +// isTopicPresent checks if a topic is present in the list of topics +func isTopicPresent(topic string, topics []string) bool { + for _, t := range topics { + if t == topic { + return true + } + } + return false +} + +func colorPrint(colorCode int, format string, a ...interface{}) { + fmt.Printf("\x1b[%dm%s\x1b[0m\n", colorCode, fmt.Sprintf(format, a...)) +} + func errorPrint(s string) { - fmt.Printf("\x1b[%dm%v\x1b[0m\n", 31, s) + colorPrint(colorRed, "%v", s) } func successPrint(s string) { - fmt.Printf("\x1b[%dm%v\x1b[0m\n", 32, s) + colorPrint(colorGreen, "%v", s) } func warningPrint(s string) { - fmt.Printf("\x1b[%dmWarning: But %v\x1b[0m\n", 33, s) + colorPrint(colorYellow, "Warning: But %v", s) } diff --git a/tools/data-conversion/chat/cmd/conversion-chat/chat.go b/tools/data-conversion/chat/cmd/conversion-chat/chat.go index 77c62ee1f..0fc49c782 100644 --- a/tools/data-conversion/chat/cmd/conversion-chat/chat.go +++ b/tools/data-conversion/chat/cmd/conversion-chat/chat.go @@ -1,3 +1,17 @@ +// 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 main import ( diff --git a/tools/data-conversion/chat/conversion/conversion.go b/tools/data-conversion/chat/conversion/conversion.go index 6032a4569..084fff59c 100644 --- a/tools/data-conversion/chat/conversion/conversion.go +++ b/tools/data-conversion/chat/conversion/conversion.go @@ -1,3 +1,17 @@ +// 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 conversion import ( diff --git a/tools/data-conversion/chat/v2/admin.go b/tools/data-conversion/chat/v2/admin.go index 7bc1b6c1b..fec11ff5b 100644 --- a/tools/data-conversion/chat/v2/admin.go +++ b/tools/data-conversion/chat/v2/admin.go @@ -1,3 +1,17 @@ +// 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 v2 import ( diff --git a/tools/data-conversion/chat/v2/chat.go b/tools/data-conversion/chat/v2/chat.go index 6690e110b..15cc4797f 100644 --- a/tools/data-conversion/chat/v2/chat.go +++ b/tools/data-conversion/chat/v2/chat.go @@ -1,3 +1,17 @@ +// 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 v2 import ( diff --git a/tools/data-conversion/openim/cmd/conversion-msg/conversion-msg.go b/tools/data-conversion/openim/cmd/conversion-msg/conversion-msg.go index 338fbf111..f2b9623a6 100644 --- a/tools/data-conversion/openim/cmd/conversion-msg/conversion-msg.go +++ b/tools/data-conversion/openim/cmd/conversion-msg/conversion-msg.go @@ -1,3 +1,17 @@ +// 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 main import ( diff --git a/tools/data-conversion/openim/mysql/cmd.go b/tools/data-conversion/openim/mysql/cmd.go index 924b0a206..f5a23facb 100644 --- a/tools/data-conversion/openim/mysql/cmd.go +++ b/tools/data-conversion/openim/mysql/cmd.go @@ -1,3 +1,17 @@ +// 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 mysql import ( diff --git a/tools/data-conversion/openim/mysql/conversion/conversion.go b/tools/data-conversion/openim/mysql/conversion/conversion.go index 54cf90edf..f371654df 100644 --- a/tools/data-conversion/openim/mysql/conversion/conversion.go +++ b/tools/data-conversion/openim/mysql/conversion/conversion.go @@ -1,3 +1,17 @@ +// 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 conversion import ( diff --git a/tools/data-conversion/openim/mysql/v2/model_struct.go b/tools/data-conversion/openim/mysql/v2/model_struct.go index 9da33f2a5..f05b84977 100644 --- a/tools/data-conversion/openim/mysql/v2/model_struct.go +++ b/tools/data-conversion/openim/mysql/v2/model_struct.go @@ -1,3 +1,17 @@ +// 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 db import "time" diff --git a/tools/data-conversion/openim/mysql/v3/log.go b/tools/data-conversion/openim/mysql/v3/log.go index 5904a790e..22198ca7c 100644 --- a/tools/data-conversion/openim/mysql/v3/log.go +++ b/tools/data-conversion/openim/mysql/v3/log.go @@ -1,3 +1,17 @@ +// 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 relation import ( diff --git a/tools/data-conversion/openim/proto/msg/msg.proto b/tools/data-conversion/openim/proto/msg/msg.proto index d2fe5337e..3149a7337 100644 --- a/tools/data-conversion/openim/proto/msg/msg.proto +++ b/tools/data-conversion/openim/proto/msg/msg.proto @@ -1,3 +1,17 @@ +// 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. + syntax = "proto3"; import "Open-IM-Server/pkg/proto/sdk_ws/ws.proto"; import "Open-IM-Server/pkg/proto/sdk_ws/wrappers.proto"; diff --git a/tools/data-conversion/openim/proto/sdk_ws/ws.proto b/tools/data-conversion/openim/proto/sdk_ws/ws.proto index c8ef680c9..95b956b0e 100644 --- a/tools/data-conversion/openim/proto/sdk_ws/ws.proto +++ b/tools/data-conversion/openim/proto/sdk_ws/ws.proto @@ -1,3 +1,17 @@ +// 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. + syntax = "proto3"; import "Open-IM-Server/pkg/proto/sdk_ws/wrappers.proto"; option go_package = "Open_IM/pkg/proto/sdk_ws;server_api_params"; diff --git a/tools/data-conversion/utils/find_insert.go b/tools/data-conversion/utils/find_insert.go index 4789cd554..150820fce 100644 --- a/tools/data-conversion/utils/find_insert.go +++ b/tools/data-conversion/utils/find_insert.go @@ -1,3 +1,17 @@ +// 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 utils import ( diff --git a/tools/data-conversion/utils/time.go b/tools/data-conversion/utils/time.go index e2dac4bb8..9077a3d88 100644 --- a/tools/data-conversion/utils/time.go +++ b/tools/data-conversion/utils/time.go @@ -1,3 +1,17 @@ +// 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 utils import "time" diff --git a/tools/infra/infra.go b/tools/infra/infra.go index f8d8c7522..c14b92fa3 100644 --- a/tools/infra/infra.go +++ b/tools/infra/infra.go @@ -1,3 +1,17 @@ +// 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 main import ( diff --git a/tools/up35/pkg/convert.go b/tools/up35/pkg/convert.go index 91fdb474e..24d3a2781 100644 --- a/tools/up35/pkg/convert.go +++ b/tools/up35/pkg/convert.go @@ -1,11 +1,26 @@ +// 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 pkg import ( + "time" + mongoModel "github.com/openimsdk/open-im-server/v3/pkg/common/db/table/relation" mysqlModel "github.com/openimsdk/open-im-server/v3/tools/data-conversion/openim/mysql/v3" mongoModelRtc "github.com/openimsdk/open-im-server/v3/tools/up35/pkg/internal/rtc/mongo/table" mysqlModelRtc "github.com/openimsdk/open-im-server/v3/tools/up35/pkg/internal/rtc/mysql" - "time" ) type convert struct{} diff --git a/tools/up35/pkg/internal/rtc/mongo/mgo/meeting.go b/tools/up35/pkg/internal/rtc/mongo/mgo/meeting.go index e3bab7af9..fd0f2818b 100644 --- a/tools/up35/pkg/internal/rtc/mongo/mgo/meeting.go +++ b/tools/up35/pkg/internal/rtc/mongo/mgo/meeting.go @@ -1,14 +1,30 @@ +// 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 mgo import ( "context" + "time" + "github.com/OpenIMSDK/tools/mgoutil" "github.com/OpenIMSDK/tools/pagination" - "github.com/openimsdk/open-im-server/v3/tools/up35/pkg/internal/rtc/mongo/table" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" - "time" + + "github.com/openimsdk/open-im-server/v3/tools/up35/pkg/internal/rtc/mongo/table" ) func NewMeeting(db *mongo.Database) (table.MeetingInterface, error) { diff --git a/tools/up35/pkg/internal/rtc/mongo/mgo/meeting_invitation.go b/tools/up35/pkg/internal/rtc/mongo/mgo/meeting_invitation.go index 5286ffa95..9926748bf 100644 --- a/tools/up35/pkg/internal/rtc/mongo/mgo/meeting_invitation.go +++ b/tools/up35/pkg/internal/rtc/mongo/mgo/meeting_invitation.go @@ -1,15 +1,31 @@ +// 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 mgo import ( "context" + "time" + "github.com/OpenIMSDK/tools/mgoutil" "github.com/OpenIMSDK/tools/pagination" "github.com/OpenIMSDK/tools/utils" - "github.com/openimsdk/open-im-server/v3/tools/up35/pkg/internal/rtc/mongo/table" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" - "time" + + "github.com/openimsdk/open-im-server/v3/tools/up35/pkg/internal/rtc/mongo/table" ) func NewMeetingInvitation(db *mongo.Database) (table.MeetingInvitationInterface, error) { @@ -55,7 +71,12 @@ func (x *meetingInvitation) CreateMeetingInvitationInfo(ctx context.Context, roo func (x *meetingInvitation) GetUserInvitedMeetingIDs(ctx context.Context, userID string) (meetingIDs []string, err error) { fiveDaysAgo := time.Now().AddDate(0, 0, -5) - return mgoutil.Find[string](ctx, x.coll, bson.M{"user_id": userID, "create_time": bson.M{"$gte": fiveDaysAgo}}, options.Find().SetSort(bson.M{"create_time": -1}).SetProjection(bson.M{"_id": 0, "room_id": 1})) + return mgoutil.Find[string]( + ctx, + x.coll, + bson.M{"user_id": userID, "create_time": bson.M{"$gte": fiveDaysAgo}}, + options.Find().SetSort(bson.M{"create_time": -1}).SetProjection(bson.M{"_id": 0, "room_id": 1}), + ) } func (x *meetingInvitation) Delete(ctx context.Context, roomIDs []string) error { diff --git a/tools/up35/pkg/internal/rtc/mongo/mgo/meeting_record.go b/tools/up35/pkg/internal/rtc/mongo/mgo/meeting_record.go index 90fc9cdca..4e9dc5e0f 100644 --- a/tools/up35/pkg/internal/rtc/mongo/mgo/meeting_record.go +++ b/tools/up35/pkg/internal/rtc/mongo/mgo/meeting_record.go @@ -1,11 +1,27 @@ +// 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 mgo import ( "context" + "github.com/OpenIMSDK/tools/mgoutil" - "github.com/openimsdk/open-im-server/v3/tools/up35/pkg/internal/rtc/mongo/table" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" + + "github.com/openimsdk/open-im-server/v3/tools/up35/pkg/internal/rtc/mongo/table" ) func NewMeetingRecord(db *mongo.Database) (table.MeetingRecordInterface, error) { diff --git a/tools/up35/pkg/internal/rtc/mongo/mgo/signal.go b/tools/up35/pkg/internal/rtc/mongo/mgo/signal.go index 0c1879007..47fd3fb02 100644 --- a/tools/up35/pkg/internal/rtc/mongo/mgo/signal.go +++ b/tools/up35/pkg/internal/rtc/mongo/mgo/signal.go @@ -1,14 +1,30 @@ +// 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 mgo import ( "context" + "time" + "github.com/OpenIMSDK/tools/mgoutil" "github.com/OpenIMSDK/tools/pagination" - "github.com/openimsdk/open-im-server/v3/tools/up35/pkg/internal/rtc/mongo/table" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" - "time" + + "github.com/openimsdk/open-im-server/v3/tools/up35/pkg/internal/rtc/mongo/table" ) func NewSignal(db *mongo.Database) (table.SignalInterface, error) { diff --git a/tools/up35/pkg/internal/rtc/mongo/mgo/signal_invitation.go b/tools/up35/pkg/internal/rtc/mongo/mgo/signal_invitation.go index 274f2f11f..1f76381e9 100644 --- a/tools/up35/pkg/internal/rtc/mongo/mgo/signal_invitation.go +++ b/tools/up35/pkg/internal/rtc/mongo/mgo/signal_invitation.go @@ -1,15 +1,31 @@ +// 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 mgo import ( "context" + "time" + "github.com/OpenIMSDK/tools/mgoutil" "github.com/OpenIMSDK/tools/pagination" "github.com/OpenIMSDK/tools/utils" - "github.com/openimsdk/open-im-server/v3/tools/up35/pkg/internal/rtc/mongo/table" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" - "time" + + "github.com/openimsdk/open-im-server/v3/tools/up35/pkg/internal/rtc/mongo/table" ) func NewSignalInvitation(db *mongo.Database) (table.SignalInvitationInterface, error) { diff --git a/tools/up35/pkg/internal/rtc/mongo/table/meeting.go b/tools/up35/pkg/internal/rtc/mongo/table/meeting.go index 3b341cfb1..6ff387bbb 100644 --- a/tools/up35/pkg/internal/rtc/mongo/table/meeting.go +++ b/tools/up35/pkg/internal/rtc/mongo/table/meeting.go @@ -1,9 +1,24 @@ +// 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 table import ( "context" - "github.com/OpenIMSDK/tools/pagination" "time" + + "github.com/OpenIMSDK/tools/pagination" ) type MeetingInfo struct { diff --git a/tools/up35/pkg/internal/rtc/mongo/table/signal.go b/tools/up35/pkg/internal/rtc/mongo/table/signal.go index 0cec050ff..8d8aa96ed 100644 --- a/tools/up35/pkg/internal/rtc/mongo/table/signal.go +++ b/tools/up35/pkg/internal/rtc/mongo/table/signal.go @@ -1,12 +1,27 @@ +// 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 table import ( "context" + "time" + "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/pagination" "github.com/redis/go-redis/v9" "go.mongodb.org/mongo-driver/mongo" - "time" ) type SignalModel struct { diff --git a/tools/up35/pkg/internal/rtc/mysql/meeting.go b/tools/up35/pkg/internal/rtc/mysql/meeting.go index 2c5bbed32..71515c3b7 100644 --- a/tools/up35/pkg/internal/rtc/mysql/meeting.go +++ b/tools/up35/pkg/internal/rtc/mysql/meeting.go @@ -1,3 +1,17 @@ +// 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 relation import ( diff --git a/tools/up35/pkg/internal/rtc/mysql/signal.go b/tools/up35/pkg/internal/rtc/mysql/signal.go index 3a4d607d4..c546360a4 100644 --- a/tools/up35/pkg/internal/rtc/mysql/signal.go +++ b/tools/up35/pkg/internal/rtc/mysql/signal.go @@ -1,3 +1,17 @@ +// 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 relation import ( @@ -16,7 +30,7 @@ type SignalModel struct { SessionType int32 `gorm:"column:sesstion_type"` InitiateTime time.Time `gorm:"column:initiate_time"` EndTime time.Time `gorm:"column:end_time"` - FileURL string `gorm:"column:file_url" json:"-"` + FileURL string `gorm:"column:file_url" json:"-"` Title string `gorm:"column:title;size:128"` Desc string `gorm:"column:desc;size:1024"` diff --git a/tools/up35/pkg/pkg.go b/tools/up35/pkg/pkg.go index d834b8492..6d16817ec 100644 --- a/tools/up35/pkg/pkg.go +++ b/tools/up35/pkg/pkg.go @@ -1,15 +1,30 @@ +// 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 pkg import ( "context" "errors" "fmt" - "gopkg.in/yaml.v3" "log" "os" "reflect" "strconv" + "gopkg.in/yaml.v3" + "github.com/go-sql-driver/mysql" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" diff --git a/tools/up35/up35.go b/tools/up35/up35.go index 0ce56ee13..63b6ec2c2 100644 --- a/tools/up35/up35.go +++ b/tools/up35/up35.go @@ -1,10 +1,25 @@ +// 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 main import ( "flag" - "github.com/openimsdk/open-im-server/v3/tools/up35/pkg" "log" "os" + + "github.com/openimsdk/open-im-server/v3/tools/up35/pkg" ) func main() { diff --git a/tools/url2im/main.go b/tools/url2im/main.go index ee159b5e8..8d6151b09 100644 --- a/tools/url2im/main.go +++ b/tools/url2im/main.go @@ -1,3 +1,17 @@ +// 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 main import ( diff --git a/tools/url2im/pkg/api.go b/tools/url2im/pkg/api.go index 1fc3813bb..7575b078a 100644 --- a/tools/url2im/pkg/api.go +++ b/tools/url2im/pkg/api.go @@ -1,3 +1,17 @@ +// 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 pkg import ( diff --git a/tools/url2im/pkg/buffer.go b/tools/url2im/pkg/buffer.go index 8ccc5c52f..b4c104652 100644 --- a/tools/url2im/pkg/buffer.go +++ b/tools/url2im/pkg/buffer.go @@ -1,3 +1,17 @@ +// 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 pkg import ( diff --git a/tools/url2im/pkg/config.go b/tools/url2im/pkg/config.go index 020395262..740e748cb 100644 --- a/tools/url2im/pkg/config.go +++ b/tools/url2im/pkg/config.go @@ -1,3 +1,17 @@ +// 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 pkg import "time" diff --git a/tools/url2im/pkg/http.go b/tools/url2im/pkg/http.go index 32e128524..50fb30c7b 100644 --- a/tools/url2im/pkg/http.go +++ b/tools/url2im/pkg/http.go @@ -1,3 +1,17 @@ +// 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 pkg import "net/http" diff --git a/tools/url2im/pkg/manage.go b/tools/url2im/pkg/manage.go index a68078f85..70c6713fc 100644 --- a/tools/url2im/pkg/manage.go +++ b/tools/url2im/pkg/manage.go @@ -1,3 +1,17 @@ +// 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 pkg import ( diff --git a/tools/url2im/pkg/md5.go b/tools/url2im/pkg/md5.go index 0db5ba000..26b8d47a2 100644 --- a/tools/url2im/pkg/md5.go +++ b/tools/url2im/pkg/md5.go @@ -1,3 +1,17 @@ +// 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 pkg import ( diff --git a/tools/url2im/pkg/progress.go b/tools/url2im/pkg/progress.go index 2d6ef3891..5f30495c6 100644 --- a/tools/url2im/pkg/progress.go +++ b/tools/url2im/pkg/progress.go @@ -1,3 +1,17 @@ +// 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 pkg import (