Merge branch 'main' into feat-simplify-mongodb-init

This commit is contained in:
Mohamed Achref Hemissi 2026-11-09 09:01:36 +01:00 committed by GitHub
commit 5545a6f658
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
136 changed files with 3288 additions and 2900 deletions

4
.env
View File

@ -1,8 +1,8 @@
MONGO_IMAGE=mongo:7.0
REDIS_IMAGE=redis:7.0.0
KAFKA_IMAGE=bitnamilegacy/kafka:3.5.1
MINIO_IMAGE=minio/minio:RELEASE.2024-01-11T07-46-16Z
ETCD_IMAGE=bitnamilegacy/etcd:3.5.13
MINIO_IMAGE=bitnamilegacy/minio:2024.1.13
ETCD_IMAGE=bitnamilegacy/etcd:3.5.21
PROMETHEUS_IMAGE=prom/prometheus:v2.45.6
ALERTMANAGER_IMAGE=prom/alertmanager:v0.27.0
GRAFANA_IMAGE=grafana/grafana:11.0.1

View File

@ -5,23 +5,23 @@ on:
jobs:
assign-issue:
if: |
contains(github.event.comment.body, '/assign') || contains(github.event.comment.body, '/accept') &&
(contains(github.event.comment.body, '/assign') || contains(github.event.comment.body, '/accept')) &&
!contains(github.event.comment.user.login, 'openim-robot')
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v7.0.0
- name: Assign the issue
run: |
export LETASE_MILESTONES=$(curl 'https://api.github.com/repos/$OWNER/$PEPO/milestones' | jq -r 'last(.[]).title')
export LATEST_MILESTONE=$(curl "https://api.github.com/repos/$OWNER/$REPO/milestones" | jq -r 'last(.[]).title')
gh issue edit ${{ github.event.issue.number }} --add-assignee "${{ github.event.comment.user.login }}"
gh issue edit ${{ github.event.issue.number }} --add-label "accepted"
gh issue comment $ISSUE --body "@${{ github.event.comment.user.login }} Glad to see you accepted this issue🤲, this issue has been assigned to you. I set the milestones for this issue to [$LETASE_MILESTONES](https://github.com/$OWNER/$PEPO/milestones), We are looking forward to your PR!"
gh issue comment $ISSUE --body "@${{ github.event.comment.user.login }} Glad to see you accepted this issue🤲, this issue has been assigned to you. I set the milestones for this issue to [$LATEST_MILESTONE](https://github.com/$OWNER/$REPO/milestones), We are looking forward to your PR!"
# gh issue edit ${{ github.event.issue.number }} --milestone "$LETASE_MILESTONES"
# gh issue edit ${{ github.event.issue.number }} --milestone "$LATEST_MILESTONE"
env:
GH_TOKEN: ${{ secrets.BOT_TOKEN }}
ISSUE: ${{ github.event.issue.html_url }}

View File

@ -12,7 +12,7 @@ jobs:
issues: write
steps:
- name: Invite user to join OpenIM Community
uses: peter-evans/create-or-update-comment@v4
uses: peter-evans/create-or-update-comment@v5.0.0
with:
token: ${{ secrets.BOT_GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}

View File

@ -13,7 +13,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v7.0.0
- name: Set up Go
uses: actions/setup-go@v6.5.0
with:
go-version-file: go.mod
- name: Run Go Changelog Generator
run: |
@ -66,7 +71,7 @@ jobs:
rm -f "${{ github.event.release.tag_name }}-changelog.md"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7.0.5
uses: peter-evans/create-pull-request@v8.1.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Update CHANGELOG for release ${{ github.event.release.tag_name }}"

View File

@ -18,7 +18,7 @@ jobs:
steps:
- name: "CLA Assistant"
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
uses: contributor-assistant/github-action@v2.4.0
uses: contributor-assistant/github-action@v2.6.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PERSONAL_ACCESS_TOKEN: ${{ secrets.BOT_TOKEN }}

View File

@ -11,14 +11,13 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4.2.0
uses: actions/checkout@v7.0.0
- name: Get the PR title and extract PR numbers
id: extract_pr_numbers
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
# Get the PR title
PR_TITLE="${{ github.event.pull_request.title }}"
echo "PR Title: $PR_TITLE"
# Extract PR numbers from the title
@ -57,9 +56,8 @@ jobs:
- name: Delete branch after PR close
if: steps.extract_pr_numbers.outputs.proceed == 'true' || contains(github.event.pull_request.labels.*.name, 'milestone-merge')
env:
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
run: |
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
echo "Branch to delete: $BRANCH_NAME"
git push origin --delete "$BRANCH_NAME"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -35,11 +35,11 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v7.0.0
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
uses: github/codeql-action/init@v4.36.2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
@ -50,7 +50,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3
uses: github/codeql-action/autobuild@v4.36.2
# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
@ -64,4 +64,4 @@ jobs:
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
uses: github/codeql-action/analyze@v4.36.2

View File

@ -17,7 +17,7 @@ jobs:
EXCLUDE_FILES: "*.md *.txt *.html *.css *.min.js *.mdx"
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7.0.0
- name: Search for Non-English comments
run: |

View File

@ -4,88 +4,162 @@ on:
push:
branches:
- release-*
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: "Tag version to be used for Docker image"
required: true
default: "v3.8.3"
workflow_call:
inputs:
tag:
description: "Tag version to be used for Docker image"
required: true
type: string
checkout_sha:
description: "Commit SHA to checkout"
required: true
type: string
checkout_short_sha:
description: "Short commit SHA for image tags"
required: true
type: string
jobs:
build-and-push:
services:
runs-on: ubuntu-latest
outputs:
services: ${{ steps.services.outputs.services }}
steps:
- name: Checkout repository
uses: actions/checkout@v7.0.0
with:
ref: ${{ inputs.checkout_sha || inputs.tag || github.event.inputs.tag }}
- name: Resolve service matrix
id: services
run: |
set -euo pipefail
services=$(docker compose -f build/images/openim-server/docker-compose.build.yml config --services | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "services=$services" >> "$GITHUB_OUTPUT"
build-and-push:
needs: services
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
service: ${{ fromJson(needs.services.outputs.services) }}
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v7.0.0
with:
ref: ${{ inputs.checkout_sha || inputs.tag || github.event.inputs.tag }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v4.1.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.8.0
uses: docker/setup-buildx-action@v4.1.0
- name: Log in to Docker Hub
uses: docker/login-action@v3.3.0
uses: docker/login-action@v4.2.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3.3.0
uses: docker/login-action@v4.2.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Aliyun Container Registry
uses: docker/login-action@v3.3.0
uses: docker/login-action@v4.2.0
with:
registry: registry.cn-hangzhou.aliyuncs.com
username: ${{ secrets.ALIREGISTRY_USERNAME }}
password: ${{ secrets.ALIREGISTRY_TOKEN }}
- name: Extract metadata for Docker (tags, labels)
id: meta
uses: docker/metadata-action@v5.6.0
with:
tags: |
type=ref,event=tag
type=schedule
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern=v{{version}}
type=semver,pattern=release-{{raw}}
type=sha
type=raw,value=${{ github.event.inputs.tag }}
- name: Resolve Docker image tags
id: tags
env:
INPUT_TAG: ${{ inputs.tag || github.event.inputs.tag }}
RELEASE_TAG: ${{ github.event.release.tag_name }}
CHECKOUT_SHORT_SHA: ${{ inputs.checkout_short_sha }}
run: |
set -euo pipefail
tags=()
declare -A seen=()
add_tag() {
local tag="$1"
[[ -n "$tag" ]] || return 0
tag="${tag//\//-}"
if [[ -z "${seen[$tag]+x}" ]]; then
tags+=("$tag")
seen["$tag"]=1
fi
}
add_tag_with_semver_alias() {
local tag="$1"
add_tag "$tag"
if [[ "$tag" =~ ^v([0-9]+\.[0-9]+\.[0-9]+.*)$ ]]; then
add_tag "${BASH_REMATCH[1]}"
add_tag "release-$tag"
fi
}
add_tag_with_semver_alias "${INPUT_TAG:-}"
add_tag_with_semver_alias "${RELEASE_TAG:-}"
if [[ "${GITHUB_EVENT_NAME:-}" == "release" && "${{ github.event.release.prerelease }}" != "true" ]]; then
add_tag "latest"
fi
if [[ "${GITHUB_REF_TYPE:-}" == "tag" ]]; then
add_tag_with_semver_alias "${GITHUB_REF_NAME}"
elif [[ "${GITHUB_REF_TYPE:-}" == "branch" ]]; then
add_tag "${GITHUB_REF_NAME}"
fi
add_tag "sha-${CHECKOUT_SHORT_SHA:-${GITHUB_SHA::7}}"
{
echo "tags<<EOF"
printf '%s\n' "${tags[@]}"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Build and push Docker images
env:
RELEASE: "true"
PUSH: "true"
SERVICE: ${{ matrix.service }}
PLATFORMS: linux/amd64,linux/arm64
IMAGE_TAGS: ${{ steps.tags.outputs.tags }}
IMAGE_REGISTRIES: |
${{ secrets.DOCKER_USERNAME }}
ghcr.io/${{ github.repository_owner }}
run: |
IMG_DIR="build/images"
for dir in "$IMG_DIR"/*/; do
# Find Dockerfile or *.dockerfile in a case-insensitive manner
dockerfile=$(find "$dir" -maxdepth 1 -type f \( -iname 'dockerfile' -o -iname '*.dockerfile' \) | head -n 1)
if [ -n "$dockerfile" ] && [ -f "$dockerfile" ]; then
IMAGE_NAME=$(basename "$dir")
echo "Building Docker image for $IMAGE_NAME with tags:"
# Initialize tag arguments
tag_args=()
bash build/build_single.sh
# Read each tag and append --tag arguments
while IFS= read -r tag; do
tag_args+=(--tag "${{ secrets.DOCKER_USERNAME }}/$IMAGE_NAME:$tag")
tag_args+=(--tag "ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:$tag")
tag_args+=(--tag "registry.cn-hangzhou.aliyuncs.com/openimsdk/$IMAGE_NAME:$tag")
done <<< "${{ steps.meta.outputs.tags }}"
# Build and push the Docker image with all tags
docker buildx build --platform linux/amd64,linux/arm64 \
--file "$dockerfile" \
"${tag_args[@]}" \
--push \
"."
else
echo "No valid Dockerfile found in $dir"
fi
done
- name: Build and push Docker images to ACR
env:
BUILDX_NO_DEFAULT_ATTESTATIONS: '1'
RELEASE: "true"
PUSH: "true"
SERVICE: ${{ matrix.service }}
PLATFORMS: linux/amd64,linux/arm64
IMAGE_TAGS: ${{ steps.tags.outputs.tags }}
IMAGE_REGISTRIES: registry.cn-hangzhou.aliyuncs.com/openimsdk
run: |
bash build/build_single.sh

View File

@ -22,14 +22,14 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
go_version: ["1.22.x"]
go_version: ["stable"]
steps:
- name: Checkout Server repository
uses: actions/checkout@v4
uses: actions/checkout@v7.0.0
- name: Set up Go ${{ matrix.go_version }}
uses: actions/setup-go@v5
uses: actions/setup-go@v6.5.0
with:
go-version: ${{ matrix.go_version }}
@ -40,7 +40,7 @@ jobs:
go mod download
- name: Set up infra services
uses: hoverkraft-tech/compose-action@v2.0.1
uses: hoverkraft-tech/compose-action@v3.0.0
with:
compose-file: "./docker-compose.yml"
@ -67,7 +67,7 @@ jobs:
mage check
- name: Checkout Chat repository
uses: actions/checkout@v4
uses: actions/checkout@v7.0.0
with:
repository: "openimsdk/chat"
path: "chat-repo"
@ -188,21 +188,21 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
go_version: ["1.22.x"]
go_version: ["stable"]
steps:
- name: Checkout Server repository
uses: actions/checkout@v4
uses: actions/checkout@v7.0.0
- name: Checkout SDK repository
uses: actions/checkout@v4
uses: actions/checkout@v7.0.0
with:
repository: "openimsdk/openim-sdk-core"
ref: "main"
path: ${{ env.SDK_DIR }}
- name: Set up Go ${{ matrix.go_version }}
uses: actions/setup-go@v5
uses: actions/setup-go@v6.5.0
with:
go-version: ${{ matrix.go_version }}
@ -237,14 +237,14 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go_version: ["1.22"]
go_version: ["stable"]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
uses: actions/checkout@v7.0.0
- name: Set up Go ${{ matrix.go_version }}
uses: actions/setup-go@v5
uses: actions/setup-go@v6.5.0
with:
go-version: ${{ matrix.go_version }}

View File

@ -26,7 +26,7 @@ jobs:
issues: write
steps:
- name: Add comment
uses: peter-evans/create-or-update-comment@v4
uses: peter-evans/create-or-update-comment@v5.0.0
with:
issue-number: ${{ github.event.issue.number }}
token: ${{ secrets.BOT_TOKEN }}

View File

@ -40,7 +40,7 @@ jobs:
touch ${{ env.TEMP_DIR }}/created_pr_number.txt
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v7.0.0
with:
fetch-depth: 0
token: ${{ secrets.BOT_TOKEN }}

View File

@ -4,17 +4,28 @@ on:
push:
branches:
- release-*
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: "Tag version to be used for Docker image"
required: true
default: "v3.8.3"
workflow_call:
inputs:
tag:
description: "Tag version to be used for Docker image"
required: true
type: string
checkout_sha:
description: "Commit SHA to checkout"
required: true
type: string
checkout_short_sha:
description: "Short commit SHA for image tags"
required: true
type: string
env:
GO_VERSION: "1.22"
IMAGE_NAME: "openim-server"
# IMAGE_NAME: ${{ github.event.repository.name }}
DOCKER_BUILDKIT: 1
@ -22,25 +33,29 @@ env:
jobs:
publish-docker-images:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
if: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.merged == false) }}
steps:
- name: Checkout main repository
uses: actions/checkout@v4
uses: actions/checkout@v7.0.0
with:
ref: ${{ inputs.checkout_sha || inputs.tag || github.event.inputs.tag }}
path: main-repo
- name: Set up QEMU
uses: docker/setup-qemu-action@v3.3.0
uses: docker/setup-qemu-action@v4.1.0
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v4.1.0
with:
driver-opts: network=host
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5.6.0
uses: docker/metadata-action@v6.1.0
with:
images: |
${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}
@ -55,7 +70,10 @@ jobs:
type=semver,pattern=v{{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
type=sha,enable=${{ inputs.checkout_short_sha == '' }}
type=raw,value=sha-${{ inputs.checkout_short_sha }},enable=${{ inputs.checkout_short_sha != '' }}
type=raw,value=${{ inputs.tag || github.event.inputs.tag }}
type=raw,value=latest,enable=${{ github.event_name == 'release' && !github.event.release.prerelease }}
- name: Install skopeo
run: |
@ -80,7 +98,7 @@ jobs:
docker image ls | grep openim
- name: Checkout compose repository
uses: actions/checkout@v4
uses: actions/checkout@v7.0.0
with:
repository: "openimsdk/openim-docker"
path: "compose-repo"
@ -134,20 +152,20 @@ jobs:
# fi
- name: Log in to Docker Hub
uses: docker/login-action@v3.3.0
uses: docker/login-action@v4.2.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3.3.0
uses: docker/login-action@v4.2.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Aliyun Container Registry
uses: docker/login-action@v3.3.0
uses: docker/login-action@v4.2.0
with:
registry: registry.cn-hangzhou.aliyuncs.com
username: ${{ secrets.ALIREGISTRY_USERNAME }}
@ -155,13 +173,46 @@ jobs:
- name: Push multi-architecture images
if: success()
env:
IMAGE_TAGS: ${{ steps.meta.outputs.tags }}
run: |
docker buildx build \
--platform linux/amd64,linux/arm64 \
$(echo "${{ steps.meta.outputs.tags }}" | sed 's/,/ --tag /g' | sed 's/^/--tag /') \
--cache-from type=local,src=/tmp/docker-cache \
--push \
./main-repo
set -euo pipefail
tag_args=()
while IFS= read -r tag; do
[[ -n "$tag" ]] || continue
[[ "${tag%%/*}" != *.aliyuncs.com ]] || continue
tag_args+=(--tag "$tag")
done < <(printf '%s\n' "$IMAGE_TAGS" | tr ',' '\n')
if [[ ${#tag_args[@]} -gt 0 ]]; then
docker buildx build \
--platform linux/amd64,linux/arm64 \
"${tag_args[@]}" \
--cache-from type=local,src=/tmp/docker-cache \
--push ./main-repo
fi
- name: Push multi-architecture images to ACR
if: success()
env:
BUILDX_NO_DEFAULT_ATTESTATIONS: '1'
IMAGE_TAGS: ${{ steps.meta.outputs.tags }}
run: |
set -euo pipefail
tag_args=()
while IFS= read -r tag; do
[[ -n "$tag" ]] || continue
[[ "${tag%%/*}" == *.aliyuncs.com ]] || continue
tag_args+=(--tag "$tag")
done < <(printf '%s\n' "$IMAGE_TAGS" | tr ',' '\n')
if [[ ${#tag_args[@]} -gt 0 ]]; then
docker buildx build \
--platform linux/amd64,linux/arm64 \
"${tag_args[@]}" \
--cache-from type=local,src=/tmp/docker-cache \
--push ./main-repo
fi
- name: Verify multi-platform support
run: |

56
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,56 @@
name: Release
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: "Existing tag to release"
required: true
target_branch:
description: "Branch that the release tag was created from"
required: true
permissions:
actions: write
contents: write
packages: write
concurrency:
group: release-${{ github.event.release.tag_name || inputs.tag }}
cancel-in-progress: false
jobs:
update-version:
permissions:
contents: write
uses: ./.github/workflows/update-version-file-on-release.yml
with:
tag: ${{ github.event.release.tag_name || inputs.tag }}
target_branch: ${{ github.event.release.target_commitish || inputs.target_branch }}
secrets: inherit
docker-image:
needs: update-version
permissions:
contents: read
packages: write
uses: ./.github/workflows/publish-docker-image.yml
with:
tag: ${{ github.event.release.tag_name || inputs.tag }}
checkout_sha: ${{ needs.update-version.outputs.updated_sha }}
checkout_short_sha: ${{ needs.update-version.outputs.updated_short_sha }}
secrets: inherit
service-images:
needs: update-version
permissions:
contents: read
packages: write
uses: ./.github/workflows/docker-build-and-release-services-images.yml
with:
tag: ${{ github.event.release.tag_name || inputs.tag }}
checkout_sha: ${{ needs.update-version.outputs.updated_sha }}
checkout_short_sha: ${{ needs.update-version.outputs.updated_short_sha }}
secrets: inherit

View File

@ -11,11 +11,11 @@ jobs:
contents: read
steps:
- name: Checkout Repository
uses: actions/checkout@v4
uses: actions/checkout@v7.0.0
- name: Fetch All Issues and PRs
id: fetch_issues_prs
uses: actions/github-script@v7.0.1
uses: actions/github-script@v9.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
@ -38,7 +38,7 @@ jobs:
- name: Fetch All Labels
id: fetch_labels
uses: actions/github-script@v7.0.1
uses: actions/github-script@v9.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
@ -52,7 +52,7 @@ jobs:
result-encoding: string
- name: Remove Unused Labels
uses: actions/github-script@v7.0.1
uses: actions/github-script@v9.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |

View File

@ -12,11 +12,11 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v4
uses: actions/checkout@v7.0.0
- name: Fetch Closed Issues with lifecycle/stale Label
id: fetch_issues
uses: actions/github-script@v7
uses: actions/github-script@v9.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
@ -40,7 +40,7 @@ jobs:
echo "Issue numbers: ${{ steps.fetch_issues.outputs.result }}"
- name: Reopen Issues
uses: actions/github-script@v7
uses: actions/github-script@v9.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
@ -59,7 +59,7 @@ jobs:
}
- name: Remove lifecycle/stale Label
uses: actions/github-script@v7
uses: actions/github-script@v9.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |

View File

@ -1,22 +1,66 @@
name: Update Version File on Release
on:
release:
types: [created]
workflow_dispatch:
inputs:
tag:
description: "Tag version to update"
required: true
target_branch:
description: "Branch that the release tag was created from"
required: true
workflow_call:
inputs:
tag:
description: "Tag version to update"
required: true
type: string
target_branch:
description: "Branch that the release tag was created from"
required: true
type: string
outputs:
updated_sha:
description: "Commit SHA after updating version and moving the tag"
value: ${{ jobs.update-version.outputs.updated_sha }}
updated_short_sha:
description: "Short commit SHA after updating version and moving the tag"
value: ${{ jobs.update-version.outputs.updated_short_sha }}
permissions:
contents: write
jobs:
update-version:
runs-on: ubuntu-latest
outputs:
updated_sha: ${{ steps.resolve-tag.outputs.updated_sha }}
updated_short_sha: ${{ steps.resolve-tag.outputs.updated_short_sha }}
env:
TAG_VERSION: ${{ github.event.release.tag_name }}
TAG_VERSION: ${{ inputs.tag || github.event.inputs.tag }}
TARGET_BRANCH: ${{ inputs.target_branch || github.event.inputs.target_branch }}
steps:
# Step 1: Checkout the original repository's code
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v7.0.0
with:
ref: ${{ inputs.target_branch || github.event.inputs.target_branch }}
fetch-depth: 0
# submodules: "recursive"
- name: Validate target branch
run: |
set -euo pipefail
if [[ -z "${TARGET_BRANCH}" ]]; then
echo "target_branch is required"
exit 1
fi
if ! git ls-remote --exit-code --heads origin "${TARGET_BRANCH}" >/dev/null; then
echo "target_branch must be an existing branch: ${TARGET_BRANCH}"
exit 1
fi
git checkout -B "${TARGET_BRANCH}" "origin/${TARGET_BRANCH}"
- name: Safe submodule initialization
run: |
echo "Checking for submodules..."
@ -48,7 +92,6 @@ jobs:
run: |
if git rev-parse ${{ env.TAG_VERSION }} >/dev/null 2>&1; then
git tag -d ${{ env.TAG_VERSION }}
git push --delete origin ${{ env.TAG_VERSION }}
fi
# Step 4: Update version file
@ -62,58 +105,26 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
git add version/version
git commit -m "Update version to ${{ env.TAG_VERSION }}"
if git diff --cached --quiet; then
echo "version/version already matches ${TAG_VERSION}"
else
git commit -m "Update version to ${{ env.TAG_VERSION }}"
git push origin HEAD:${TARGET_BRANCH}
fi
# Step 6: Update tag
- name: Update tag
run: |
set -euo pipefail
git tag -fa ${{ env.TAG_VERSION }} -m "Update version to ${{ env.TAG_VERSION }}"
git push origin ${{ env.TAG_VERSION }} --force
git push origin refs/tags/${{ env.TAG_VERSION }}:refs/tags/${{ env.TAG_VERSION }} --force
# Step 7: Find and Publish Draft Release
- name: Find and Publish Draft Release
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { owner, repo } = context.repo;
const tagName = process.env.TAG_VERSION;
- name: Resolve updated tag SHA
id: resolve-tag
run: |
updated_sha="$(git rev-parse "${TAG_VERSION}^{commit}")"
echo "updated_sha=$updated_sha" >> "$GITHUB_OUTPUT"
echo "updated_short_sha=${updated_sha:0:12}" >> "$GITHUB_OUTPUT"
try {
let release;
try {
const response = await github.rest.repos.getReleaseByTag({
owner,
repo,
tag: tagName
});
release = response.data;
} catch (tagError) {
core.info(`Release not found by tag, searching all releases...`);
const releases = await github.rest.repos.listReleases({
owner,
repo,
per_page: 100
});
release = releases.data.find(r => r.draft && r.tag_name === tagName);
if (!release) {
throw new Error(`No release found with tag ${tagName}`);
}
}
await github.rest.repos.updateRelease({
owner,
repo,
release_id: release.id,
draft: false,
prerelease: release.prerelease
});
const status = release.draft ? "was draft" : "was already published";
core.info(`Release ${tagName} ensured to be published (${status}).`);
} catch (error) {
core.warning(`Could not find or update release for tag ${tagName}: ${error.message}`);
}

View File

@ -11,11 +11,11 @@ jobs:
check_for_first_interaction:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/first-interaction@v1.3.0
- uses: actions/checkout@v7.0.0
- uses: actions/first-interaction@v3.1.0
with:
repo-token: ${{ secrets.BOT_TOKEN }}
pr-message: |
repo_token: ${{ secrets.BOT_TOKEN }}
pr_message: |
Hello! Thank you for your contribution.
If you are fixing a bug, please reference the issue number in the description.
@ -26,7 +26,7 @@ jobs:
Please leave your information in the [✨ discussions](https://github.com/orgs/OpenIMSDK/discussions/426), we expect anyone to join OpenIM developer community.
issue-message: |
issue_message: |
Hello! Thank you for filing an issue.
If this is a bug report, please include relevant logs to help us debug the problem.

5
.gitignore vendored
View File

@ -387,4 +387,7 @@ Sessionx.vim
# End of https://www.toptal.com/developers/gitignore/api/go,git,vim,tags,test,emacs,backup,jetbrains
.idea
dist/
dist/
.omo
.sisyphus

View File

@ -1,70 +1,285 @@
## [v3.8.3-patch.6](https://github.com/openimsdk/open-im-server/releases/tag/v3.8.3-patch.6) (2025-07-23)
### Bug Fixes
* fix: Add friend DB in notification sender [#3438](https://github.com/openimsdk/open-im-server/pull/3438)
* fix: remove update version file workflows have new line in 3.8.3-patch branch. [#3452](https://github.com/openimsdk/open-im-server/pull/3452)
* fix: s3 aws init [#3454](https://github.com/openimsdk/open-im-server/pull/3454)
* fix: use safe submodule init in workflows in v3.8.3-patch. [#3469](https://github.com/openimsdk/open-im-server/pull/3469)
**Full Changelog**: [v3.8.3-patch.5...v3.8.3-patch.6](https://github.com/openimsdk/open-im-server/compare/v3.8.3-patch.5...v3.8.3-patch.6)
## [v3.8.3-patch.5](https://github.com/openimsdk/open-im-server/releases/tag/v3.8.3-patch.5) (2025-06-10)
## [v3.8.3-patch.16](https://github.com/openimsdk/open-im-server/releases/tag/v3.8.3-patch.16) (2026-03-19)
### New Features
* feat: optimize friend and group applications [#3396](https://github.com/openimsdk/open-im-server/pull/3396)
* feat: provide the interface required [#2712](https://github.com/openimsdk/open-im-server/pull/2712)
* feat: add webhooks of online status and remove zookeeper configuration. [#2716](https://github.com/openimsdk/open-im-server/pull/2716)
* feat: Add More Multi Login Policy [#2770](https://github.com/openimsdk/open-im-server/pull/2770)
* feat: Push configuration can ignore case sensitivity [#2775](https://github.com/openimsdk/open-im-server/pull/2775)
* feat: support app update service [#2794](https://github.com/openimsdk/open-im-server/pull/2794)
* feat: implement merge milestone PR to target-branch. [#2796](https://github.com/openimsdk/open-im-server/pull/2796)
* feat: support app update service [#2811](https://github.com/openimsdk/open-im-server/pull/2811)
* feat: ApplicationVersion move chat [#2813](https://github.com/openimsdk/open-im-server/pull/2813)
* feat: Update login policy [#2822](https://github.com/openimsdk/open-im-server/pull/2822)
* feat: support stream message [#2824](https://github.com/openimsdk/open-im-server/pull/2824)
* feat: merge js sdk [#2856](https://github.com/openimsdk/open-im-server/pull/2856)
* feat: Print Panic Log [#2850](https://github.com/openimsdk/open-im-server/pull/2850)
* feat: seq user and conversation seq synchronization [#2924](https://github.com/openimsdk/open-im-server/pull/2924)
* feat: support aws [#2938](https://github.com/openimsdk/open-im-server/pull/2938)
* feat: Prometheus can auto set port [#2943](https://github.com/openimsdk/open-im-server/pull/2943)
* feat: Change upload logs systemType to AppFramework. [#2927](https://github.com/openimsdk/open-im-server/pull/2927)
* feat: support quote ContentType in SendMsg. [#2819](https://github.com/openimsdk/open-im-server/pull/2819)
* feat: Group Monitoring Components, Enable Host Mode && Deprecate reliabilityLevel and unreadCount in notification.yml [#2975](https://github.com/openimsdk/open-im-server/pull/2975)
* feat: Add node_exporter in docker-compose [#2979](https://github.com/openimsdk/open-im-server/pull/2979)
* feat: Optimize Scheduled Task [#2985](https://github.com/openimsdk/open-im-server/pull/2985)
* feat: Optimizing RPC call [#2993](https://github.com/openimsdk/open-im-server/pull/2993)
* feat: optimize error stack information [#2995](https://github.com/openimsdk/open-im-server/pull/2995)
* feat: config center [#2997](https://github.com/openimsdk/open-im-server/pull/2997)
* feat: support message cache [#3007](https://github.com/openimsdk/open-im-server/pull/3007)
* feat: optimize log output [#3026](https://github.com/openimsdk/open-im-server/pull/3026)
* feat: support GetLastMessage [#3029](https://github.com/openimsdk/open-im-server/pull/3029)
* feat: Add enable config center button && fix: grpc connection leakage [#3036](https://github.com/openimsdk/open-im-server/pull/3036)
* feat: change appNotificationAccount to appManagerAccount && fix: enable config center add env check && fix: error return [#3038](https://github.com/openimsdk/open-im-server/pull/3038)
* feat: SendBusinessNotification supported configuration parameters [#3048](https://github.com/openimsdk/open-im-server/pull/3048)
* feat: add backup volume && optimize log print [#3066](https://github.com/openimsdk/open-im-server/pull/3066)
* feat: optimize code and support running in single process mode [#3142](https://github.com/openimsdk/open-im-server/pull/3142)
* feat: Change after webhook filter && feat SendSimpleMsg [#3151](https://github.com/openimsdk/open-im-server/pull/3151)
* feat: the default notification.yml is not configured properly [#3168](https://github.com/openimsdk/open-im-server/pull/3168)
* feat: add a new message type: Markdown text [#3162](https://github.com/openimsdk/open-im-server/pull/3162)
* feat: add a field to specify whether to send a notification message w… [#3163](https://github.com/openimsdk/open-im-server/pull/3163)
* feat: optimizing BatchGetIncrementalGroupMember [#3180](https://github.com/openimsdk/open-im-server/pull/3180)
* feat: system account send msg doesn't need friend verify [#3187](https://github.com/openimsdk/open-im-server/pull/3187)
* feat: sending messages supports returning fields modified [#3192](https://github.com/openimsdk/open-im-server/pull/3192)
* feat: set configs api [#3183](https://github.com/openimsdk/open-im-server/pull/3183)
* feat: check if the secret in config/share.yml has been changed during registration [#3223](https://github.com/openimsdk/open-im-server/pull/3223)
* feat: Implement webhook in createConversation [#3228](https://github.com/openimsdk/open-im-server/pull/3228)
* feat: add a function for business info change to update related conve… [#3225](https://github.com/openimsdk/open-im-server/pull/3225)
* feat: add filtering for invalid messages and invalid conversations to… [#3239](https://github.com/openimsdk/open-im-server/pull/3239)
* feat: implement stress-test tools. [#3261](https://github.com/openimsdk/open-im-server/pull/3261)
* feat: support server-issued configuration, which can be set for individual users [#3271](https://github.com/openimsdk/open-im-server/pull/3271)
* feat: GetConversationsHasReadAndMaxSeq support pinned [#3281](https://github.com/openimsdk/open-im-server/pull/3281)
* feat: Implement stress test v2. [#3292](https://github.com/openimsdk/open-im-server/pull/3292)
* feat: GroupApplicationAgreeMemberEnterNotification splitting [#3297](https://github.com/openimsdk/open-im-server/pull/3297)
* feat: optimize server code [#3319](https://github.com/openimsdk/open-im-server/pull/3319)
* feat: add rpc interface permission check [#3366](https://github.com/openimsdk/open-im-server/pull/3366)
* feat: optimize friend and group applications [#3384](https://github.com/openimsdk/open-im-server/pull/3384)
* feat: support distributed lock in crontask. [#3401](https://github.com/openimsdk/open-im-server/pull/3401)
* feat: Implement etcd and kafka auth. [#3394](https://github.com/openimsdk/open-im-server/pull/3394)
* feat: support redis sentinel. [#3423](https://github.com/openimsdk/open-im-server/pull/3423)
* feat: add api logger [#3427](https://github.com/openimsdk/open-im-server/pull/3427)
* feat: add nickname for adminUser [#3435](https://github.com/openimsdk/open-im-server/pull/3435)
* feat: support mongo replicaset mode. [#3433](https://github.com/openimsdk/open-im-server/pull/3433)
* feat: enable redis aof-use-rdb-preamble && disable auto rdb [#3529](https://github.com/openimsdk/open-im-server/pull/3529)
* feat: implement auth local cache. [#3533](https://github.com/openimsdk/open-im-server/pull/3533)
* feat: add msgDBSave webhook when data save to DB. [#3578](https://github.com/openimsdk/open-im-server/pull/3578)
* feat: implement DeleteConversations interface. [#3549](https://github.com/openimsdk/open-im-server/pull/3549)
* feat: replace LongConn with ClientConn interface and simplify message handling [#3643](https://github.com/openimsdk/open-im-server/pull/3643)
* feat: add error code for handled friend requests and improve error handling in friend operations [#3670](https://github.com/openimsdk/open-im-server/pull/3670)
* feat: update protocol support botPlatform [#3696](https://github.com/openimsdk/open-im-server/pull/3696)
* feat: gomake upgrade [#3702](https://github.com/openimsdk/open-im-server/pull/3702)
### Bug Fixes
* fix: solve unocrrect invite notification [Created [#3219](https://github.com/openimsdk/open-im-server/pull/3219)
* fix: the message I sent is not set to read seq in mongodb [#2718](https://github.com/openimsdk/open-im-server/pull/2718)
* fix: cannot modify group member avatars [#2719](https://github.com/openimsdk/open-im-server/pull/2719)
* fix: auth package import twice [#2724](https://github.com/openimsdk/open-im-server/pull/2724)
* fix: join the group chat directly, notification type error [#2772](https://github.com/openimsdk/open-im-server/pull/2772)
* fix: change update group member level logic [#2730](https://github.com/openimsdk/open-im-server/pull/2730)
* fix: joinSource check args error. [#2773](https://github.com/openimsdk/open-im-server/pull/2773)
* fix: Change group member roleLevel can`t send notification [#2777](https://github.com/openimsdk/open-im-server/pull/2777)
* fix: client sends message status error to server [#2779](https://github.com/openimsdk/open-im-server/pull/2779)
* fix: del UserB's conversation version cache when userA set conversati… [#2785](https://github.com/openimsdk/open-im-server/pull/2785)
* fix: improve setConversationAtInfo logic. [#2782](https://github.com/openimsdk/open-im-server/pull/2782)
* fix: improve transfer Owner logic when newOwner is mute. [#2790](https://github.com/openimsdk/open-im-server/pull/2790)
* fix: improve getUserInfo logic. [#2792](https://github.com/openimsdk/open-im-server/pull/2792)
* fix: improve time condition check mehtod. [#2804](https://github.com/openimsdk/open-im-server/pull/2804)
* fix: webhook before online push [#2805](https://github.com/openimsdk/open-im-server/pull/2805)
* fix: set own read seq in MongoDB when sender send a message. [#2808](https://github.com/openimsdk/open-im-server/pull/2808)
* fix: solve err Notification when setGroupInfo. [#2806](https://github.com/openimsdk/open-im-server/pull/2806)
* fix: improve condition check. [#2815](https://github.com/openimsdk/open-im-server/pull/2815)
* fix: Write back message to Redis [#2836](https://github.com/openimsdk/open-im-server/pull/2836)
* fix: get group return repeated result [#2842](https://github.com/openimsdk/open-im-server/pull/2842)
* fix: SetConversations can update new conversation [#2838](https://github.com/openimsdk/open-im-server/pull/2838)
* fix(push): push content with jpush [#2844](https://github.com/openimsdk/open-im-server/pull/2844)
* fix #2860 migrate jpns to jpush [#2861](https://github.com/openimsdk/open-im-server/pull/2861)
* fix: concurrent write to websocket connection [#2866](https://github.com/openimsdk/open-im-server/pull/2866)
* fix: Remove admin token in redis [#2871](https://github.com/openimsdk/open-im-server/pull/2871)
* Fix Push2User webhookBeforeOfflinePush [#2862](https://github.com/openimsdk/open-im-server/pull/2862)
* fix: move workflow to correct path [#2837](https://github.com/openimsdk/open-im-server/pull/2837)
* fix: del login Policy [#2825](https://github.com/openimsdk/open-im-server/pull/2825)
* fix: Wrong Redis Error Check [#2876](https://github.com/openimsdk/open-im-server/pull/2876)
* fix: minor log typo [#2881](https://github.com/openimsdk/open-im-server/pull/2881)
* fix: webhookAfterSingleMsgRead will be called correctly [#2884](https://github.com/openimsdk/open-im-server/pull/2884)
* fix: webhookBeforeSendSingleMsg will call before black and friend check [#2885](https://github.com/openimsdk/open-im-server/pull/2885)
* fix: Wrong Redis Error Check [#2891](https://github.com/openimsdk/open-im-server/pull/2891)
* fix: improve crontask delete outdated Data. [#2901](https://github.com/openimsdk/open-im-server/pull/2901)
* fix: go mod [#2906](https://github.com/openimsdk/open-im-server/pull/2906)
* fix: group member update face_url [#2910](https://github.com/openimsdk/open-im-server/pull/2910)
* fix: update set seq implement. [#2911](https://github.com/openimsdk/open-im-server/pull/2911)
* fix https://github.com/openimsdk/open-im-server/issues/2895 [#2896](https://github.com/openimsdk/open-im-server/pull/2896)
* fix: Can choose whether to set the port. [#2929](https://github.com/openimsdk/open-im-server/pull/2929)
* fix: Configure move service discovery into discovery [#2934](https://github.com/openimsdk/open-im-server/pull/2934)
* fix: compilation failed under Windows [#2940](https://github.com/openimsdk/open-im-server/pull/2940)
* fix: server can return isEnd to control fetch messages when sdk pull … [#2949](https://github.com/openimsdk/open-im-server/pull/2949)
* fix:Only print panic function frame && feat: log.ZPanic [#2947](https://github.com/openimsdk/open-im-server/pull/2947)
* fix: seq user and conversation seq synchronization [#2958](https://github.com/openimsdk/open-im-server/pull/2958)
* fix: fetch message return isEnd and endSeq panic. [#2959](https://github.com/openimsdk/open-im-server/pull/2959)
* fix: rpc panic recover [#2957](https://github.com/openimsdk/open-im-server/pull/2957)
* fix: modifying other fields while setting IsPrivateChat does not take effect [#2972](https://github.com/openimsdk/open-im-server/pull/2972)
* fix: when fetching a referenced message, it indicates that the original message has been deleted. [#2977](https://github.com/openimsdk/open-im-server/pull/2977)
* fix: when unable EnableHistoryForNewMembers, new group member can read last one message. [#3001](https://github.com/openimsdk/open-im-server/pull/3001)
* fix: redis save error when KickTokens [#3002](https://github.com/openimsdk/open-im-server/pull/3002)
* fix: The message @ information will be set only for members in the gr… [#3009](https://github.com/openimsdk/open-im-server/pull/3009)
* fix: restart permission check [#3011](https://github.com/openimsdk/open-im-server/pull/3011)
* fix: The system cannot be restarted the first time the configuration is set. [#3013](https://github.com/openimsdk/open-im-server/pull/3013)
* fix: jssdk not init [#3016](https://github.com/openimsdk/open-im-server/pull/3016)
* fix: online status error [#3022](https://github.com/openimsdk/open-im-server/pull/3022)
* fix: GetUsersOnline returns an error in the online list [#3040](https://github.com/openimsdk/open-im-server/pull/3040)
* fix: seq conversion failed without exiting [#3052](https://github.com/openimsdk/open-im-server/pull/3052)
* fix: check error in BatchSetTokenMapByUidPid [#3076](https://github.com/openimsdk/open-im-server/pull/3076)
* fix: DeleteDoc crash [#3078](https://github.com/openimsdk/open-im-server/pull/3078)
* fix: the abnormal message has no sending time, causing the SDK to be abnormal [#3087](https://github.com/openimsdk/open-im-server/pull/3087)
* fix: crash caused [#3100](https://github.com/openimsdk/open-im-server/pull/3100)
* fix: the user sets the conversation timer cleanup timestamp unit incorrectly [#3102](https://github.com/openimsdk/open-im-server/pull/3102)
* fix: solve workflows stop when merge failed [#3106](https://github.com/openimsdk/open-im-server/pull/3106)
* fix: seq conversion not reading env in docker environment [#3130](https://github.com/openimsdk/open-im-server/pull/3130)
* fix: the source message of the reference is withdrawn, and the referenced message is deleted [#3137](https://github.com/openimsdk/open-im-server/pull/3137)
* fix: Offline push does not have a badge && Android offline push [#3146](https://github.com/openimsdk/open-im-server/pull/3146)
* fix: PCAndOther multi login policy can`t get old clients correctly [#3158](https://github.com/openimsdk/open-im-server/pull/3158)
* fix: solve uncorrect notification when set group info [#3172](https://github.com/openimsdk/open-im-server/pull/3172)
* fix: the sorting is wrong after canceling the administrator in group settings [#3185](https://github.com/openimsdk/open-im-server/pull/3185)
* fix: solve uncorrect GroupMember enter group notification type. [#3188](https://github.com/openimsdk/open-im-server/pull/3188)
* fix: solve unocrrect invite notification [#3213](https://github.com/openimsdk/open-im-server/pull/3213)
* fix: AdminToken save to redis && limit 1 for each userID [#3224](https://github.com/openimsdk/open-im-server/pull/3224)
* fix: improve stress test tools parms. [#3265](https://github.com/openimsdk/open-im-server/pull/3265)
* fix: oss specifies content-type when uploading [#3267](https://github.com/openimsdk/open-im-server/pull/3267)
* fix: transferring the group owner to a muted member, incremental version error [#3284](https://github.com/openimsdk/open-im-server/pull/3284)
* fix: group status in GroupDismissedNotification [#3286](https://github.com/openimsdk/open-im-server/pull/3286)
* fix: data version SetVersion will add record [#3304](https://github.com/openimsdk/open-im-server/pull/3304)
* fix: delete token [#3313](https://github.com/openimsdk/open-im-server/pull/3313)
* fix: optimize grpc option and fix some interface permission checks [#3327](https://github.com/openimsdk/open-im-server/pull/3327)
* fix: standalone mode cannot be used [#3360](https://github.com/openimsdk/open-im-server/pull/3360)
* fix: solve user not found when notification invitedUserID is zero in … [#3375](https://github.com/openimsdk/open-im-server/pull/3375)
* fix: send simple msg [#3362](https://github.com/openimsdk/open-im-server/pull/3362)
* fix: solve updateUserInfoEx null pointer. [#3326](https://github.com/openimsdk/open-im-server/pull/3326)
* fix: add rpc interface permission check [#3377](https://github.com/openimsdk/open-im-server/pull/3377)
* fix: optimize friend and group applications [#3389](https://github.com/openimsdk/open-im-server/pull/3389)
* fix redis config db field [#3395](https://github.com/openimsdk/open-im-server/pull/3395)
* fix: prometheus discovery [#3408](https://github.com/openimsdk/open-im-server/pull/3408)
* fix: import friends send notification [#3420](https://github.com/openimsdk/open-im-server/pull/3420)
* fix: improve mileston PR workflows contents. [#3382](https://github.com/openimsdk/open-im-server/pull/3382)
* fix: solve webhook incorrect attentionID references. [#3411](https://github.com/openimsdk/open-im-server/pull/3411)
* fix: solve `createTime` not set in setConversation and Create Conversation. [#3447](https://github.com/openimsdk/open-im-server/pull/3447)
* fix: update log level in crontask dist look. [#3440](https://github.com/openimsdk/open-im-server/pull/3440)
* fix: use safe submodule init in workflows. [#3468](https://github.com/openimsdk/open-im-server/pull/3468)
* fix: fix incorrect kicked logic. [#3480](https://github.com/openimsdk/open-im-server/pull/3480)
* fix: added AtUserIDList to the @ message for API sending. [#3472](https://github.com/openimsdk/open-im-server/pull/3472)
* fix: solve batch incorrect error in Find DocIDs [#3476](https://github.com/openimsdk/open-im-server/pull/3476)
* fix: correctly aggregate read seqs [#3442](https://github.com/openimsdk/open-im-server/pull/3442)
* fix: performance issues with Kafka caused [#3485](https://github.com/openimsdk/open-im-server/pull/3485)
* fix: searchMessage method has potential NPE bug [Created [#3289](https://github.com/openimsdk/open-im-server/pull/3289)
* fix: admin token in standalone mode [#3499](https://github.com/openimsdk/open-im-server/pull/3499)
* fix: revert contentType in API msg [#3509](https://github.com/openimsdk/open-im-server/pull/3509)
* fix: optimize to lru local cache. [#3514](https://github.com/openimsdk/open-im-server/pull/3514)
* fix: fill in the most recent sendTime for a gap message to prevent th… [#3522](https://github.com/openimsdk/open-im-server/pull/3522)
* fix: solve incorrect batchGetIncrGroupMember when group dismissed. [#3526](https://github.com/openimsdk/open-im-server/pull/3526)
* fix: GetSortedConversationList nil pointer when chatlog not found. [#3531](https://github.com/openimsdk/open-im-server/pull/3531)
* fix: switch kafka & etcd image namespace to bitnamilegacy [#3555](https://github.com/openimsdk/open-im-server/pull/3555)
* fix: solve incorrect time.Unix and logger asyncwrite [#3584](https://github.com/openimsdk/open-im-server/pull/3584)
* fix: db manager [#3600](https://github.com/openimsdk/open-im-server/pull/3600)
* fix: update JSON field names to camelCase in conversation structs [#3609](https://github.com/openimsdk/open-im-server/pull/3609)
* Fix: Resolved the issue of incorrect generation of conversationID [#3581](https://github.com/openimsdk/open-im-server/pull/3581)
* fix: solve msg wsHandler panic. [#3595](https://github.com/openimsdk/open-im-server/pull/3595)
* fix: resolve deadlock in cache eviction and improve GetBatch implementation and full id version [#3591](https://github.com/openimsdk/open-im-server/pull/3591)
* fix: reset user conversation seq when rejoining group to resolve message recall issue [#3640](https://github.com/openimsdk/open-im-server/pull/3640)
* fix(group): move member count retrieval after member deletion for accurate updates [#3651](https://github.com/openimsdk/open-im-server/pull/3651)
* fix(group): set max_seq to 0 when join group [#3649](https://github.com/openimsdk/open-im-server/pull/3649)
* fix: Mongo Malloc upsert overwrites min_seq initialization [#3657](https://github.com/openimsdk/open-im-server/pull/3657)
### Builds
* build: update gomake version in dockerfile.[Patch branch] [#3416](https://github.com/openimsdk/open-im-server/pull/3416)
**Full Changelog**: [v3.8.3...v3.8.3-patch.5](https://github.com/openimsdk/open-im-server/compare/v3.8.3...v3.8.3-patch.5)
## [v3.8.3-patch.4](https://github.com/openimsdk/open-im-server/releases/tag/v3.8.3-patch.4) (2025-03-13)
### Bug Fixes
* fix: solve unocrrect invite notificationfrom #3213
**Full Changelog**: [v3.8.3-patch.3...v3.8.3-patch.4](https://github.com/openimsdk/open-im-server/compare/v3.8.3-patch.3...v3.8.3-patch.4)
## [v3.8.3-patch.3](https://github.com/openimsdk/open-im-server/releases/tag/v3.8.3-patch.3) (2025-03-07)
### New Features
* feat: optimizing BatchGetIncrementalGroupMember #3180
### Bug Fixes
* fix: solve uncorrect notification when set group info #3172
* fix: the sorting is wrong after canceling the administrator in group settings #3185
* fix: solve uncorrect GroupMember enter group notification type. #3188
### Chores
* chore: remove unused content [#2786](https://github.com/openimsdk/open-im-server/pull/2786)
* chore: update admin front image version [#2893](https://github.com/openimsdk/open-im-server/pull/2893)
### Refactors
* refactor: change sendNotification to sendMessage to avoid ambiguity regarding message sending behavior. #3173
**Full Changelog**: [v3.8.3-patch.2...v3.8.3-patch.3](https://github.com/openimsdk/open-im-server/compare/v3.8.3-patch.2...v3.8.3-patch.3)
## [v3.8.3-patch.2](https://github.com/openimsdk/open-im-server/releases/tag/v3.8.3-patch.2) (2025-02-28)
### Bug Fixes
* fix: Offline push does not have a badge && Android offline push (#3146) [#3174](https://github.com/openimsdk/open-im-server/pull/3174)
**Full Changelog**: [v3.8.3-patch.1...v3.8.3-patch.2](https://github.com/openimsdk/open-im-server/compare/v3.8.3-patch.1...v3.8.3-patch.2)
## [v3.8.3-patch.1](https://github.com/openimsdk/open-im-server/releases/tag/v3.8.3-patch.1) (2025-02-25)
### New Features
* feat: add backup volume && optimize log print [Created [#3121](https://github.com/openimsdk/open-im-server/pull/3121)
### Bug Fixes
* fix: seq conversion failed without exiting [Created [#3120](https://github.com/openimsdk/open-im-server/pull/3120)
* fix: check error in BatchSetTokenMapByUidPid [Created [#3123](https://github.com/openimsdk/open-im-server/pull/3123)
* fix: DeleteDoc crash [Created [#3124](https://github.com/openimsdk/open-im-server/pull/3124)
* fix: the abnormal message has no sending time, causing the SDK to be abnormal [Created [#3126](https://github.com/openimsdk/open-im-server/pull/3126)
* fix: crash caused [#3127](https://github.com/openimsdk/open-im-server/pull/3127)
* fix: the user sets the conversation timer cleanup timestamp unit incorrectly [Created [#3128](https://github.com/openimsdk/open-im-server/pull/3128)
* fix: seq conversion not reading env in docker environment [Created [#3131](https://github.com/openimsdk/open-im-server/pull/3131)
* refactor: Refactor rpc call && auto gen rpc_call code [#2969](https://github.com/openimsdk/open-im-server/pull/2969)
* refactor: improve workflows logic. [#3072](https://github.com/openimsdk/open-im-server/pull/3072)
* refactor: change sendNotification to sendMessage to avoid ambiguity regarding message sending behavior. [#3173](https://github.com/openimsdk/open-im-server/pull/3173)
* refactor: improve setConversations method. [#3194](https://github.com/openimsdk/open-im-server/pull/3194)
* refactor: move stress-test tools location. [#3295](https://github.com/openimsdk/open-im-server/pull/3295)
* refactor: support modified config and args in mage. [#3466](https://github.com/openimsdk/open-im-server/pull/3466)
### Builds
* build: improve workflows contents. [Created [#3125](https://github.com/openimsdk/open-im-server/pull/3125)
* build: improve workflows logic. [#2801](https://github.com/openimsdk/open-im-server/pull/2801)
* build: implement version file update when release. [#2826](https://github.com/openimsdk/open-im-server/pull/2826)
* build: update mongo and kafka start logic. [#2858](https://github.com/openimsdk/open-im-server/pull/2858)
* build: create changelog tool and workflows. [#2869](https://github.com/openimsdk/open-im-server/pull/2869)
* build(deps): bump github.com/golang-jwt/jwt/v4 from 4.5.0 to 4.5.1 [#2851](https://github.com/openimsdk/open-im-server/pull/2851)
* build: update Server version. [#2887](https://github.com/openimsdk/open-im-server/pull/2887)
* build: implement services image build and CI release. [#2920](https://github.com/openimsdk/open-im-server/pull/2920)
* build: update kubernetes deployment Run. [#2919](https://github.com/openimsdk/open-im-server/pull/2919)
* build: fix uncorrect path. [#3020](https://github.com/openimsdk/open-im-server/pull/3020)
* build: fix docker images build. [#3024](https://github.com/openimsdk/open-im-server/pull/3024)
* build: keep conflict is true. [#3103](https://github.com/openimsdk/open-im-server/pull/3103)
* build: comment out admin services. [#3537](https://github.com/openimsdk/open-im-server/pull/3537)
* build: improve publish docker image workflow. [#3552](https://github.com/openimsdk/open-im-server/pull/3552)
* build: add sdk version log in registerClient [#3574](https://github.com/openimsdk/open-im-server/pull/3574)
**Full Changelog**: [v3.8.3-e-v1.1.5...v3.8.3-patch.1-e-v1.1.5](https://github.com/openimsdk/open-im-server-enterprise/compare/v3.8.3-e-v1.1.5...v3.8.3-patch.1-e-v1.1.5)
### Others
* Revert: Change group member roleLevel can`t send notification [#2789](https://github.com/openimsdk/open-im-server/pull/2789)
* Introducing OpenIM Guru on Gurubase.io [#2788](https://github.com/openimsdk/open-im-server/pull/2788)
* revert: write msg to redis [#2883](https://github.com/openimsdk/open-im-server/pull/2883)
* Add a lead time for the token's issuance time. [#2914](https://github.com/openimsdk/open-im-server/pull/2914)
* docs: improve deployment docs in kubernetes. [#2973](https://github.com/openimsdk/open-im-server/pull/2973)
* update: env image version [#3055](https://github.com/openimsdk/open-im-server/pull/3055)
* License [#3293](https://github.com/openimsdk/open-im-server/pull/3293)
* docs: update slack link. [#3479](https://github.com/openimsdk/open-im-server/pull/3479)
* Update CHANGELOG for release v3.8.3-patch.1 [#3164](https://github.com/openimsdk/open-im-server/pull/3164)
* Update CHANGELOG for release v3.8.3-patch.2 [#3175](https://github.com/openimsdk/open-im-server/pull/3175)
* Update CHANGELOG for release v3.8.3-patch.3 [#3206](https://github.com/openimsdk/open-im-server/pull/3206)
* Update CHANGELOG for release v3.8.3-patch.4 [#3226](https://github.com/openimsdk/open-im-server/pull/3226)
* Update CHANGELOG for release v3.8.3-patch.5 [#3405](https://github.com/openimsdk/open-im-server/pull/3405)
* Update CHANGELOG for release v3.8.3-patch.6 [#3473](https://github.com/openimsdk/open-im-server/pull/3473)
* docs: update readme of config file. [#3356](https://github.com/openimsdk/open-im-server/pull/3356)
* ​Build: Implement rate limiting and circuit breaker for API and RPC services.​​ [#3572](https://github.com/openimsdk/open-im-server/pull/3572)
* merge: pre-release-v3.8.4 [#3623](https://github.com/openimsdk/open-im-server/pull/3623)
* Simplify iOS background push gating (#3611) [#3612](https://github.com/openimsdk/open-im-server/pull/3612)
* bugfix(conversation):removed unexpectedly called functions and itself… [#3668](https://github.com/openimsdk/open-im-server/pull/3668)
* @lkzz made their first contribution in https://github.com/openimsdk/open-im-server/pull/2724 [#2724](https://github.com/openimsdk/open-im-server/pull/2724)
* @alilestera made their first contribution in https://github.com/openimsdk/open-im-server/pull/2773 [#2773](https://github.com/openimsdk/open-im-server/pull/2773)
* @kursataktas made their first contribution in https://github.com/openimsdk/open-im-server/pull/2788 [#2788](https://github.com/openimsdk/open-im-server/pull/2788)
* @yoyo930021 made their first contribution in https://github.com/openimsdk/open-im-server/pull/2844 [#2844](https://github.com/openimsdk/open-im-server/pull/2844)
* @wikylyu made their first contribution in https://github.com/openimsdk/open-im-server/pull/2861 [#2861](https://github.com/openimsdk/open-im-server/pull/2861)
* @storyn26383 made their first contribution in https://github.com/openimsdk/open-im-server/pull/2862 [#2862](https://github.com/openimsdk/open-im-server/pull/2862)
* @morya made their first contribution in https://github.com/openimsdk/open-im-server/pull/2881 [#2881](https://github.com/openimsdk/open-im-server/pull/2881)
* @HonQii made their first contribution in https://github.com/openimsdk/open-im-server/pull/3395 [#3395](https://github.com/openimsdk/open-im-server/pull/3395)
* @github-actions[bot] made their first contribution in https://github.com/openimsdk/open-im-server/pull/3164 [#3164](https://github.com/openimsdk/open-im-server/pull/3164)
* @xuzhijvn made their first contribution in https://github.com/openimsdk/open-im-server/pull/3289 [#3289](https://github.com/openimsdk/open-im-server/pull/3289)
* @ozudev made their first contribution in https://github.com/openimsdk/open-im-server/pull/3612 [#3612](https://github.com/openimsdk/open-im-server/pull/3612)
**Full Changelog**: [v3.8.3-patch.15...v3.8.3-patch.16](https://github.com/openimsdk/open-im-server/compare/v3.8.3-patch.15...v3.8.3-patch.16)
## [v3.8.3-patch.12](https://github.com/openimsdk/open-im-server/releases/tag/v3.8.3-patch.12) (2025-10-24)
### Bug Fixes
* fix: full id version [#3589](https://github.com/openimsdk/open-im-server/pull/3589)
* fix: incorrect redis fields. [#3602](https://github.com/openimsdk/open-im-server/pull/3602)
**Full Changelog**: [v3.8.3-patch.11...v3.8.3-patch.12](https://github.com/openimsdk/open-im-server/compare/v3.8.3-patch.11...v3.8.3-patch.12)
## [v3.8.3-patch.9](https://github.com/openimsdk/open-im-server/releases/tag/v3.8.3-patch.9) (2025-08-19)
### New Features
* feat: enable redis aof-use-rdb-preamble && disable auto rdb [Created [#3535](https://github.com/openimsdk/open-im-server/pull/3535)
### Bug Fixes
* fix: fill in the most recent sendTime for a gap message to prevent th… [#3523](https://github.com/openimsdk/open-im-server/pull/3523)
**Full Changelog**: [v3.8.3-patch.8...v3.8.3-patch.9](https://github.com/openimsdk/open-im-server/compare/v3.8.3-patch.8...v3.8.3-patch.9)
## [v3.8.3-patch.8](https://github.com/openimsdk/open-im-server/releases/tag/v3.8.3-patch.8) (2025-08-13)
### Bug Fixes
* fix: fix incorrect kicked logic and PCAndOther Login policy In v3.8.3-patch [#3511](https://github.com/openimsdk/open-im-server/pull/3511)
* fix: solve batch incorrect error in Find DocIDs in v3.8.3-patch branch. [#3515](https://github.com/openimsdk/open-im-server/pull/3515)
**Full Changelog**: [v3.8.3-patch.7...v3.8.3-patch.8](https://github.com/openimsdk/open-im-server/compare/v3.8.3-patch.7...v3.8.3-patch.8)
## [v3.8.3-patch.7](https://github.com/openimsdk/open-im-server/releases/tag/v3.8.3-patch.7) (2025-07-29)
### New Features
* feat: add filtering for invalid messages and invalid conversations to… [#3483](https://github.com/openimsdk/open-im-server/pull/3483)
### Bug Fixes
* fix: correctly aggregate read seqs [#3482](https://github.com/openimsdk/open-im-server/pull/3482)
* fix: import friends send notification in v3.8.3-patch [#3488](https://github.com/openimsdk/open-im-server/pull/3488)
* fix: solve redis config db field in v3.8.3-patch [#3490](https://github.com/openimsdk/open-im-server/pull/3490)
**Full Changelog**: [v3.8.3-patch.6...v3.8.3-patch.7](https://github.com/openimsdk/open-im-server/compare/v3.8.3-patch.6...v3.8.3-patch.7)

View File

@ -1,49 +1,25 @@
# Use Go 1.22 Alpine as the base image for building the application
FROM golang:1.22-alpine AS builder
FROM golang:alpine AS builder
# Define the base directory for the application as an environment variable
ENV SERVER_DIR=/openim-server
ARG RELEASE=false
ARG COMPRESS=false
WORKDIR /openim-server
# Set the working directory inside the container based on the environment variable
WORKDIR $SERVER_DIR
RUN apk add --no-cache upx
# Set the Go proxy to improve dependency resolution speed
# ENV GOPROXY=https://goproxy.io,direct
RUN go install github.com/magefile/mage@latest
# Copy all files from the current directory into the container
COPY . .
RUN go mod download
RUN RELEASE=${RELEASE} COMPRESS=${COMPRESS} mage build
RUN mage -compile ./mage -ldflags "-s -w"
# Install Mage to use for building the application
RUN go install github.com/magefile/mage@v1.15.0
FROM alpine:latest
# Optionally build your application if needed
RUN mage build
WORKDIR /openim-server
# Using Alpine Linux with Go environment for the final image
FROM golang:1.22-alpine
COPY --from=builder /openim-server/_output ./_output
COPY --from=builder /openim-server/config ./config
COPY --from=builder /openim-server/start-config.yml ./start-config.yml
COPY --from=builder /openim-server/mage ./mage
# Install necessary packages, such as bash
RUN apk add --no-cache bash
# Set the environment and work directory
ENV SERVER_DIR=/openim-server
WORKDIR $SERVER_DIR
# Copy the compiled binaries and mage from the builder image to the final image
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
COPY --from=builder /go/bin/mage /usr/local/bin/mage
COPY --from=builder $SERVER_DIR/magefile_windows.go $SERVER_DIR/
COPY --from=builder $SERVER_DIR/magefile_unix.go $SERVER_DIR/
COPY --from=builder $SERVER_DIR/magefile.go $SERVER_DIR/
COPY --from=builder $SERVER_DIR/start-config.yml $SERVER_DIR/
COPY --from=builder $SERVER_DIR/go.mod $SERVER_DIR/
COPY --from=builder $SERVER_DIR/go.sum $SERVER_DIR/
RUN go get github.com/openimsdk/gomake@v0.0.15-alpha.1
# Set the command to run when the container starts
ENTRYPOINT ["sh", "-c", "mage start && tail -f /dev/null"]
ENTRYPOINT ["sh", "-c", "./mage start && sleep infinity"]

129
build/build.sh Executable file
View File

@ -0,0 +1,129 @@
#!/usr/bin/env bash
set -euo pipefail
CYAN='\033[0;36m'
GREEN='\033[0;32m'
RED='\033[0;31m'
NO_COLOR='\033[0m'
BASE_DIR="$(cd "$(dirname "$0")" && pwd)"
COMPOSE_FILE="$BASE_DIR/images/openim-server/docker-compose.build.yml"
RELEASE="${RELEASE:-false}"
PUSH="${PUSH:-false}"
DRY_RUN="${DRY_RUN:-false}"
PLATFORMS="${PLATFORMS:-linux/amd64,linux/arm64}"
IMAGE_TAGS="${IMAGE_TAGS:-}"
IMAGE_REGISTRIES="${IMAGE_REGISTRIES:-}"
if [[ ! -f "$COMPOSE_FILE" ]]; then
echo -e "${RED}docker-compose.build.yml not found: $COMPOSE_FILE${NO_COLOR}"
exit 1
fi
cd "$BASE_DIR/.." || exit 1
split_values() {
echo "$1" | grep -o '[^, ]\+'
}
run_or_print() {
if [[ "$DRY_RUN" == "true" ]]; then
printf '%q ' "$@"
printf '\n'
else
"$@"
fi
}
build_local() {
echo -e "${CYAN}Building all services...${NO_COLOR}"
while IFS= read -r service; do
RELEASE="$RELEASE" docker compose -f "$COMPOSE_FILE" build "$service"
done < <(docker compose -f "$COMPOSE_FILE" config --services)
echo -e "${CYAN}Tagging compatibility images for Kubernetes...${NO_COLOR}"
while IFS= read -r built_image; do
[[ -n "$built_image" ]] || continue
compatibility_tag="${built_image##*/}"
if [[ "$built_image" != "$compatibility_tag" ]]; then
docker tag "$built_image" "$compatibility_tag"
fi
done < <(docker compose -f "$COMPOSE_FILE" config --images)
echo -e "${GREEN}Successfully built all services${NO_COLOR}"
}
build_push() {
if ! command -v jq >/dev/null 2>&1; then
echo -e "${RED}jq is required for PUSH=true${NO_COLOR}"
exit 1
fi
if [[ -z "$IMAGE_TAGS" || -z "$IMAGE_REGISTRIES" ]]; then
echo -e "${RED}IMAGE_TAGS and IMAGE_REGISTRIES are required for PUSH=true${NO_COLOR}"
exit 1
fi
image_tags=()
while IFS= read -r tag; do
image_tags+=("$tag")
done < <(split_values "$IMAGE_TAGS")
image_registries=()
while IFS= read -r registry; do
image_registries+=("$registry")
done < <(split_values "$IMAGE_REGISTRIES")
if [[ ${#image_tags[@]} -eq 0 || ${#image_registries[@]} -eq 0 ]]; then
echo -e "${RED}IMAGE_TAGS and IMAGE_REGISTRIES must contain at least one value${NO_COLOR}"
exit 1
fi
compose_config=$(docker compose -f "$COMPOSE_FILE" config --format json)
echo -e "${CYAN}Building and pushing service images...${NO_COLOR}"
while IFS= read -r service; do
context=$(jq -r --arg service "$service" '.services[$service].build.context // empty' <<< "$compose_config")
dockerfile=$(jq -r --arg service "$service" '.services[$service].build.dockerfile // empty' <<< "$compose_config")
cmd_path=$(jq -r --arg service "$service" '.services[$service].build.args.CMD_PATH // empty' <<< "$compose_config")
binary_name=$(jq -r --arg service "$service" '.services[$service].build.args.BINARY_NAME // empty' <<< "$compose_config")
if [[ -z "$context" || -z "$dockerfile" || -z "$cmd_path" || -z "$binary_name" ]]; then
echo -e "${RED}Invalid build config for $service${NO_COLOR}"
exit 1
fi
if [[ ! -d "$cmd_path" && ! -f "$cmd_path/main.go" ]]; then
echo -e "${CYAN}Skipping $service because $cmd_path does not exist${NO_COLOR}"
continue
fi
tag_args=()
for registry in "${image_registries[@]}"; do
for tag in "${image_tags[@]}"; do
tag_args+=(--tag "$registry/$binary_name:$tag")
done
done
echo -e "${CYAN}Building $binary_name for $PLATFORMS...${NO_COLOR}"
run_or_print docker buildx build \
--platform "$PLATFORMS" \
--file "$dockerfile" \
--build-arg "CMD_PATH=$cmd_path" \
--build-arg "BINARY_NAME=$binary_name" \
--build-arg "RELEASE=$RELEASE" \
"${tag_args[@]}" \
--push \
"$context"
done < <(jq -r '.services | keys[]' <<< "$compose_config" | sort)
echo -e "${GREEN}Successfully pushed service images${NO_COLOR}"
}
if [[ "$PUSH" == "true" ]]; then
build_push
else
build_local
fi

105
build/build_single.sh Executable file
View File

@ -0,0 +1,105 @@
#!/usr/bin/env bash
set -euo pipefail
CYAN='\033[0;36m'
GREEN='\033[0;32m'
RED='\033[0;31m'
NO_COLOR='\033[0m'
BASE_DIR="$(cd "$(dirname "$0")" && pwd)"
COMPOSE_FILE="$BASE_DIR/images/openim-server/docker-compose.build.yml"
RELEASE="${RELEASE:-false}"
PUSH="${PUSH:-false}"
DRY_RUN="${DRY_RUN:-false}"
PLATFORMS="${PLATFORMS:-linux/amd64,linux/arm64}"
IMAGE_TAGS="${IMAGE_TAGS:-}"
IMAGE_REGISTRIES="${IMAGE_REGISTRIES:-}"
SERVICE="${SERVICE:-}"
if [[ ! -f "$COMPOSE_FILE" ]]; then
echo -e "${RED}docker-compose.build.yml not found: $COMPOSE_FILE${NO_COLOR}"
exit 1
fi
if [[ -z "$SERVICE" ]]; then
echo -e "${RED}SERVICE is required${NO_COLOR}"
exit 1
fi
cd "$BASE_DIR/.." || exit 1
split_values() {
echo "$1" | grep -o '[^, ]\+'
}
run_or_print() {
if [[ "$DRY_RUN" == "true" ]]; then
printf '%q ' "$@"
printf '\n'
else
"$@"
fi
}
if ! command -v jq >/dev/null 2>&1; then
echo -e "${RED}jq is required${NO_COLOR}"
exit 1
fi
if [[ -z "$IMAGE_TAGS" || -z "$IMAGE_REGISTRIES" ]]; then
echo -e "${RED}IMAGE_TAGS and IMAGE_REGISTRIES are required${NO_COLOR}"
exit 1
fi
image_tags=()
while IFS= read -r tag; do
image_tags+=("$tag")
done < <(split_values "$IMAGE_TAGS")
image_registries=()
while IFS= read -r registry; do
image_registries+=("$registry")
done < <(split_values "$IMAGE_REGISTRIES")
if [[ ${#image_tags[@]} -eq 0 || ${#image_registries[@]} -eq 0 ]]; then
echo -e "${RED}IMAGE_TAGS and IMAGE_REGISTRIES must contain at least one value${NO_COLOR}"
exit 1
fi
compose_config=$(docker compose -f "$COMPOSE_FILE" config --format json)
context=$(jq -r --arg service "$SERVICE" '.services[$service].build.context // empty' <<< "$compose_config")
dockerfile=$(jq -r --arg service "$SERVICE" '.services[$service].build.dockerfile // empty' <<< "$compose_config")
cmd_path=$(jq -r --arg service "$SERVICE" '.services[$service].build.args.CMD_PATH // empty' <<< "$compose_config")
binary_name=$(jq -r --arg service "$SERVICE" '.services[$service].build.args.BINARY_NAME // empty' <<< "$compose_config")
if [[ -z "$context" || -z "$dockerfile" || -z "$cmd_path" || -z "$binary_name" ]]; then
echo -e "${RED}Invalid build config for $SERVICE${NO_COLOR}"
exit 1
fi
if [[ ! -d "$cmd_path" && ! -f "$cmd_path/main.go" ]]; then
echo -e "${CYAN}Skipping $SERVICE because $cmd_path does not exist${NO_COLOR}"
exit 0
fi
tag_args=()
for registry in "${image_registries[@]}"; do
for tag in "${image_tags[@]}"; do
tag_args+=(--tag "$registry/$binary_name:$tag")
done
done
echo -e "${CYAN}Building $binary_name for $PLATFORMS...${NO_COLOR}"
run_or_print docker buildx build \
--platform "$PLATFORMS" \
--file "$dockerfile" \
--build-arg "CMD_PATH=$cmd_path" \
--build-arg "BINARY_NAME=$binary_name" \
--build-arg "RELEASE=$RELEASE" \
"${tag_args[@]}" \
--push \
"$context"
echo -e "${GREEN}Successfully pushed $binary_name${NO_COLOR}"

View File

@ -1,24 +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.
# FROM BASE_IMAGE
# WORKDIR ${SERVER_WORKDIR}
# # Set HTTP proxy
# ARG BINARY_NAME
# COPY BINARY_NAME ./bin/BINARY_NAME
# ENTRYPOINT ["./bin/BINARY_NAME"]

View File

@ -1,36 +0,0 @@
# Use Go 1.22 Alpine as the base image for building the application
FROM golang:1.22-alpine AS builder
# Define the base directory for the application as an environment variable
ENV SERVER_DIR=/openim-server
# Set the working directory inside the container based on the environment variable
WORKDIR $SERVER_DIR
# Set the Go proxy to improve dependency resolution speed
#ENV GOPROXY=https://goproxy.io,direct
# Copy all files from the current directory into the container
COPY . .
RUN go mod tidy
RUN go build -o _output/openim-api ./cmd/openim-api
# Using Alpine Linux for the final image
FROM alpine:latest
# Install necessary packages, such as bash
RUN apk add --no-cache bash
# Set the environment and work directory
ENV SERVER_DIR=/openim-server
WORKDIR $SERVER_DIR
# Copy the compiled binaries and mage from the builder image to the final image
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
# Set the command to run when the container starts
ENTRYPOINT ["sh", "-c", "_output/openim-api"]

View File

@ -1,39 +0,0 @@
# Use Go 1.22 Alpine as the base image for building the application
FROM golang:1.22-alpine AS builder
# Define the base directory for the application as an environment variable
ENV SERVER_DIR=/openim-server
# Set the working directory inside the container based on the environment variable
WORKDIR $SERVER_DIR
# Set the Go proxy to improve dependency resolution speed
#ENV GOPROXY=https://goproxy.io,direct
# Copy all files from the current directory into the container
COPY . .
RUN go mod tidy
RUN go build -o _output/openim-crontask ./cmd/openim-crontask
# Using Alpine Linux for the final image
FROM alpine:latest
# Install necessary packages, such as bash
RUN apk add --no-cache bash
# Set the environment and work directory
ENV SERVER_DIR=/openim-server
WORKDIR $SERVER_DIR
# Copy the compiled binaries and mage from the builder image to the final image
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
# Set the command to run when the container starts
ENTRYPOINT ["sh", "-c", "_output/openim-crontask"]

View File

@ -1,39 +0,0 @@
# Use Go 1.22 Alpine as the base image for building the application
FROM golang:1.22-alpine AS builder
# Define the base directory for the application as an environment variable
ENV SERVER_DIR=/openim-server
# Set the working directory inside the container based on the environment variable
WORKDIR $SERVER_DIR
# Set the Go proxy to improve dependency resolution speed
#ENV GOPROXY=https://goproxy.io,direct
# Copy all files from the current directory into the container
COPY . .
RUN go mod tidy
RUN go build -o _output/openim-msggateway ./cmd/openim-msggateway
# Using Alpine Linux for the final image
FROM alpine:latest
# Install necessary packages, such as bash
RUN apk add --no-cache bash
# Set the environment and work directory
ENV SERVER_DIR=/openim-server
WORKDIR $SERVER_DIR
# Copy the compiled binaries and mage from the builder image to the final image
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
# Set the command to run when the container starts
ENTRYPOINT ["sh", "-c", "_output/openim-msggateway"]

View File

@ -1,39 +0,0 @@
# Use Go 1.22 Alpine as the base image for building the application
FROM golang:1.22-alpine AS builder
# Define the base directory for the application as an environment variable
ENV SERVER_DIR=/openim-server
# Set the working directory inside the container based on the environment variable
WORKDIR $SERVER_DIR
# Set the Go proxy to improve dependency resolution speed
#ENV GOPROXY=https://goproxy.io,direct
# Copy all files from the current directory into the container
COPY . .
RUN go mod tidy
RUN go build -o _output/openim-msgtransfer ./cmd/openim-msgtransfer
# Using Alpine Linux for the final image
FROM alpine:latest
# Install necessary packages, such as bash
RUN apk add --no-cache bash
# Set the environment and work directory
ENV SERVER_DIR=/openim-server
WORKDIR $SERVER_DIR
# Copy the compiled binaries and mage from the builder image to the final image
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
# Set the command to run when the container starts
ENTRYPOINT ["sh", "-c", "_output/openim-msgtransfer"]

View File

@ -1,39 +0,0 @@
# Use Go 1.22 Alpine as the base image for building the application
FROM golang:1.22-alpine AS builder
# Define the base directory for the application as an environment variable
ENV SERVER_DIR=/openim-server
# Set the working directory inside the container based on the environment variable
WORKDIR $SERVER_DIR
# Set the Go proxy to improve dependency resolution speed
#ENV GOPROXY=https://goproxy.io,direct
# Copy all files from the current directory into the container
COPY . .
RUN go mod tidy
RUN go build -o _output/openim-push ./cmd/openim-push
# Using Alpine Linux for the final image
FROM alpine:latest
# Install necessary packages, such as bash
RUN apk add --no-cache bash
# Set the environment and work directory
ENV SERVER_DIR=/openim-server
WORKDIR $SERVER_DIR
# Copy the compiled binaries and mage from the builder image to the final image
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
# Set the command to run when the container starts
ENTRYPOINT ["sh", "-c", "_output/openim-push"]

View File

@ -1,39 +0,0 @@
# Use Go 1.22 Alpine as the base image for building the application
FROM golang:1.22-alpine AS builder
# Define the base directory for the application as an environment variable
ENV SERVER_DIR=/openim-server
# Set the working directory inside the container based on the environment variable
WORKDIR $SERVER_DIR
# Set the Go proxy to improve dependency resolution speed
#ENV GOPROXY=https://goproxy.io,direct
# Copy all files from the current directory into the container
COPY . .
RUN go mod tidy
RUN go build -o _output/openim-rpc-auth ./cmd/openim-rpc/openim-rpc-auth
# Using Alpine Linux for the final image
FROM alpine:latest
# Install necessary packages, such as bash
RUN apk add --no-cache bash
# Set the environment and work directory
ENV SERVER_DIR=/openim-server
WORKDIR $SERVER_DIR
# Copy the compiled binaries and mage from the builder image to the final image
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
# Set the command to run when the container starts
ENTRYPOINT ["sh", "-c", "_output/openim-rpc-auth"]

View File

@ -1,39 +0,0 @@
# Use Go 1.22 Alpine as the base image for building the application
FROM golang:1.22-alpine AS builder
# Define the base directory for the application as an environment variable
ENV SERVER_DIR=/openim-server
# Set the working directory inside the container based on the environment variable
WORKDIR $SERVER_DIR
# Set the Go proxy to improve dependency resolution speed
#ENV GOPROXY=https://goproxy.io,direct
# Copy all files from the current directory into the container
COPY . .
RUN go mod tidy
RUN go build -o _output/openim-rpc-conversation ./cmd/openim-rpc/openim-rpc-conversation
# Using Alpine Linux for the final image
FROM alpine:latest
# Install necessary packages, such as bash
RUN apk add --no-cache bash
# Set the environment and work directory
ENV SERVER_DIR=/openim-server
WORKDIR $SERVER_DIR
# Copy the compiled binaries and mage from the builder image to the final image
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
# Set the command to run when the container starts
ENTRYPOINT ["sh", "-c", "_output/openim-rpc-conversation"]

View File

@ -1,39 +0,0 @@
# Use Go 1.22 Alpine as the base image for building the application
FROM golang:1.22-alpine AS builder
# Define the base directory for the application as an environment variable
ENV SERVER_DIR=/openim-server
# Set the working directory inside the container based on the environment variable
WORKDIR $SERVER_DIR
# Set the Go proxy to improve dependency resolution speed
#ENV GOPROXY=https://goproxy.io,direct
# Copy all files from the current directory into the container
COPY . .
RUN go mod tidy
RUN go build -o _output/openim-rpc-friend ./cmd/openim-rpc/openim-rpc-friend
# Using Alpine Linux for the final image
FROM alpine:latest
# Install necessary packages, such as bash
RUN apk add --no-cache bash
# Set the environment and work directory
ENV SERVER_DIR=/openim-server
WORKDIR $SERVER_DIR
# Copy the compiled binaries and mage from the builder image to the final image
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
# Set the command to run when the container starts
ENTRYPOINT ["sh", "-c", "_output/openim-rpc-friend"]

View File

@ -1,39 +0,0 @@
# Use Go 1.22 Alpine as the base image for building the application
FROM golang:1.22-alpine AS builder
# Define the base directory for the application as an environment variable
ENV SERVER_DIR=/openim-server
# Set the working directory inside the container based on the environment variable
WORKDIR $SERVER_DIR
# Set the Go proxy to improve dependency resolution speed
#ENV GOPROXY=https://goproxy.io,direct
# Copy all files from the current directory into the container
COPY . .
RUN go mod tidy
RUN go build -o _output/openim-rpc-group ./cmd/openim-rpc/openim-rpc-group
# Using Alpine Linux for the final image
FROM alpine:latest
# Install necessary packages, such as bash
RUN apk add --no-cache bash
# Set the environment and work directory
ENV SERVER_DIR=/openim-server
WORKDIR $SERVER_DIR
# Copy the compiled binaries and mage from the builder image to the final image
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
# Set the command to run when the container starts
ENTRYPOINT ["sh", "-c", "_output/openim-rpc-group"]

View File

@ -1,39 +0,0 @@
# Use Go 1.22 Alpine as the base image for building the application
FROM golang:1.22-alpine AS builder
# Define the base directory for the application as an environment variable
ENV SERVER_DIR=/openim-server
# Set the working directory inside the container based on the environment variable
WORKDIR $SERVER_DIR
# Set the Go proxy to improve dependency resolution speed
#ENV GOPROXY=https://goproxy.io,direct
# Copy all files from the current directory into the container
COPY . .
RUN go mod tidy
RUN go build -o _output/openim-rpc-msg ./cmd/openim-rpc/openim-rpc-msg
# Using Alpine Linux for the final image
FROM alpine:latest
# Install necessary packages, such as bash
RUN apk add --no-cache bash
# Set the environment and work directory
ENV SERVER_DIR=/openim-server
WORKDIR $SERVER_DIR
# Copy the compiled binaries and mage from the builder image to the final image
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
# Set the command to run when the container starts
ENTRYPOINT ["sh", "-c", "_output/openim-rpc-msg"]

View File

@ -1,39 +0,0 @@
# Use Go 1.22 Alpine as the base image for building the application
FROM golang:1.22-alpine AS builder
# Define the base directory for the application as an environment variable
ENV SERVER_DIR=/openim-server
# Set the working directory inside the container based on the environment variable
WORKDIR $SERVER_DIR
# Set the Go proxy to improve dependency resolution speed
#ENV GOPROXY=https://goproxy.io,direct
# Copy all files from the current directory into the container
COPY . .
RUN go mod tidy
RUN go build -o _output/openim-rpc-third ./cmd/openim-rpc/openim-rpc-third
# Using Alpine Linux for the final image
FROM alpine:latest
# Install necessary packages, such as bash
RUN apk add --no-cache bash
# Set the environment and work directory
ENV SERVER_DIR=/openim-server
WORKDIR $SERVER_DIR
# Copy the compiled binaries and mage from the builder image to the final image
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
# Set the command to run when the container starts
ENTRYPOINT ["sh", "-c", "_output/openim-rpc-third"]

View File

@ -1,37 +0,0 @@
# Use Go 1.22 Alpine as the base image for building the application
FROM golang:1.22-alpine AS builder
# Define the base directory for the application as an environment variable
ENV SERVER_DIR=/openim-server
# Set the working directory inside the container based on the environment variable
WORKDIR $SERVER_DIR
# Set the Go proxy to improve dependency resolution speed
#ENV GOPROXY=https://goproxy.io,direct
# Copy all files from the current directory into the container
COPY . .
RUN go mod tidy
RUN go build -o _output/openim-rpc-user ./cmd/openim-rpc/openim-rpc-user
# Using Alpine Linux for the final image
FROM alpine:latest
# Install necessary packages, such as bash
RUN apk add --no-cache bash
# Set the environment and work directory
ENV SERVER_DIR=/openim-server
WORKDIR $SERVER_DIR
# Copy the compiled binaries and mage from the builder image to the final image
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
# Set the command to run when the container starts
ENTRYPOINT ["sh", "-c", "_output/openim-rpc-user"]

View File

@ -0,0 +1,30 @@
FROM golang:alpine AS builder
ENV SERVER_DIR=/openim-server
WORKDIR $SERVER_DIR
COPY . .
RUN go mod tidy
ARG CMD_PATH
ARG BINARY_NAME
ARG RELEASE=false
RUN if [ "$RELEASE" = "true" ]; then \
go build -trimpath -ldflags "-s -w" -o _output/${BINARY_NAME} ./${CMD_PATH}; \
else \
go build -o _output/${BINARY_NAME} ./${CMD_PATH}; \
fi
FROM alpine:latest
RUN apk add --no-cache bash
ARG BINARY_NAME
ENV BINARY_NAME=${BINARY_NAME}
ENV SERVER_DIR=/openim-server
WORKDIR $SERVER_DIR
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
ENTRYPOINT ["sh", "-c", "_output/${BINARY_NAME}"]

View File

@ -0,0 +1,120 @@
services:
openim-api:
build:
context: ../../..
dockerfile: build/images/openim-server/Dockerfile
args:
CMD_PATH: cmd/openim-api
BINARY_NAME: openim-api
RELEASE: ${RELEASE:-false}
image: openim-api:test
openim-crontask:
build:
context: ../../..
dockerfile: build/images/openim-server/Dockerfile
args:
CMD_PATH: cmd/openim-crontask
BINARY_NAME: openim-crontask
RELEASE: ${RELEASE:-false}
image: openim-crontask:test
openim-msggateway:
build:
context: ../../..
dockerfile: build/images/openim-server/Dockerfile
args:
CMD_PATH: cmd/openim-msggateway
BINARY_NAME: openim-msggateway
RELEASE: ${RELEASE:-false}
image: openim-msggateway:test
openim-msgtransfer:
build:
context: ../../..
dockerfile: build/images/openim-server/Dockerfile
args:
CMD_PATH: cmd/openim-msgtransfer
BINARY_NAME: openim-msgtransfer
RELEASE: ${RELEASE:-false}
image: openim-msgtransfer:test
openim-push:
build:
context: ../../..
dockerfile: build/images/openim-server/Dockerfile
args:
CMD_PATH: cmd/openim-push
BINARY_NAME: openim-push
RELEASE: ${RELEASE:-false}
image: openim-push:test
openim-rpc-auth:
build:
context: ../../..
dockerfile: build/images/openim-server/Dockerfile
args:
CMD_PATH: cmd/openim-rpc/openim-rpc-auth
BINARY_NAME: openim-rpc-auth
RELEASE: ${RELEASE:-false}
image: openim-rpc-auth:test
openim-rpc-conversation:
build:
context: ../../..
dockerfile: build/images/openim-server/Dockerfile
args:
CMD_PATH: cmd/openim-rpc/openim-rpc-conversation
BINARY_NAME: openim-rpc-conversation
RELEASE: ${RELEASE:-false}
image: openim-rpc-conversation:test
openim-rpc-friend:
build:
context: ../../..
dockerfile: build/images/openim-server/Dockerfile
args:
CMD_PATH: cmd/openim-rpc/openim-rpc-friend
BINARY_NAME: openim-rpc-friend
RELEASE: ${RELEASE:-false}
image: openim-rpc-friend:test
openim-rpc-group:
build:
context: ../../..
dockerfile: build/images/openim-server/Dockerfile
args:
CMD_PATH: cmd/openim-rpc/openim-rpc-group
BINARY_NAME: openim-rpc-group
RELEASE: ${RELEASE:-false}
image: openim-rpc-group:test
openim-rpc-msg:
build:
context: ../../..
dockerfile: build/images/openim-server/Dockerfile
args:
CMD_PATH: cmd/openim-rpc/openim-rpc-msg
BINARY_NAME: openim-rpc-msg
RELEASE: ${RELEASE:-false}
image: openim-rpc-msg:test
openim-rpc-third:
build:
context: ../../..
dockerfile: build/images/openim-server/Dockerfile
args:
CMD_PATH: cmd/openim-rpc/openim-rpc-third
BINARY_NAME: openim-rpc-third
RELEASE: ${RELEASE:-false}
image: openim-rpc-third:test
openim-rpc-user:
build:
context: ../../..
dockerfile: build/images/openim-server/Dockerfile
args:
CMD_PATH: cmd/openim-rpc/openim-rpc-user
BINARY_NAME: openim-rpc-user
RELEASE: ${RELEASE:-false}
image: openim-rpc-user:test

View File

@ -1,108 +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.
# # OpenIM base image: https://github.com/openim-sigs/openim-base-image
# # Set go mod installation source and proxy
# FROM golang:1.20 AS builder
#
# WORKDIR /openim/openim-server
#
# ENV GOPROXY=$GOPROXY
# COPY go.mod go.sum ./
# RUN go mod download
# COPY . .
# RUN make clean
# RUN make build BINS=component
# # FROM ghcr.io/openim-sigs/openim-bash-image:latest
# FROM ghcr.io/openim-sigs/openim-bash-image:latest
# WORKDIR /openim/openim-server
# COPY --from=builder /openim/openim-server/_output/bin/tools /openim/openim-server/_output/bin/tools/
# COPY --from=builder /openim/openim-server/config /openim/openim-server/config
# ENV OPENIM_SERVER_CONFIG_NAME=/openim/openim-server/config
# RUN mv ${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/component /usr/bin/component
# ENTRYPOINT ["bash", "-c", "component -c $OPENIM_SERVER_CONFIG_NAME"]
# Use Go 1.22 Alpine as the base image for building the application
FROM golang:1.22-alpine AS builder
# Define the base directory for the application as an environment variable
ENV SERVER_DIR=/openim-server
# Set the working directory inside the container based on the environment variable
WORKDIR $SERVER_DIR
# Set the Go proxy to improve dependency resolution speed
#ENV GOPROXY=https://goproxy.io,direct
# Copy all files from the current directory into the container
COPY . .
RUN go mod download
# Install Mage to use for building the application
RUN go install github.com/magefile/mage@v1.15.0
# ENV BINS=openim-rpc-user
# Optionally build your application if needed
# RUN mage build ${BINS} check-free-memory seq || true
RUN mage build check-free-memory seq || true
# Using Alpine Linux with Go environment for the final image
FROM golang:1.22-alpine
# Install necessary packages, such as bash
RUN apk add bash
# Set the environment and work directory
ENV SERVER_DIR=/openim-server
WORKDIR $SERVER_DIR
# Copy the compiled binaries and mage from the builder image to the final image
COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output
COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config
COPY --from=builder /go/bin/mage /usr/local/bin/mage
COPY --from=builder $SERVER_DIR/magefile_windows.go $SERVER_DIR/
COPY --from=builder $SERVER_DIR/magefile_unix.go $SERVER_DIR/
COPY --from=builder $SERVER_DIR/magefile.go $SERVER_DIR/
# COPY --from=builder $SERVER_DIR/start-config.yml $SERVER_DIR/
COPY --from=builder $SERVER_DIR/go.mod $SERVER_DIR/
COPY --from=builder $SERVER_DIR/go.sum $SERVER_DIR/
RUN echo -e "serviceBinaries:\n \n" \
> $SERVER_DIR/start-config.yml && \
echo -e "toolBinaries:\n - check-free-memory\n - seq\n" >> $SERVER_DIR/start-config.yml && \
echo "maxFileDescriptors: 10000" >> $SERVER_DIR/start-config.yml
RUN go get github.com/openimsdk/gomake@v0.0.15-alpha.1
# Set the command to run when the container starts
ENTRYPOINT ["sh", "-c", "mage start && tail -f /dev/null"]

View File

@ -3,6 +3,7 @@ package main
import (
"bytes"
"context"
"errors"
"flag"
"fmt"
"net"
@ -12,12 +13,15 @@ import (
"path/filepath"
"reflect"
"runtime"
"strconv"
"strings"
"sync"
"syscall"
"time"
"github.com/mitchellh/mapstructure"
"github.com/spf13/viper"
"google.golang.org/grpc"
"github.com/openimsdk/open-im-server/v3/internal/api"
"github.com/openimsdk/open-im-server/v3/internal/msggateway"
"github.com/openimsdk/open-im-server/v3/internal/msgtransfer"
@ -30,33 +34,40 @@ import (
"github.com/openimsdk/open-im-server/v3/internal/rpc/third"
"github.com/openimsdk/open-im-server/v3/internal/rpc/user"
"github.com/openimsdk/open-im-server/v3/internal/tools/cron"
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
"github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/redis"
"github.com/openimsdk/open-im-server/v3/pkg/dbbuild"
"github.com/openimsdk/open-im-server/v3/version"
"github.com/openimsdk/tools/discovery"
"github.com/openimsdk/tools/discovery/standalone"
"github.com/openimsdk/tools/discovery/inprocess"
"github.com/openimsdk/tools/log"
"github.com/openimsdk/tools/system/program"
"github.com/openimsdk/tools/utils/datautil"
"github.com/spf13/viper"
"google.golang.org/grpc"
"github.com/openimsdk/tools/utils/network"
)
func init() {
config.SetStandalone()
prommetrics.RegistryAll()
inprocess.SetContextAdminFunc(authverify.IsAdmin)
}
func main() {
var configPath string
var (
configPath string
index int
)
flag.StringVar(&configPath, "c", "", "config path")
flag.IntVar(&index, "i", 0, "start index")
flag.Parse()
if configPath == "" {
_, _ = fmt.Fprintln(os.Stderr, "config path is empty")
os.Exit(1)
return
}
cmd := newCmds(configPath)
cmd := newCmds(configPath, index)
putCmd(cmd, false, auth.Start)
putCmd(cmd, false, conversation.Start)
putCmd(cmd, false, relation.Start)
@ -69,6 +80,7 @@ func main() {
putCmd(cmd, true, msgtransfer.Start)
putCmd(cmd, true, api.Start)
putCmd(cmd, true, cron.Start)
putCmd(cmd, true, startRedisServerRegister)
ctx := context.Background()
if err := cmd.run(ctx); err != nil {
_, _ = fmt.Fprintf(os.Stderr, "server exit %s", err)
@ -77,8 +89,8 @@ func main() {
}
}
func newCmds(confPath string) *cmds {
return &cmds{confPath: confPath}
func newCmds(confPath string, index int) *cmds {
return &cmds{confPath: confPath, index: index}
}
type cmdName struct {
@ -88,6 +100,7 @@ type cmdName struct {
}
type cmds struct {
confPath string
index int
cmds []cmdName
config config.AllConfig
conf map[string]reflect.Value
@ -116,6 +129,9 @@ func (x *cmds) initDiscovery() {
func (x *cmds) initAllConfig() error {
x.conf = make(map[string]reflect.Value)
if err := x.loadShareConfig(); err != nil {
return err
}
vof := reflect.ValueOf(&x.config).Elem()
num := vof.NumField()
for i := 0; i < num; i++ {
@ -129,23 +145,17 @@ func (x *cmds) initAllConfig() error {
}
x.conf[x.getTypePath(field.Type())] = field
val := field.Addr().Interface()
name := val.(interface{ GetConfigFileName() string }).GetConfigFileName()
confData, err := os.ReadFile(filepath.Join(x.confPath, name))
if err != nil {
if os.IsNotExist(err) {
continue
}
return err
// Fields without a config file (e.g. Timer) are still registered above
// for parseConf distribution, but there is nothing to load for them.
fc, ok := val.(config.FileConfig)
if !ok {
continue
}
v := viper.New()
v.SetConfigType("yaml")
if err := v.ReadConfig(bytes.NewReader(confData)); err != nil {
return err
name := fc.GetConfigFileName()
if name == config.ShareFileName || x.skipKafkaConfig(name) {
continue
}
opt := func(conf *mapstructure.DecoderConfig) {
conf.TagName = config.StructTagName
}
if err := v.Unmarshal(val, opt); err != nil {
if err := x.loadFileConfig(name, val); err != nil {
return err
}
}
@ -156,6 +166,31 @@ func (x *cmds) initAllConfig() error {
return nil
}
func (x *cmds) loadShareConfig() error {
return x.loadFileConfig(config.ShareFileName, &x.config.Share)
}
func (x *cmds) skipKafkaConfig(name string) bool {
return name == config.KafkaConfigFileName &&
config.NormalizeQueueEngine(x.config.Share.Queue.Engine) != config.QueueEngineKafka
}
func (x *cmds) loadFileConfig(name string, val any) error {
confData, err := os.ReadFile(filepath.Join(x.confPath, name))
if err != nil {
if os.IsNotExist(err) {
return nil
}
return err
}
v := viper.New()
v.SetConfigType(config.StructTagName)
if err := v.ReadConfig(bytes.NewReader(confData)); err != nil {
return err
}
return v.Unmarshal(val, config.ApplyDecoderConfig)
}
func (x *cmds) parseConf(conf any) error {
vof := reflect.ValueOf(conf)
for {
@ -178,6 +213,7 @@ func (x *cmds) parseConf(conf any) error {
if !ok {
switch field.Interface().(type) {
case config.Index:
field.Set(reflect.ValueOf(config.Index(x.index)))
case config.Path:
field.SetString(x.confPath)
case config.AllConfig:
@ -201,7 +237,7 @@ func (x *cmds) add(name string, block bool, fn func(ctx context.Context) error)
func (x *cmds) initLog() error {
conf := x.config.Log
if err := log.InitLoggerFromConfig(
"openim-server",
"openim-service-log",
program.GetProcessName(),
"", "",
conf.RemainLogLevel,
@ -339,7 +375,7 @@ func putCmd[C any](cmd *cmds, block bool, fn func(ctx context.Context, config *C
if err := cmd.parseConf(&conf); err != nil {
return err
}
return fn(ctx, &conf, standalone.GetSvcDiscoveryRegistry(), standalone.GetServiceRegistrar())
return fn(ctx, &conf, inprocess.GetSvcDiscoveryRegistry(), inprocess.GetServiceRegistrar())
})
}
@ -404,3 +440,71 @@ func (x *cmdManger) Running() []string {
}
return names
}
type serverConfig struct {
API config.API
Share config.Share
RedisConfig config.Redis
Index config.Index
}
func startRedisServerRegister(ctx context.Context, cfg *serverConfig, client discovery.SvcDiscoveryRegistry, service grpc.ServiceRegistrar) error {
apiPort, err := datautil.GetElemByIndex(cfg.API.Api.Ports, int(cfg.Index))
if err != nil {
return err
}
if apiPort <= 0 {
return errors.New("standalone api port is 0")
}
registerIP, err := network.GetRpcRegisterIP(cfg.API.Api.RegisterIP)
if err != nil {
return err
}
const validTime = time.Second * 10
dbb := dbbuild.NewBuilder(nil, &cfg.RedisConfig)
rdb, err := dbb.Redis(ctx)
if err != nil {
return err
}
gateway := redis.NewStandaloneGatewayRedis(rdb, validTime)
selfAddr := net.JoinHostPort(registerIP, strconv.Itoa(apiPort))
inprocess.SetLocalTarget(selfAddr)
inprocess.SetBroadcastAddress(cfg.Share.Secret, func(ctx context.Context) ([]string, error) {
address, err := gateway.GetGatewayAddrs(ctx)
if err != nil {
return nil, err
}
notSelf := make([]string, 0, len(address))
for _, addr := range address {
if addr != selfAddr {
notSelf = append(notSelf, addr)
}
}
return notSelf, nil
})
register := func() {
ctx, cancel := context.WithTimeout(ctx, validTime/2)
defer cancel()
if err := gateway.RegisterGateway(ctx, selfAddr); err != nil {
log.ZWarn(ctx, "gateway register failed", err, "address", selfAddr)
}
}
timer := time.NewTicker(validTime / 2)
defer func() {
timer.Stop()
ctx, cancel := context.WithTimeout(context.WithoutCancel(ctx), time.Second)
defer cancel()
if err := gateway.UnregisterGateway(ctx, selfAddr); err != nil {
log.ZWarn(ctx, "gateway unregister failed", err, "address", selfAddr)
}
}()
register()
for {
select {
case <-timer.C:
register()
case <-ctx.Done():
return context.Cause(ctx)
}
}
}

View File

@ -1,34 +1,36 @@
# Global Alertmanager runtime and SMTP settings.
global:
resolve_timeout: 5m
smtp_from: alert@openim.io
smtp_smarthost: smtp.163.com:465
smtp_auth_username: alert@openim.io
smtp_auth_password: YOURAUTHPASSWORD
smtp_require_tls: false
smtp_hello: xxx
resolve_timeout: 5m # Wait time before an alert is considered resolved when no further updates are received.
smtp_from: alert@openim.io # Sender address displayed in alert emails.
smtp_smarthost: smtp.163.com:465 # SMTP relay endpoint in host:port format.
smtp_auth_username: alert@openim.io # SMTP authentication username (commonly the same as smtp_from).
smtp_auth_password: YOURAUTHPASSWORD # SMTP authorization token or app password.
smtp_require_tls: false # Set to true when your SMTP provider requires STARTTLS.
smtp_hello: xxx # HELO/EHLO identity presented to the SMTP server.
templates:
- /etc/alertmanager/email.tmpl
- /etc/alertmanager/email.tmpl # Go template file used to render HTML email content.
# Root routing tree for all incoming alerts.
route:
group_by: [ 'alertname' ]
group_wait: 5s
group_interval: 5s
repeat_interval: 5m
receiver: email
group_by: [ 'alertname' ] # Alerts sharing this label value are batched into one notification.
group_wait: 5s # Initial delay before sending the first notification for a new alert group.
group_interval: 5s # Minimum interval between notifications for the same alert group.
repeat_interval: 5m # Reminder interval while an alert group remains firing.
receiver: email # Default receiver when no child route matches.
routes:
- matchers:
- alertname = "XXX"
group_by: [ 'instance' ]
- alertname = "XXX" # Example matcher; replace with a real alert name or remove this route.
group_by: [ 'instance' ] # Override grouping for this specific route.
group_wait: 5s
group_interval: 5s
repeat_interval: 5m
receiver: email
receivers:
- name: email
- name: email # Receiver name referenced by route.receiver.
email_configs:
- to: 'alert@example.com'
html: '{{ template "email.to.html" . }}'
headers: { Subject: "[OPENIM-SERVER]Alarm" }
send_resolved: true
- to: 'alert@example.com' # Recipient mailbox for alert notifications.
html: '{{ template "email.to.html" . }}' # Rendered with the template declared in email.tmpl.
headers: { Subject: "[OPENIM-SERVER]Alarm" } # Custom email subject line.
send_resolved: true # Also send a notification when the alert recovers.

View File

@ -1,3 +1,6 @@
{{/* OpenIM Alertmanager email template.
This template renders both firing and resolved alerts.
Each alert entry reads labels and annotations from Prometheus rule definitions. */}}
{{ define "email.to.html" }}
{{ if eq .Status "firing" }}
{{ range .Alerts }}

View File

@ -1,30 +1,31 @@
# Default Prometheus alert groups for OpenIM.
groups:
- name: instance_down
- name: instance_down # Fires when a monitored target remains unreachable.
rules:
- alert: InstanceDown
expr: up == 0
for: 1m
expr: up == 0 # The built-in "up" metric is 0 when the latest scrape fails.
for: 1m # Trigger only if the condition remains true for more than 1 minute.
labels:
severity: critical
severity: critical # Used by Alertmanager for routing and notification priority.
annotations:
summary: "Instance {{ $labels.instance }} down"
description: "{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 1 minutes."
description: "{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 1 minute."
- name: database_insert_failure_alerts
- name: database_insert_failure_alerts # Detects failures when persisting messages to Redis or MongoDB.
rules:
- alert: DatabaseInsertFailed
expr: (increase(msg_insert_redis_failed_total[5m]) > 0) or (increase(msg_insert_mongo_failed_total[5m]) > 0)
for: 1m
expr: (increase(msg_insert_redis_failed_total[5m]) > 0) or (increase(msg_insert_mongo_failed_total[5m]) > 0) # Any positive increase indicates write failures occurred in the last 5 minutes.
for: 1m # Avoid firing on very short spikes.
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."
description: "Either MsgInsertRedisFailedCounter or MsgInsertMongoFailedCounter increased in the last 5 minutes, indicating message insert failures to Redis or MongoDB and a possible backend outage."
- name: registrations_few
- name: registrations_few # Operational early-warning rule for unusually low login/registration activity.
rules:
- alert: RegistrationsFew
expr: increase(user_login_total[1h]) == 0
expr: increase(user_login_total[1h]) == 0 # No successful login/registration events observed in 1 hour.
for: 1m
labels:
severity: info
@ -32,10 +33,10 @@ groups:
summary: "Too few registrations within the time frame"
description: "The number of registrations in the last hour is 0. There might be some issues."
- name: messages_few
- name: messages_few # Operational early-warning rule for unusually low messaging activity.
rules:
- alert: MessagesFew
expr: (increase(single_chat_msg_process_success_total[1h])+increase(group_chat_msg_process_success_total[1h])) == 0
expr: (increase(single_chat_msg_process_success_total[1h])+increase(group_chat_msg_process_success_total[1h])) == 0 # No successful single or group messages observed in 1 hour.
for: 1m
labels:
severity: info

View File

@ -3,12 +3,14 @@ api:
listenIP: 0.0.0.0
# Listening ports; if multiple are configured, multiple instances will be launched, must be consistent with the number of prometheus.ports
ports: [ 10002 ]
# Fallback for IP resolution issues in multi-instance standalone mode.
# registerIP:
# API compression level; 0: default compression, 1: best compression, 2: best speed, -1: no compression
compressionLevel: 0
prometheus:
# Whether to enable prometheus
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
enable: true
# autoSetPorts indicates whether to automatically set the ports
autoSetPorts: true

View File

@ -9,7 +9,7 @@ rpc:
ports:
prometheus:
# Enable or disable Prometheus monitoring
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
enable: true
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
# It will only take effect when autoSetPorts is set to false.

View File

@ -1,5 +1,5 @@
prometheus:
# Enable or disable Prometheus monitoring
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
enable: true
# autoSetPorts indicates whether to automatically set the ports
autoSetPorts: true

View File

@ -28,7 +28,7 @@ circuitBreaker:
request: 500 # Request threshold; circuit breaker evaluation occurs when reached
prometheus:
# Enable or disable Prometheus monitoring
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
enable: false
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
# It will only take effect when autoSetPorts is set to false.

View File

@ -11,7 +11,7 @@ rpc:
ports:
prometheus:
# Enable or disable Prometheus monitoring
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
enable: true
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
# It will only take effect when autoSetPorts is set to false.

View File

@ -11,7 +11,7 @@ rpc:
ports:
prometheus:
# Enable or disable Prometheus monitoring
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
enable: true
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
# It will only take effect when autoSetPorts is set to false.

View File

@ -11,7 +11,7 @@ rpc:
ports:
prometheus:
# Enable or disable Prometheus monitoring
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
enable: true
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
# It will only take effect when autoSetPorts is set to false.

View File

@ -11,7 +11,7 @@ rpc:
ports:
prometheus:
# Enable or disable Prometheus monitoring
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
enable: true
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
# It will only take effect when autoSetPorts is set to false.

View File

@ -11,7 +11,7 @@ rpc:
ports:
prometheus:
# Enable or disable Prometheus monitoring
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
enable: true
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
# It will only take effect when autoSetPorts is set to false.

View File

@ -11,7 +11,7 @@ rpc:
ports:
prometheus:
# Enable or disable Prometheus monitoring
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
enable: true
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
# It will only take effect when autoSetPorts is set to false.

View File

@ -11,7 +11,7 @@ rpc:
ports:
prometheus:
# Whether to enable prometheus
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
enable: true
# Prometheus listening ports, must be consistent with the number of rpc.ports
# It will only take effect when autoSetPorts is set to false.

View File

@ -1,35 +1,34 @@
# my global config
# Global Prometheus runtime settings.
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# scrape_timeout defaults to 10s unless overridden in a specific scrape job.
# Alertmanager configuration
# Alertmanager endpoints that receive alert events from Prometheus.
alerting:
alertmanagers:
- static_configs:
- targets: [127.0.0.1:19093]
- targets: [127.0.0.1:19093] # Alertmanager address in host:port format.
# Load rules once and periodically evaluate them according to the global evaluation_interval.
# Rule files loaded by Prometheus.
rule_files:
- instance-down-rules.yml
- instance-down-rules.yml # Default OpenIM alert rules; add more files here if needed.
# - first_rules.yml
# - second_rules.yml
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
# Scrape jobs used to collect infrastructure and OpenIM service metrics.
scrape_configs:
# The job name is added as a label "job=job_name" to any timeseries scraped from this config.
# Monitored information captured by prometheus
# prometheus fetches application services
# The job_name value is attached as the "job" label in collected time series.
- job_name: node_exporter
static_configs:
- targets: [ 127.0.0.1:19100 ]
- targets: [ 127.0.0.1:19100 ] # node_exporter endpoint for host CPU, memory, disk, and network metrics.
# OpenIM services are discovered dynamically from the admin API.
# For multi-host deployments, replace 127.0.0.1 with a reachable internal address.
- job_name: openimserver-openim-api
http_sd_configs:
- url: "http://127.0.0.1:10002/prometheus_discovery/api"
- url: "http://127.0.0.1:10002/prometheus_discovery/api" # Service discovery endpoint for OpenIM API instances.
# static_configs:
# - targets: [ 127.0.0.1:12002 ]
# labels:
@ -37,7 +36,7 @@ scrape_configs:
- job_name: openimserver-openim-msggateway
http_sd_configs:
- url: "http://127.0.0.1:10002/prometheus_discovery/msg_gateway"
- url: "http://127.0.0.1:10002/prometheus_discovery/msg_gateway" # Service discovery endpoint for msggateway instances.
# static_configs:
# - targets: [ 127.0.0.1:12140 ]
# # - targets: [ 127.0.0.1:12140, 127.0.0.1:12141, 127.0.0.1:12142, 127.0.0.1:12143, 127.0.0.1:12144, 127.0.0.1:12145, 127.0.0.1:12146, 127.0.0.1:12147, 127.0.0.1:12148, 127.0.0.1:12149, 127.0.0.1:12150, 127.0.0.1:12151, 127.0.0.1:12152, 127.0.0.1:12153, 127.0.0.1:12154, 127.0.0.1:12155 ]
@ -46,7 +45,7 @@ scrape_configs:
- job_name: openimserver-openim-msgtransfer
http_sd_configs:
- url: "http://127.0.0.1:10002/prometheus_discovery/msg_transfer"
- url: "http://127.0.0.1:10002/prometheus_discovery/msg_transfer" # Service discovery endpoint for msgtransfer instances.
# static_configs:
# - targets: [ 127.0.0.1:12020, 127.0.0.1:12021, 127.0.0.1:12022, 127.0.0.1:12023, 127.0.0.1:12024, 127.0.0.1:12025, 127.0.0.1:12026, 127.0.0.1:12027 ]
# # - targets: [ 127.0.0.1:12020, 127.0.0.1:12021, 127.0.0.1:12022, 127.0.0.1:12023, 127.0.0.1:12024, 127.0.0.1:12025, 127.0.0.1:12026, 127.0.0.1:12027, 127.0.0.1:12028, 127.0.0.1:12029, 127.0.0.1:12030, 127.0.0.1:12031, 127.0.0.1:12032, 127.0.0.1:12033, 127.0.0.1:12034, 127.0.0.1:12035 ]
@ -55,7 +54,7 @@ scrape_configs:
- job_name: openimserver-openim-push
http_sd_configs:
- url: "http://127.0.0.1:10002/prometheus_discovery/push"
- url: "http://127.0.0.1:10002/prometheus_discovery/push" # Service discovery endpoint for push service instances.
# static_configs:
# - targets: [ 127.0.0.1:12170, 127.0.0.1:12171, 127.0.0.1:12172, 127.0.0.1:12173, 127.0.0.1:12174, 127.0.0.1:12175, 127.0.0.1:12176, 127.0.0.1:12177 ]
## - targets: [ 127.0.0.1:12170, 127.0.0.1:12171, 127.0.0.1:12172, 127.0.0.1:12173, 127.0.0.1:12174, 127.0.0.1:12175, 127.0.0.1:12176, 127.0.0.1:12177, 127.0.0.1:12178, 127.0.0.1:12179, 127.0.0.1:12180, 127.0.0.1:12182, 127.0.0.1:12183, 127.0.0.1:12184, 127.0.0.1:12185, 127.0.0.1:12186 ]
@ -64,7 +63,7 @@ scrape_configs:
- job_name: openimserver-openim-rpc-auth
http_sd_configs:
- url: "http://127.0.0.1:10002/prometheus_discovery/auth"
- url: "http://127.0.0.1:10002/prometheus_discovery/auth" # Service discovery endpoint for auth RPC instances.
# static_configs:
# - targets: [ 127.0.0.1:12200 ]
# labels:
@ -72,7 +71,7 @@ scrape_configs:
- job_name: openimserver-openim-rpc-conversation
http_sd_configs:
- url: "http://127.0.0.1:10002/prometheus_discovery/conversation"
- url: "http://127.0.0.1:10002/prometheus_discovery/conversation" # Service discovery endpoint for conversation RPC instances.
# static_configs:
# - targets: [ 127.0.0.1:12220 ]
# labels:
@ -80,7 +79,7 @@ scrape_configs:
- job_name: openimserver-openim-rpc-friend
http_sd_configs:
- url: "http://127.0.0.1:10002/prometheus_discovery/friend"
- url: "http://127.0.0.1:10002/prometheus_discovery/friend" # Service discovery endpoint for friend RPC instances.
# static_configs:
# - targets: [ 127.0.0.1:12240 ]
# labels:
@ -88,7 +87,7 @@ scrape_configs:
- job_name: openimserver-openim-rpc-group
http_sd_configs:
- url: "http://127.0.0.1:10002/prometheus_discovery/group"
- url: "http://127.0.0.1:10002/prometheus_discovery/group" # Service discovery endpoint for group RPC instances.
# static_configs:
# - targets: [ 127.0.0.1:12260 ]
# labels:
@ -96,7 +95,7 @@ scrape_configs:
- job_name: openimserver-openim-rpc-msg
http_sd_configs:
- url: "http://127.0.0.1:10002/prometheus_discovery/msg"
- url: "http://127.0.0.1:10002/prometheus_discovery/msg" # Service discovery endpoint for msg RPC instances.
# static_configs:
# - targets: [ 127.0.0.1:12280 ]
# labels:
@ -104,7 +103,7 @@ scrape_configs:
- job_name: openimserver-openim-rpc-third
http_sd_configs:
- url: "http://127.0.0.1:10002/prometheus_discovery/third"
- url: "http://127.0.0.1:10002/prometheus_discovery/third" # Service discovery endpoint for third-party RPC instances.
# static_configs:
# - targets: [ 127.0.0.1:12300 ]
# labels:
@ -112,8 +111,8 @@ scrape_configs:
- job_name: openimserver-openim-rpc-user
http_sd_configs:
- url: "http://127.0.0.1:10002/prometheus_discovery/user"
- url: "http://127.0.0.1:10002/prometheus_discovery/user" # Service discovery endpoint for user RPC instances.
# static_configs:
# - targets: [ 127.0.0.1:12320 ]
# labels:
# namespace: default
# namespace: default

View File

@ -9,6 +9,14 @@ imAdminUser:
# Each entry here corresponds by index to the matching entry in the userIDs list above.
nicknames: [superAdmin]
# queue: choose message queue engine
# Supported values:
# - kafka (default)
# - redis
# - memory (standalone only; microservices cannot use memory)
queue: kafka
# 1: For Android, iOS, Windows, Mac, and web platforms, only one instance can be online at a time
multiLogin:
policy: 1

View File

@ -46,6 +46,7 @@ services:
etcd:
image: "${ETCD_IMAGE}"
user: root
container_name: etcd
ports:
- "12379:2379"
@ -53,6 +54,8 @@ services:
environment:
- ETCD_NAME=s1
- ETCD_DATA_DIR=/etcd-data
# Authentication is managed below; no-auth requires a trusted, isolated network.
- ALLOW_NONE_AUTHENTICATION=yes
- ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379
- ETCD_ADVERTISE_CLIENT_URLS=http://0.0.0.0:2379
- ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380
@ -60,7 +63,7 @@ services:
- ETCD_INITIAL_CLUSTER=s1=http://0.0.0.0:2380
- ETCD_INITIAL_CLUSTER_TOKEN=tkn
- ETCD_INITIAL_CLUSTER_STATE=new
- ALLOW_NONE_AUTHENTICATION=no
## Optional: Enable etcd authentication by setting the following credentials
# - ETCD_ROOT_USER=root
# - ETCD_ROOT_PASSWORD=openIM123
@ -68,74 +71,70 @@ services:
# - ETCD_PASSWORD=openIM123
volumes:
- "${DATA_DIR}/components/etcd:/etcd-data"
command: >
/bin/sh -c '
etcd &
export ETCDCTL_API=3
echo "Waiting for etcd to become healthy..."
until etcdctl --endpoints=http://127.0.0.1:2379 endpoint health &>/dev/null; do
echo "Waiting for ETCD to start..."
command:
- /bin/sh
- -c
- |
set -eu
fail() { echo "$$*" >&2; exit 1; }
auth=no
if [ -n "$${ETCD_ROOT_USER:-}$${ETCD_ROOT_PASSWORD:-}$${ETCD_USERNAME:-}$${ETCD_PASSWORD:-}" ]; then
[ -n "$${ETCD_ROOT_USER:-}" ] && [ -n "$${ETCD_ROOT_PASSWORD:-}" ] && [ -n "$${ETCD_USERNAME:-}" ] && [ -n "$${ETCD_PASSWORD:-}" ] || fail "Set all four authentication variables or leave all four empty."
[ "$$ETCD_ROOT_USER" = root ] && [ "$$ETCD_USERNAME" != root ] || fail "etcd requires ETCD_ROOT_USER=root and a separate application user."
auth=yes
fi
[ -d /etcd-data ] && [ -w /etcd-data ] && [ -x /etcd-data ] || fail "/etcd-data must be writable and searchable."
(unset ETCD_ROOT_USER ETCD_ROOT_PASSWORD ETCD_USERNAME ETCD_PASSWORD; ETCD_DATA_DIR=/etcd-data exec etcd) &
daemon=$$!
cleanup() {
trap - EXIT TERM INT
kill -"$${signal:-TERM}" "$$daemon" 2>/dev/null || :
wait "$$daemon" 2>/dev/null || :
}
trap cleanup EXIT
trap "signal=TERM; exit 143" TERM
trap "signal=INT; exit 130" INT
export ETCDCTL_API=3 ETCDCTL_ENDPOINTS=http://127.0.0.1:2379
export ETCDCTL_DIAL_TIMEOUT=2s ETCDCTL_COMMAND_TIMEOUT=2s
unset ETCDCTL_USER ETCDCTL_PASSWORD
attempts=0
until etcdctl endpoint status >/dev/null 2>&1; do
kill -0 "$$daemon" 2>/dev/null || { wait "$$daemon"; exit $$?; }
attempts=$$((attempts + 1))
[ "$$attempts" -lt 30 ] || fail "etcd startup timed out."
sleep 1
done
echo "etcd is healthy."
if [ -n "$${ETCD_ROOT_USER}" ] && [ -n "$${ETCD_ROOT_PASSWORD}" ] && [ -n "$${ETCD_USERNAME}" ] && [ -n "$${ETCD_PASSWORD}" ]; then
echo "Authentication credentials provided. Setting up authentication..."
echo "Checking authentication status..."
if ! etcdctl --endpoints=http://127.0.0.1:2379 auth status | grep -q "Authentication Status: true"; then
echo "Authentication is disabled. Creating users and enabling..."
# Create users and setup permissions
etcdctl --endpoints=http://127.0.0.1:2379 user add $${ETCD_ROOT_USER} --new-user-password=$${ETCD_ROOT_PASSWORD} || true
etcdctl --endpoints=http://127.0.0.1:2379 user add $${ETCD_USERNAME} --new-user-password=$${ETCD_PASSWORD} || true
etcdctl --endpoints=http://127.0.0.1:2379 role add openim-role || true
etcdctl --endpoints=http://127.0.0.1:2379 role grant-permission openim-role --prefix=true readwrite / || true
etcdctl --endpoints=http://127.0.0.1:2379 role grant-permission openim-role --prefix=true readwrite "" || true
etcdctl --endpoints=http://127.0.0.1:2379 user grant-role $${ETCD_USERNAME} openim-role || true
etcdctl --endpoints=http://127.0.0.1:2379 user grant-role $${ETCD_ROOT_USER} $${ETCD_USERNAME} root || true
echo "Enabling authentication..."
etcdctl --endpoints=http://127.0.0.1:2379 auth enable
echo "Authentication enabled successfully"
else
echo "Authentication is already enabled. Checking OpenIM user..."
# Check if openIM user exists and can perform operations
if ! etcdctl --endpoints=http://127.0.0.1:2379 --user=$${ETCD_USERNAME}:$${ETCD_PASSWORD} put /test/auth "auth-check" &>/dev/null; then
echo "OpenIM user test failed. Recreating user with root credentials..."
# Try to create/update the openIM user using root credentials
etcdctl --endpoints=http://127.0.0.1:2379 --user=$${ETCD_ROOT_USER}:$${ETCD_ROOT_PASSWORD} user add $${ETCD_USERNAME} --new-user-password=$${ETCD_PASSWORD} --no-password-file || true
etcdctl --endpoints=http://127.0.0.1:2379 --user=$${ETCD_ROOT_USER}:$${ETCD_ROOT_PASSWORD} role add openim-role || true
etcdctl --endpoints=http://127.0.0.1:2379 --user=$${ETCD_ROOT_USER}:$${ETCD_ROOT_PASSWORD} role grant-permission openim-role --prefix=true readwrite / || true
etcdctl --endpoints=http://127.0.0.1:2379 --user=$${ETCD_ROOT_USER}:$${ETCD_ROOT_PASSWORD} role grant-permission openim-role --prefix=true readwrite "" || true
etcdctl --endpoints=http://127.0.0.1:2379 --user=$${ETCD_ROOT_USER}:$${ETCD_ROOT_PASSWORD} user grant-role $${ETCD_USERNAME} openim-role || true
etcdctl --endpoints=http://127.0.0.1:2379 user grant-role $${ETCD_ROOT_USER} $${ETCD_USERNAME} root || true
echo "OpenIM user recreated with required permissions"
if [ "$$auth" = yes ]; then
export ETCDCTL_USER="$$ETCD_ROOT_USER" ETCDCTL_PASSWORD="$$ETCD_ROOT_PASSWORD"
fi
status=$$(etcdctl auth status) || fail "Cannot verify authentication; check configured credentials."
case "$$status" in
*"Authentication Status: false"*)
if [ "$$auth" = yes ]; then
users=$$(etcdctl user list)
[ -z "$$users" ] || fail "Existing users with disabled authentication require manual review."
printf "%s\n%s\n" "$$ETCD_ROOT_PASSWORD" "$$ETCD_ROOT_PASSWORD" | etcdctl user add root >/dev/null
printf "%s\n%s\n" "$$ETCD_PASSWORD" "$$ETCD_PASSWORD" | etcdctl user add "$$ETCD_USERNAME" >/dev/null
etcdctl role add openim-role
etcdctl role grant-permission openim-role --prefix readwrite ""
etcdctl user grant-role "$$ETCD_USERNAME" openim-role
etcdctl user grant-role root root
etcdctl auth enable
else
echo "OpenIM user exists and has correct permissions"
etcdctl --endpoints=http://127.0.0.1:2379 --user=$${ETCD_USERNAME}:$${ETCD_PASSWORD} del /test/auth &>/dev/null
echo "etcd authentication is explicitly disabled; restrict access to the published ports."
fi
;;
*"Authentication Status: true"*)
[ "$$auth" = yes ] || fail "Existing authentication requires configured credentials."
;;
*) fail "Could not determine authentication status." ;;
esac
if [ "$$auth" = yes ]; then
etcdctl user get root >/dev/null
ETCDCTL_USER="$$ETCD_USERNAME" ETCDCTL_PASSWORD="$$ETCD_PASSWORD" etcdctl get /check_openim_component >/dev/null
fi
echo "Testing authentication with OpenIM user..."
if etcdctl --endpoints=http://127.0.0.1:2379 --user=$${ETCD_USERNAME}:$${ETCD_PASSWORD} put /test/auth "auth-works"; then
echo "Authentication working properly"
etcdctl --endpoints=http://127.0.0.1:2379 --user=$${ETCD_USERNAME}:$${ETCD_PASSWORD} del /test/auth
else
echo "WARNING: Authentication test failed"
fi
else
echo "No authentication credentials provided. Running in no-auth mode."
echo "To enable authentication, set ETCD_ROOT_USER, ETCD_ROOT_PASSWORD, ETCD_USERNAME, and ETCD_PASSWORD environment variables."
fi
tail -f /dev/null
'
echo "etcd startup complete."
wait "$$daemon"
restart: always
networks:
- openim
@ -211,6 +210,7 @@ services:
minio:
image: "${MINIO_IMAGE}"
user: root
ports:
- "10005:9000"
- "19090:9090"

92
go.mod
View File

@ -1,6 +1,6 @@
module github.com/openimsdk/open-im-server/v3
go 1.22.7
go 1.26.0
require (
firebase.google.com/go/v4 v4.14.1
@ -8,19 +8,18 @@ require (
github.com/gin-gonic/gin v1.9.1
github.com/go-playground/validator/v10 v10.20.0
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.1
github.com/golang-jwt/jwt/v4 v4.5.2
github.com/gorilla/websocket v1.5.1
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/mitchellh/mapstructure v1.5.0
github.com/openimsdk/protocol v0.0.73-alpha.17
github.com/openimsdk/tools v0.0.50-alpha.105
github.com/pkg/errors v0.9.1 // indirect
github.com/openimsdk/protocol v0.0.73-alpha.19
github.com/openimsdk/tools v0.0.50-alpha.126
github.com/prometheus/client_golang v1.18.0
github.com/stretchr/testify v1.10.0
github.com/stretchr/testify v1.12.1
go.mongodb.org/mongo-driver v1.14.0
google.golang.org/api v0.170.0
google.golang.org/grpc v1.71.0
google.golang.org/protobuf v1.36.4
google.golang.org/grpc v1.79.3
google.golang.org/protobuf v1.36.12
gopkg.in/yaml.v3 v3.0.1
)
@ -35,22 +34,25 @@ require (
github.com/hashicorp/golang-lru/v2 v2.0.7
github.com/kelindar/bitmap v1.5.2
github.com/likexian/gokit v0.25.13
github.com/openimsdk/gomake v0.0.15-alpha.11
github.com/openimsdk/gomake v0.0.19
github.com/redis/go-redis/v9 v9.4.0
github.com/robfig/cron/v3 v3.0.1
github.com/shirou/gopsutil v3.21.11+incompatible
github.com/spf13/viper v1.18.2
go.etcd.io/etcd/client/v3 v3.5.13
go.uber.org/automaxprocs v1.5.3
golang.org/x/sync v0.10.0
golang.org/x/sync v0.24.0
k8s.io/api v0.31.2
k8s.io/apimachinery v0.31.2
k8s.io/client-go v0.31.2
)
require (
atomicgo.dev/cursor v0.2.0 // indirect
atomicgo.dev/keyboard v0.2.10 // indirect
atomicgo.dev/schedule v0.1.0 // indirect
cloud.google.com/go v0.112.1 // indirect
cloud.google.com/go/compute/metadata v0.6.0 // indirect
cloud.google.com/go/compute/metadata v0.9.0 // indirect
cloud.google.com/go/firestore v1.15.0 // indirect
cloud.google.com/go/iam v1.1.7 // indirect
cloud.google.com/go/longrunning v0.5.5 // indirect
@ -76,12 +78,15 @@ require (
github.com/aws/aws-sdk-go-v2/service/sts v1.33.1 // indirect
github.com/aws/smithy-go v1.22.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bmatcuk/doublestar/v4 v4.10.3 // indirect
github.com/bytedance/sonic v1.11.6 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/clbanning/mxj v1.8.4 // indirect
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/containerd/console v1.0.5 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
@ -90,25 +95,26 @@ require (
github.com/eapache/go-resiliency v1.6.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/ebitengine/purego v0.11.2 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-zookeeper/zk v1.0.3 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/go-zookeeper/zk v1.0.4 // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/s2a-go v0.1.7 // indirect
@ -130,16 +136,19 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kelindar/simd v1.1.2 // indirect
github.com/klauspost/compress v1.17.7 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/klauspost/compress v1.20.3 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/klauspost/pgzip v1.2.7 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/lestrrat-go/strftime v1.0.6 // indirect
github.com/lestrrat-go/strftime v1.2.0 // indirect
github.com/lithammer/fuzzysearch v1.1.8 // indirect
github.com/lithammer/shortuuid v3.0.0+incompatible // indirect
github.com/lufia/plan9stats v0.0.0-20230110061619-bbe2e5e100de // indirect
github.com/magefile/mage v1.15.0 // indirect
github.com/lufia/plan9stats v0.0.0-20260802145828-341c2f0c90b5 // indirect
github.com/magefile/mage v1.17.2 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-runewidth v0.0.31 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/minio/md5-simd v1.1.2 // indirect
github.com/minio/minio-go/v7 v7.0.69 // indirect
@ -151,11 +160,11 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pierrec/lz4/v4 v4.1.21 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b // indirect
github.com/power-devops/perfstat v0.0.0-20260916203055-22a1a467d9f0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/pterm/pterm v0.12.84 // indirect
github.com/qiniu/go-sdk/v7 v7.18.2 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rs/xid v1.5.0 // indirect
@ -163,16 +172,17 @@ require (
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sercand/kuberesolver/v6 v6.0.1 // indirect
github.com/shirou/gopsutil/v3 v3.24.5 // indirect
github.com/shirou/gopsutil/v4 v4.26.9 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/stretchr/objx v0.5.3 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tencentyun/cos-go-sdk-v5 v0.7.47 // indirect
github.com/tklauser/go-sysconf v0.3.13 // indirect
github.com/tklauser/numcpus v0.7.0 // indirect
github.com/tklauser/go-sysconf v0.4.0 // indirect
github.com/tklauser/numcpus v0.12.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
@ -183,27 +193,27 @@ require (
go.etcd.io/etcd/api/v3 v3.5.13 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.13 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel v1.34.0 // indirect
go.opentelemetry.io/otel/metric v1.34.0 // indirect
go.opentelemetry.io/otel/trace v1.34.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.opentelemetry.io/otel v1.39.0 // indirect
go.opentelemetry.io/otel/metric v1.39.0 // indirect
go.opentelemetry.io/otel/trace v1.39.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.yaml.in/yaml/v3 v3.0.5 // indirect
golang.org/x/arch v0.7.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/image v0.15.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/oauth2 v0.25.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/term v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/image v0.39.0 // indirect
golang.org/x/net v0.56.0 // indirect
golang.org/x/oauth2 v0.34.0 // indirect
golang.org/x/sys v0.49.0 // indirect
golang.org/x/term v0.47.0 // indirect
golang.org/x/text v0.43.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/appengine/v2 v2.0.2 // indirect
google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250106144421-5f5ef82da422 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gorm.io/gorm v1.25.8 // indirect
@ -221,7 +231,7 @@ require (
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/spf13/cobra v1.8.0
github.com/ugorji/go/codec v1.2.12 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.32.0 // indirect
go.uber.org/zap v1.28.0 // indirect
golang.org/x/crypto v0.53.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
)

219
go.sum
View File

@ -1,8 +1,16 @@
atomicgo.dev/assert v0.0.2 h1:FiKeMiZSgRrZsPo9qn/7vmr7mCsh5SZyXY4YGYiYwrg=
atomicgo.dev/assert v0.0.2/go.mod h1:ut4NcI3QDdJtlmAxQULOmA13Gz6e2DWbSAS8RUOmNYQ=
atomicgo.dev/cursor v0.2.0 h1:H6XN5alUJ52FZZUkI7AlJbUc1aW38GWZalpYRPpoPOw=
atomicgo.dev/cursor v0.2.0/go.mod h1:Lr4ZJB3U7DfPPOkbH7/6TOtJ4vFGHlgj1nc+n900IpU=
atomicgo.dev/keyboard v0.2.10 h1:v7mvUKUZLHIggxULEIuWbT+WkkyQSgdbA201EziAhHU=
atomicgo.dev/keyboard v0.2.10/go.mod h1:ap/z5ilnhLqYq852m6kPeTq5Z6aESGWu5mzRpJlC6aI=
atomicgo.dev/schedule v0.1.0 h1:nTthAbhZS5YZmgYbb2+DH8uQIZcTlIrd4eYr3UQxEjs=
atomicgo.dev/schedule v0.1.0/go.mod h1:xeUa3oAkiuHYh8bKiQBRojqAMq3PXXbJujjb0hw8pEU=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.112.1 h1:uJSeirPke5UNZHIb4SxfZklVSiWWVqW4oXlETwZziwM=
cloud.google.com/go v0.112.1/go.mod h1:+Vbu+Y1UU+I1rjmzeMOb/8RfkKJK2Gyxi1X6jJCZLo4=
cloud.google.com/go/compute/metadata v0.6.0 h1:A6hENjEsCDtC1k8byVsgwvVcioamEHvZ4j01OwKxG9I=
cloud.google.com/go/compute/metadata v0.6.0/go.mod h1:FjyFAW1MW0C203CEOMDTu3Dk1FlqW3Rga40jzHL4hfg=
cloud.google.com/go/compute/metadata v0.9.0 h1:pDUj4QMoPejqq20dK0Pg2N4yG9zIkYGdBtwLoEkH9Zs=
cloud.google.com/go/compute/metadata v0.9.0/go.mod h1:E0bWwX5wTnLPedCKqk3pJmVgCBSM6qQI1yTBdEb3C10=
cloud.google.com/go/firestore v1.15.0 h1:/k8ppuWOtNuDHt2tsRV42yI21uaGnKDEQnRFeBpbFF8=
cloud.google.com/go/firestore v1.15.0/go.mod h1:GWOxFXcv8GZUtYpWHw/w6IuYNux/BtmeVTMmjrm4yhk=
cloud.google.com/go/iam v1.1.7 h1:z4VHOhwKLF/+UYXAJDFwGtNF0b6gjsW1Pk9Ml0U/IoM=
@ -16,6 +24,8 @@ firebase.google.com/go/v4 v4.14.1/go.mod h1:fgk2XshgNDEKaioKco+AouiegSI9oTWVqRaB
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/IBM/sarama v1.43.0 h1:YFFDn8mMI2QL0wOrG0J2sFoVIAFl7hS9JQi2YZsXtJc=
github.com/IBM/sarama v1.43.0/go.mod h1:zlE6HEbC/SMQ9mhEYaF7nNLYOUyrs0obySKCckWP9BM=
github.com/MarvinJWendt/testza v0.5.2 h1:53KDo64C1z/h/d/stCYCPY69bt/OSwjq5KpFNwi+zB4=
github.com/MarvinJWendt/testza v0.5.2/go.mod h1:xu53QFE5sCdjtMCKk8YMQ2MnymimEctc4n3EjyIYvEY=
github.com/MicahParks/keyfunc v1.9.0 h1:lhKd5xrFHLNOWrDc4Tyb/Q1AJ4LCzQ48GVJyVIID3+o=
github.com/MicahParks/keyfunc v1.9.0/go.mod h1:IdnCilugA0O/99dW+/MkvlyrsX8+L8+x95xuVNtM5jw=
github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM=
@ -57,10 +67,10 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.33.1 h1:6SZUVRQNvExYlMLbHdlKB48x0fLb
github.com/aws/aws-sdk-go-v2/service/sts v1.33.1/go.mod h1:GqWyYCwLXnlUB1lOAXQyNSPqPLQJvmo8J0DWBzp9mtg=
github.com/aws/smithy-go v1.22.1 h1:/HPHZQ0g7f4eUeK6HKglFz8uwVfZKgoI25rb/J+dnro=
github.com/aws/smithy-go v1.22.1/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bmatcuk/doublestar/v4 v4.10.3 h1:1UIv1+fqH3++ViVkpnaPTB+Pi1UHycnPFAq14zgK+gI=
github.com/bmatcuk/doublestar/v4 v4.10.3/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
@ -75,11 +85,17 @@ github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL
github.com/clbanning/mxj v1.8.4 h1:HuhwZtbyvyOw+3Z1AowPkU87JkJUSv751ELWaiTpj8I=
github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk=
github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM=
github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y=
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/xds/go v0.0.0-20251210132809-ee656c7534f5 h1:6xNmx7iTtyBRev0+D/Tv1FZd4SCg8axKApyNyRsAt/w=
github.com/cncf/xds/go v0.0.0-20251210132809-ee656c7534f5/go.mod h1:KdCmV+x/BuvyMxRnYBlmVaq4OLiKW6iRQfvC62cvdkI=
github.com/containerd/console v1.0.5 h1:R0ymNeydRqH2DmakFNdmjR2k0t7UPuiOV/N/27/qqsc=
github.com/containerd/console v1.0.5/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk=
github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM=
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI=
@ -103,12 +119,19 @@ github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 h1:Oy0F4A
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3/go.mod h1:YvSRo5mw33fLEx1+DlK6L2VV43tJt5Eyel9n9XBcR+0=
github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc=
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
github.com/ebitengine/purego v0.11.2 h1:WWiTx8rD8zYdOwSj8O/NiNbsOvSAgJMTlyV1XlbUSeU=
github.com/ebitengine/purego v0.11.2/go.mod h1:DCHPP08djqhNSoTfImcnHYQRZmd0qhakvrozqaEYhGQ=
github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g=
github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/go-control-plane v0.14.0 h1:hbG2kr4RuFj222B6+7T83thSPqLjwBIfQawTkC++2HA=
github.com/envoyproxy/go-control-plane/envoy v1.36.0 h1:yg/JjO5E7ubRyKX3m07GF3reDNEnfOboJ0QySbH736g=
github.com/envoyproxy/go-control-plane/envoy v1.36.0/go.mod h1:ty89S1YCCVruQAm9OtKeEkQLTb+Lkz0k8v9W0Oxsv98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/envoyproxy/protoc-gen-validate v1.3.0 h1:TvGH1wof4H33rezVKWSpqKz5NXWg5VPuZ0uONDT6eb4=
github.com/envoyproxy/protoc-gen-validate v1.3.0/go.mod h1:HvYl7zwPa5mffgyeTUHA9zHIH36nmrm7oCbo4YKoSWA=
github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w=
github.com/fatih/color v1.14.1/go.mod h1:2oHN61fhTpgcxD3TSWCgKDiH1+x4OiDVVGH8WlgGZGg=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
@ -130,12 +153,13 @@ github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm
github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE=
github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs=
github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE=
@ -163,20 +187,20 @@ github.com/go-redis/redismock/v9 v9.2.0 h1:ZrMYQeKPECZPjOj5u9eyOjg8Nnb0BS9lkVIZ6
github.com/go-redis/redismock/v9 v9.2.0/go.mod h1:18KHfGDK4Y6c2R0H38EUGWAdc7ZQS9gfYxc94k7rWT0=
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
github.com/go-zookeeper/zk v1.0.3 h1:7M2kwOsc//9VeeFiPtf+uSJlVpU66x9Ba5+8XK7/TDg=
github.com/go-zookeeper/zk v1.0.3/go.mod h1:nOB03cncLtlp4t+UAkGSV+9beXP/akpekBwL+UX1Qcw=
github.com/go-zookeeper/zk v1.0.4 h1:DPzxraQx7OrPyXq2phlGlNSIyWEsAox0RJmjTseMV6I=
github.com/go-zookeeper/zk v1.0.4/go.mod h1:nOB03cncLtlp4t+UAkGSV+9beXP/akpekBwL+UX1Qcw=
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo=
github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang-jwt/jwt/v4 v4.5.2 h1:YtQM7lnr8iZ+j5q71MGKkNw9Mn7AjHM68uc9g5fXeUI=
github.com/golang-jwt/jwt/v4 v4.5.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ=
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
@ -202,8 +226,8 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
@ -262,8 +286,8 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jonboulle/clockwork v0.4.0 h1:p4Cf1aMWXnXAUh8lVfewRBx1zaTSYKrKMF2g3ST4RZ4=
github.com/jonboulle/clockwork v0.4.0/go.mod h1:xgRqUGwRcjKCO1vbZUEtSLrqKoPSsUpK7fnezOII0kc=
github.com/jonboulle/clockwork v0.5.0 h1:Hyh9A8u51kptdkR+cqRpT1EebBwTn1oK9YfGYbdFz6I=
github.com/jonboulle/clockwork v0.5.0/go.mod h1:3mZlmanh0g2NDKO5TWZVJAfofYk64M7XN3SzBPjZF60=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
@ -274,12 +298,14 @@ github.com/kelindar/simd v1.1.2 h1:KduKb+M9cMY2HIH8S/cdJyD+5n5EGgq+Aeeleos55To=
github.com/kelindar/simd v1.1.2/go.mod h1:inq4DFudC7W8L5fhxoeZflLRNpWSs0GNx6MlWFvuvr0=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg=
github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/klauspost/compress v1.20.3 h1:zWNoFqq/lSuYQRim3dUXlXeA0IqwuZGicdG5ZTfY5j4=
github.com/klauspost/compress v1.20.3/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
github.com/klauspost/pgzip v1.2.7 h1:02QB3Ttao6zOWDnSsv3bIvjN24bX0eGjWniQ8vuBfkA=
github.com/klauspost/pgzip v1.2.7/go.mod h1:g7E6NrOKHOzah4QwK6Ue1tNCJs8IDiNOfjiXTr85U2E=
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
@ -297,16 +323,18 @@ github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc h1:RKf14vYWi2t
github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc/go.mod h1:kopuH9ugFRkIXf3YoqHKyrJ9YfUFsckUU9S7B+XP+is=
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible h1:Y6sqxHMyB1D2YSzWkLibYKgg+SwmyFU9dF2hn6MdTj4=
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible/go.mod h1:ZQnN8lSECaebrkQytbHj4xNgtg8CR7RYXnPok8e0EHA=
github.com/lestrrat-go/strftime v1.0.6 h1:CFGsDEt1pOpFNU+TJB0nhz9jl+K0hZSLE205AhTIGQQ=
github.com/lestrrat-go/strftime v1.0.6/go.mod h1:f7jQKgV5nnJpYgdEasS+/y7EsTb8ykN2z68n3TtcTaw=
github.com/lestrrat-go/strftime v1.2.0 h1:8fAUYOeaJKCuLzNvUWBAo8t6I6hkFfodDTndEzJIun0=
github.com/lestrrat-go/strftime v1.2.0/go.mod h1:GtsIA/7ddIGJjEdfadUafEb1sbutvlvpMdPCMglykYo=
github.com/likexian/gokit v0.25.13 h1:p2Uw3+6fGG53CwdU2Dz0T6bOycdb2+bAFAa3ymwWVkM=
github.com/likexian/gokit v0.25.13/go.mod h1:qQhEWFBEfqLCO3/vOEo2EDKd+EycekVtUK4tex+l2H4=
github.com/lithammer/fuzzysearch v1.1.8 h1:/HIuJnjHuXS8bKaiTMeeDlW2/AyIWk2brx1V8LFgLN4=
github.com/lithammer/fuzzysearch v1.1.8/go.mod h1:IdqeyBClc3FFqSzYq/MXESsS4S0FsZ5ajtkr5xPLts4=
github.com/lithammer/shortuuid v3.0.0+incompatible h1:NcD0xWW/MZYXEHa6ITy6kaXN5nwm/V115vj2YXfhS0w=
github.com/lithammer/shortuuid v3.0.0+incompatible/go.mod h1:FR74pbAuElzOUuenUHTK2Tciko1/vKuIKS9dSkDrA4w=
github.com/lufia/plan9stats v0.0.0-20230110061619-bbe2e5e100de h1:V53FWzU6KAZVi1tPp5UIsMoUWJ2/PNwYIDXnu7QuBCE=
github.com/lufia/plan9stats v0.0.0-20230110061619-bbe2e5e100de/go.mod h1:JKx41uQRwqlTZabZc+kILPrO/3jlKnQ2Z8b7YiVw5cE=
github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg=
github.com/magefile/mage v1.15.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
github.com/lufia/plan9stats v0.0.0-20260802145828-341c2f0c90b5 h1:eveIIGn4BGM3qknO74omf6HYr30/exH+eVUTuAgwjZ0=
github.com/lufia/plan9stats v0.0.0-20260802145828-341c2f0c90b5/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg=
github.com/magefile/mage v1.17.2 h1:fyXVu1eadI8Ap1HCCNgEhJ5McIWiYhLR8uol64ZZc40=
github.com/magefile/mage v1.17.2/go.mod h1:Yj51kqllmsgFpvvSzgrZPK9WtluG3kUhFaBUVLo4feA=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
@ -316,6 +344,8 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.31 h1:1oCV4ReTlosDBc6rYRw5cL8S/4y8iv5oRl4SJ5IBgwo=
github.com/mattn/go-runewidth v0.0.31/go.mod h1:3qAiGCV4Koz/yuveO58qUefmUTRm8r0IGEXZ9jeHp/8=
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg=
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k=
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
@ -347,12 +377,12 @@ github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA
github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To=
github.com/onsi/gomega v1.25.0 h1:Vw7br2PCDYijJHSfBOWhov+8cAnUf8MfMaIOV323l6Y=
github.com/onsi/gomega v1.25.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM=
github.com/openimsdk/gomake v0.0.15-alpha.11 h1:PQudYDRESYeYlUYrrLLJhYIlUPO5x7FAx+o5El9U/Bw=
github.com/openimsdk/gomake v0.0.15-alpha.11/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI=
github.com/openimsdk/protocol v0.0.73-alpha.17 h1:ddo0QMns1GVwAmrPIPlAQ7uKmThAYLnOt+CIOgLsJyE=
github.com/openimsdk/protocol v0.0.73-alpha.17/go.mod h1:WF7EuE55vQvpyUAzDXcqg+B+446xQyEba0X35lTINmw=
github.com/openimsdk/tools v0.0.50-alpha.105 h1:axuCvKXhxY2RGLhpMMFNgBtE0B65T2Sr1JDW3UD9nBs=
github.com/openimsdk/tools v0.0.50-alpha.105/go.mod h1:x9i/e+WJFW4tocy6RNJQ9NofQiP3KJ1Y576/06TqOG4=
github.com/openimsdk/gomake v0.0.19 h1:uzplTl/xDUQ9m6BRk1qFgn/IF8fSXxKqFHp00K6wZf8=
github.com/openimsdk/gomake v0.0.19/go.mod h1:pWidqX7Q1455YlWjx9A5OJoirMYh4QIQY+jW7dUw2y8=
github.com/openimsdk/protocol v0.0.73-alpha.19 h1:CvXoDF2U73UcMhLnrtMFks2Aw+bXiDgH8AITEt783/s=
github.com/openimsdk/protocol v0.0.73-alpha.19/go.mod h1:WF7EuE55vQvpyUAzDXcqg+B+446xQyEba0X35lTINmw=
github.com/openimsdk/tools v0.0.50-alpha.126 h1:wJ3eIR4Y/ZKz1m+m4osV4K5w5aiHmmA9QqJVkp45nFk=
github.com/openimsdk/tools v0.0.50-alpha.126/go.mod h1:3d0x4v/6/0Gdr/8si5+cRJrVHDfr79E1IXQ3eQLxQ7k=
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
@ -360,11 +390,11 @@ github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFu
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 h1:GFCKgmp0tecUJ0sJuv4pzYCqS9+RGSn52M3FUwPs+uo=
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10/go.mod h1:t/avpk3KcrXxUnYOhZhMXJlSEyie6gQbtLq5NM3loB8=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b h1:0LFwY6Q3gMACTjAbMZBjXAqTOzOwFaj2Ld6cjeQ7Rig=
github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
github.com/power-devops/perfstat v0.0.0-20260916203055-22a1a467d9f0 h1:XA01Vk/wv9YikCi1V51yRzIHPMT5of9+cMpZoZvDn/M=
github.com/power-devops/perfstat v0.0.0-20260916203055-22a1a467d9f0/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U=
github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk=
@ -376,6 +406,8 @@ github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lne
github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY=
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
github.com/pterm/pterm v0.12.84 h1:DA9943h1RfwlpcGWCIbD6f6nRTLCe09gK7w6GDXaIzE=
github.com/pterm/pterm v0.12.84/go.mod h1:LVerZ1tFVFZrTv7lRbLdbrrTLSLAB5oZY8z3IY/z+IQ=
github.com/qiniu/dyn v1.3.0/go.mod h1:E8oERcm8TtwJiZvkQPbcAh0RL8jO1G0VXJMW3FAWdkk=
github.com/qiniu/go-sdk/v7 v7.18.2 h1:vk9eo5OO7aqgAOPF0Ytik/gt7CMKuNgzC/IPkhda6rk=
github.com/qiniu/go-sdk/v7 v7.18.2/go.mod h1:nqoYCNo53ZlGA521RvRethvxUDvXKt4gtYXOwye868w=
@ -388,8 +420,8 @@ github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
@ -399,10 +431,14 @@ github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6g
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
github.com/sercand/kuberesolver/v6 v6.0.1 h1:XZUTA0gy/lgDYp/UhEwv7Js24F1j8NJ833QrWv0Xux4=
github.com/sercand/kuberesolver/v6 v6.0.1/go.mod h1:C0tsTuRMONSY+Xf7pv7RMW1/JlewY1+wS8SZE+1lf1s=
github.com/sergi/go-diff v1.4.0 h1:n/SP9D5ad1fORl+llWyN+D6qoUETXNZARKjyY2/KVCw=
github.com/sergi/go-diff v1.4.0/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=
github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/gopsutil/v3 v3.24.5 h1:i0t8kL+kQTvpAYToeuiVk3TgDeKOFioZO3Ztz/iZ9pI=
github.com/shirou/gopsutil/v3 v3.24.5/go.mod h1:bsoOS1aStSs9ErQ1WWfxllSeS1K5D+U30r2NfcubMVk=
github.com/shirou/gopsutil/v4 v4.26.9 h1:CaBo/hBFqvlJoLvAQEKdHdf5GD97/MN2ACfyv63+2Ig=
github.com/shirou/gopsutil/v4 v4.26.9/go.mod h1:nKH+8wX2zxr/mDbsR+AAy6Qd2z4ZOQ7wfQaEp+yrYmg=
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=
github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
@ -422,8 +458,9 @@ github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMV
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/objx v0.5.3 h1:jmXUvGomnU1o3W/V5h2VEradbpJDwGrzugQQvL0POH4=
github.com/stretchr/objx v0.5.3/go.mod h1:rDQraq+vQZU7Fde9LOZLr8Tax6zZvy4kuNKF+QYS+U0=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
@ -433,18 +470,18 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE=
github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.563/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/kms v1.0.563/go.mod h1:uom4Nvi9W+Qkom0exYiJ9VWJjXwyxtPYTkKkaLMlfE0=
github.com/tencentyun/cos-go-sdk-v5 v0.7.47 h1:uoS4Sob16qEYoapkqJq1D1Vnsy9ira9BfNUMtoFYTI4=
github.com/tencentyun/cos-go-sdk-v5 v0.7.47/go.mod h1:DH9US8nB+AJXqwu/AMOrCFN1COv3dpytXuJWHgdg7kE=
github.com/tklauser/go-sysconf v0.3.13 h1:GBUpcahXSpR2xN01jhkNAbTLRk2Yzgggk8IM08lq3r4=
github.com/tklauser/go-sysconf v0.3.13/go.mod h1:zwleP4Q4OehZHGn4CYZDipCgg9usW5IJePewFCGVEa0=
github.com/tklauser/numcpus v0.7.0 h1:yjuerZP127QG9m5Zh/mSO4wqurYil27tHrqwRoRjpr4=
github.com/tklauser/numcpus v0.7.0/go.mod h1:bb6dMVcj8A42tSE7i32fsIUCbQNllK5iDguyOZRUzAY=
github.com/tklauser/go-sysconf v0.4.0 h1:7H0uAN+7RkwWRaxhYXDLqa5V3LPrJeV8wmD9dRUgPQU=
github.com/tklauser/go-sysconf v0.4.0/go.mod h1:8mTNWyog7H+MpKijp4VmKJAd2bbYQ2zuUwkYRbUArPI=
github.com/tklauser/numcpus v0.12.0 h1:NR85qdvHA9pFse3x3weVZ0r0ST8R6l5RHbZrlRaqob4=
github.com/tklauser/numcpus v0.12.0/go.mod h1:ABHeXzJnr/qqwguhClkZKT1/8VABcYrsyUiUGobwWJg=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
@ -474,32 +511,32 @@ go.mongodb.org/mongo-driver v1.14.0 h1:P98w8egYRjYe3XDjxhYJagTokP/H6HzlsnojRgZRd
go.mongodb.org/mongo-driver v1.14.0/go.mod h1:Vzb0Mk/pa7e6cWw85R4F/endUC3u0U9jGcNU603k65c=
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 h1:4Pp6oUg3+e/6M4C0A/3kJ2VYa++dsWVTtGgLVj5xtHg=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0/go.mod h1:Mjt1i1INqiaoZOMGR1RIUJN+i3ChKoFRqzrRQhlkbs0=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw=
go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY=
go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI=
go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ=
go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE=
go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7Wr1A=
go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU=
go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk=
go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w=
go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k=
go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE=
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.opentelemetry.io/otel v1.39.0 h1:8yPrr/S0ND9QEfTfdP9V+SiwT4E0G7Y5MO7p85nis48=
go.opentelemetry.io/otel v1.39.0/go.mod h1:kLlFTywNWrFyEdH0oj2xK0bFYZtHRYUdv1NklR/tgc8=
go.opentelemetry.io/otel/metric v1.39.0 h1:d1UzonvEZriVfpNKEVmHXbdf909uGTOQjA0HF0Ls5Q0=
go.opentelemetry.io/otel/metric v1.39.0/go.mod h1:jrZSWL33sD7bBxg1xjrqyDjnuzTUB0x1nBERXd7Ftcs=
go.opentelemetry.io/otel/sdk v1.39.0 h1:nMLYcjVsvdui1B/4FRkwjzoRVsMK8uL/cj0OyhKzt18=
go.opentelemetry.io/otel/sdk v1.39.0/go.mod h1:vDojkC4/jsTJsE+kh+LXYQlbL8CgrEcwmt1ENZszdJE=
go.opentelemetry.io/otel/sdk/metric v1.39.0 h1:cXMVVFVgsIf2YL6QkRF4Urbr/aMInf+2WKg+sEJTtB8=
go.opentelemetry.io/otel/sdk/metric v1.39.0/go.mod h1:xq9HEVH7qeX69/JnwEfp6fVq5wosJsY1mt4lLfYdVew=
go.opentelemetry.io/otel/trace v1.39.0 h1:2d2vfpEDmCJ5zVYz7ijaJdOF59xLomrvj7bjt6/qCJI=
go.opentelemetry.io/otel/trace v1.39.0/go.mod h1:88w4/PnZSazkGzz/w84VHpQafiU4EtqqlVdxWy+rNOA=
go.uber.org/automaxprocs v1.5.3 h1:kWazyxZUrS3Gs4qUpbwo5kEIMGe/DAvi5Z4tl2NW4j8=
go.uber.org/automaxprocs v1.5.3/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
go.uber.org/zap v1.28.0 h1:IZzaP1Fv73/T/pBMLk4VutPl36uNC+OSUh3JLG3FIjo=
go.uber.org/zap v1.28.0/go.mod h1:rDLpOi171uODNm/mxFcuYWxDsqWSAVkFdX4XojSKg/Q=
go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw=
go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/arch v0.7.0 h1:pskyeJh/3AmoQ8CPE95vxHLqp1G1GfGNXTmcl9NEKTc=
golang.org/x/arch v0.7.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
@ -510,19 +547,20 @@ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5y
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
golang.org/x/crypto v0.53.0 h1:QZ4Muo8THX6CizN2vPPd5fBGHyogrdK9fG4wLPFUsto=
golang.org/x/crypto v0.53.0/go.mod h1:DNLU434OwVakk9PzuwV8w62mAJpRJL3vsgcfp4Qnsio=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
golang.org/x/image v0.15.0 h1:kOELfmgrmJlw4Cdb7g/QGuB3CvDrXbqEIww/pNtNBm8=
golang.org/x/image v0.15.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE=
golang.org/x/image v0.39.0 h1:skVYidAEVKgn8lZ602XO75asgXBgLj9G/FE3RbuPFww=
golang.org/x/image v0.39.0/go.mod h1:sIbmppfU+xFLPIG0FoVUTvyBMmgng1/XAMhQ2ft0hpA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@ -539,19 +577,20 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
golang.org/x/net v0.56.0 h1:Rw8j/hFzGvJUZwNBXnAtf5sVDVt+65SK2C7IxCxZt5o=
golang.org/x/net v0.56.0/go.mod h1:D3Ku6r+V6JROoZK144D2XfMHFcMq/0zSfLelVTCFKec=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.25.0 h1:CY4y7XT9v0cRI9oupztF8AgiIu99L/ksR/Xp/6jrZ70=
golang.org/x/oauth2 v0.25.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/oauth2 v0.34.0 h1:hqK/t4AKgbqWkdkcAeI8XLmbK+4m4G5YeQRrmiotGlw=
golang.org/x/oauth2 v0.34.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.24.0 h1:iqiDrGoDgyuvAKrhLQthUEzU/R378N78gXbBjxed7oA=
golang.org/x/sync v0.24.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@ -567,14 +606,14 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.49.0 h1:XbzkgYJHdqh/8m2Uu0W/dQv8nktxx4BFHp1M0gROTXA=
golang.org/x/sys v0.49.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg=
golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
golang.org/x/term v0.47.0 h1:cpyOwQkr2Nzxe2p6KnrTG7Ei2wtzjsuSjhpXXepZ/BM=
golang.org/x/term v0.47.0/go.mod h1:efAfAuG6RKABvg1ArGebRkvX6LXul14SM67o2e4mUCY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
@ -583,8 +622,9 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.43.0 h1:1QivrlhwAsnMOcqgOdl9my7s9OyZl8O5/UGUTJVXoWc=
golang.org/x/text v0.43.0/go.mod h1:hbSIYA/amXcRXTFSZqh8tWHEoqRvvbKPJ2uz/KU+a+s=
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@ -596,14 +636,17 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.51.0 h1:k4Xc/1Om9jwkBJBo4NVLMSARBoWtK10mx+W5BnXCeAI=
golang.org/x/tools v0.51.0/go.mod h1:9eEncMayCV6zRMGhR5eZEC2iBx98qWcF1HZ9Z7wJOoA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU=
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90=
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
google.golang.org/api v0.170.0 h1:zMaruDePM88zxZBG+NG8+reALO2rfLhe/JShitLyT48=
google.golang.org/api v0.170.0/go.mod h1:/xql9M2btF85xac/VAm4PsLMTLVGUOpq4BE9R8jyNy8=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
@ -615,17 +658,17 @@ google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 h1:9+tzLLstTlPTRyJTh+ah5wIMsBW5c4tQwGTN3thOW9Y=
google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9/go.mod h1:mqHbVIp48Muh7Ywss/AD6I5kNVKZMmAa/QEW58Gxp2s=
google.golang.org/genproto/googleapis/api v0.0.0-20250106144421-5f5ef82da422 h1:GVIKPyP/kLIyVOgOnTwFOrvQaQUzOzGMCxgFUOEmm24=
google.golang.org/genproto/googleapis/api v0.0.0-20250106144421-5f5ef82da422/go.mod h1:b6h1vNKhxaSoEI+5jc3PJUCustfli/mRab7295pY7rw=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f h1:OxYkA3wjPsZyBylwymxSHa7ViiW1Sml4ToBrncvFehI=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f/go.mod h1:+2Yz8+CLJbIfL9z73EW45avw8Lmge3xVElCP9zEKi50=
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 h1:fCvbg86sFXwdrl5LgVcTEvNC+2txB5mgROGmRL5mrls=
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217/go.mod h1:+rXWjjaukWZun3mLfjmVnQi18E1AsFbDN9QdJ5YXLto=
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 h1:gRkg/vSppuSQoDjxyiGfN4Upv/h/DQmIR10ZU8dh4Ww=
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
google.golang.org/grpc v1.71.0 h1:kF77BGdPTQ4/JZWMlb9VpJ5pa25aqvVqogsxNHHdeBg=
google.golang.org/grpc v1.71.0/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec=
google.golang.org/grpc v1.79.3 h1:sybAEdRIEtvcD68Gx7dmnwjZKlyfuc61Dyo9pGXXkKE=
google.golang.org/grpc v1.79.3/go.mod h1:KmT0Kjez+0dde/v2j9vzwoAScgEPx/Bw1CYChhHLrHQ=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
@ -635,8 +678,8 @@ google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM=
google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc=
google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=

View File

@ -23,13 +23,14 @@ import (
"strconv"
"time"
"google.golang.org/grpc"
conf "github.com/openimsdk/open-im-server/v3/pkg/common/config"
"github.com/openimsdk/tools/discovery"
"github.com/openimsdk/tools/log"
"github.com/openimsdk/tools/utils/datautil"
"github.com/openimsdk/tools/utils/network"
"github.com/openimsdk/tools/utils/runtimeenv"
"google.golang.org/grpc"
)
type Config struct {
@ -77,18 +78,6 @@ func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryReg
apiCancel(err)
}()
//if config.Discovery.Enable == conf.ETCD {
// cm := disetcd.NewConfigManager(client.(*etcd.SvcDiscoveryRegistryImpl).GetClient(), config.GetConfigNames())
// cm.Watch(ctx)
//}
//sigs := make(chan os.Signal, 1)
//signal.Notify(sigs, syscall.SIGTERM)
//select {
//case val := <-sigs:
// log.ZDebug(ctx, "recv exit", "signal", val.String())
// cancel(fmt.Errorf("signal %s", val.String()))
//case <-ctx.Done():
//}
<-apiCtx.Done()
exitCause := context.Cause(apiCtx)
log.ZWarn(ctx, "api server exit", exitCause)

View File

@ -143,14 +143,16 @@ func (x *JSSdk) getActiveConversations(ctx context.Context, req *jssdk.GetActive
if err != nil {
return nil, err
}
msgs, err := x.msgClient.GetSeqMessage(ctx, req.OwnerUserID, datautil.Slice(sortList, func(c *msg.ActiveConversation) *msg.ConversationSeqs {
return &msg.ConversationSeqs{
ConversationID: c.ConversationID,
Seqs: []int64{c.MaxSeq},
maxSeqs := datautil.SliceToMapAny(sortList, func(c *msg.ActiveConversation) (string, int64) {
return c.ConversationID, c.MaxSeq
})
conversationSeqs := x.filterConversationSeqs(conversations, maxSeqs)
var msgs map[string]*sdkws.PullMsgs
if len(conversationSeqs) > 0 {
msgs, err = x.msgClient.GetSeqMessage(ctx, req.OwnerUserID, conversationSeqs)
if err != nil {
return nil, err
}
}))
if err != nil {
return nil, err
}
x.checkMessagesAndGetLastMessage(ctx, req.OwnerUserID, msgs)
conversationMap := datautil.SliceToMap(conversations, func(c *conversation.Conversation) string {
@ -208,15 +210,7 @@ func (x *JSSdk) getConversations(ctx context.Context, req *jssdk.GetConversation
if err != nil {
return nil, err
}
conversationSeqs := make([]*msg.ConversationSeqs, 0, len(conversations))
for _, c := range conversations {
if seq := maxSeqs[c.ConversationID]; seq > 0 {
conversationSeqs = append(conversationSeqs, &msg.ConversationSeqs{
ConversationID: c.ConversationID,
Seqs: []int64{seq},
})
}
}
conversationSeqs := x.filterConversationSeqs(conversations, maxSeqs)
var msgs map[string]*sdkws.PullMsgs
if len(conversationSeqs) > 0 {
msgs, err = x.msgClient.GetSeqMessage(ctx, req.OwnerUserID, conversationSeqs)
@ -253,6 +247,21 @@ func (x *JSSdk) getConversations(ctx context.Context, req *jssdk.GetConversation
}, nil
}
func (x *JSSdk) filterConversationSeqs(conversations []*conversation.Conversation, maxSeqs map[string]int64) []*msg.ConversationSeqs {
conversationSeqs := make([]*msg.ConversationSeqs, 0, len(conversations))
for _, c := range conversations {
seq := maxSeqs[c.ConversationID]
if seq == 0 || (c.MinSeq > 0 && seq < c.MinSeq) {
continue
}
conversationSeqs = append(conversationSeqs, &msg.ConversationSeqs{
ConversationID: c.ConversationID,
Seqs: []int64{seq},
})
}
return conversationSeqs
}
// This function checks whether the latest MaxSeq message is valid.
// If not, it needs to fetch a valid message again.
func (x *JSSdk) checkMessagesAndGetLastMessage(ctx context.Context, userID string, messages map[string]*sdkws.PullMsgs) {

View File

@ -9,6 +9,8 @@ import (
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
"github.com/go-playground/validator/v10"
clientv3 "go.etcd.io/etcd/client/v3"
"github.com/openimsdk/open-im-server/v3/internal/api/jssdk"
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
@ -23,13 +25,15 @@ import (
"github.com/openimsdk/protocol/relation"
"github.com/openimsdk/protocol/third"
"github.com/openimsdk/protocol/user"
"github.com/openimsdk/tools/a2r"
"github.com/openimsdk/tools/apiresp"
"github.com/openimsdk/tools/discovery"
"github.com/openimsdk/tools/discovery/etcd"
"github.com/openimsdk/tools/discovery/inprocess"
"github.com/openimsdk/tools/log"
"github.com/openimsdk/tools/mcontext"
"github.com/openimsdk/tools/mw"
"github.com/openimsdk/tools/mw/api"
clientv3 "go.etcd.io/etcd/client/v3"
)
const (
@ -341,9 +345,55 @@ func newGinRouter(ctx context.Context, client discovery.SvcDiscoveryRegistry, cf
{
r.POST("/restart", cm.CheckAdmin, cm.Restart)
}
if config.Standalone() {
a := internalApi{secret: cfg.Share.Secret, client: client}
r.POST(inprocess.BroadcastPath, a.RpcInvoke)
}
return r, nil
}
type internalApi struct {
secret string
client discovery.SvcDiscoveryRegistry
}
func (x *internalApi) RpcInvoke(c *gin.Context) {
req, err := a2r.ParseRequestNotCheck[inprocess.InvokeRequest](c)
if err != nil {
apiresp.GinError(c, err)
return
}
// Request length is deliberately not validated: a proto request whose fields
// are all default values marshals to zero bytes.
if req.Service == "" || req.Method == "" || req.Secret == "" {
apiresp.GinError(c, servererrs.ErrArgs)
return
}
if req.Secret != x.secret {
apiresp.GinError(c, servererrs.ErrNoPermission.WrapMsg("secret not match"))
return
}
ctx := context.Context(c)
if req.OpUserID != "" {
ctx = mcontext.SetOpUserID(ctx, req.OpUserID)
}
if req.Admin {
ctx = authverify.WithTempAdmin(ctx)
}
cc, err := x.client.GetConn(ctx, req.Service)
if err != nil {
apiresp.GinError(c, err)
return
}
var resp []byte
if err := cc.Invoke(ctx, req.Method, req.Request, &resp); err != nil {
apiresp.GinError(c, err)
return
}
apiresp.GinSuccess(c, resp)
}
func GinParseToken(authClient *rpcli.AuthClient) gin.HandlerFunc {
return func(c *gin.Context) {
switch c.Request.Method {
@ -385,4 +435,6 @@ func setGinIsAdmin(imAdminUserID []string) gin.HandlerFunc {
var Whitelist = []string{
"/auth/get_admin_token",
"/auth/parse_token",
// cross-instance rpc invoke authenticates with share.secret instead of token
inprocess.BroadcastPath,
}

View File

@ -16,7 +16,6 @@ package msggateway
import (
"context"
"encoding/json"
"fmt"
"sync"
"sync/atomic"
@ -31,7 +30,6 @@ import (
"github.com/openimsdk/tools/errs"
"github.com/openimsdk/tools/log"
"github.com/openimsdk/tools/mcontext"
"github.com/openimsdk/tools/utils/stringutil"
)
var (
@ -64,7 +62,7 @@ type PingPongHandler func(string) error
type Client struct {
w *sync.Mutex
conn LongConn
conn ClientConn
PlatformID int `json:"platformID"`
IsCompress bool `json:"isCompress"`
UserID string `json:"userID"`
@ -84,10 +82,10 @@ type Client struct {
}
// ResetClient updates the client's state with new connection and context information.
func (c *Client) ResetClient(ctx *UserConnContext, conn LongConn, longConnServer LongConnServer) {
func (c *Client) ResetClient(ctx *UserConnContext, conn ClientConn, longConnServer LongConnServer) {
c.w = new(sync.Mutex)
c.conn = conn
c.PlatformID = stringutil.StringToInt(ctx.GetPlatformID())
c.PlatformID = ctx.GetPlatformID()
c.IsCompress = ctx.GetCompression()
c.IsBackground = ctx.GetBackground()
c.UserID = ctx.GetUserID()
@ -112,22 +110,6 @@ func (c *Client) ResetClient(ctx *UserConnContext, conn LongConn, longConnServer
c.subUserIDs = make(map[string]struct{})
}
func (c *Client) pingHandler(appData string) error {
if err := c.conn.SetReadDeadline(pongWait); err != nil {
return err
}
log.ZDebug(c.ctx, "ping Handler Success.", "appData", appData)
return c.writePongMsg(appData)
}
func (c *Client) pongHandler(_ string) error {
if err := c.conn.SetReadDeadline(pongWait); err != nil {
return err
}
return nil
}
// readMessage continuously reads messages from the connection.
func (c *Client) readMessage() {
defer func() {
@ -138,52 +120,25 @@ func (c *Client) readMessage() {
c.close()
}()
c.conn.SetReadLimit(maxMessageSize)
_ = c.conn.SetReadDeadline(pongWait)
c.conn.SetPongHandler(c.pongHandler)
c.conn.SetPingHandler(c.pingHandler)
c.activeHeartbeat(c.hbCtx)
for {
log.ZDebug(c.ctx, "readMessage")
messageType, message, returnErr := c.conn.ReadMessage()
message, returnErr := c.conn.ReadMessage()
if returnErr != nil {
log.ZWarn(c.ctx, "readMessage", returnErr, "messageType", messageType)
log.ZWarn(c.ctx, "readMessage", returnErr)
c.closedErr = returnErr
return
}
log.ZDebug(c.ctx, "readMessage", "messageType", messageType)
if c.closed.Load() {
// The scenario where the connection has just been closed, but the coroutine has not exited
c.closedErr = ErrConnClosed
return
}
switch messageType {
case MessageBinary:
_ = c.conn.SetReadDeadline(pongWait)
parseDataErr := c.handleMessage(message)
if parseDataErr != nil {
c.closedErr = parseDataErr
return
}
case MessageText:
_ = c.conn.SetReadDeadline(pongWait)
parseDataErr := c.handlerTextMessage(message)
if parseDataErr != nil {
c.closedErr = parseDataErr
return
}
case PingMessage:
err := c.writePongMsg("")
log.ZError(c.ctx, "writePongMsg", err)
case CloseMessage:
c.closedErr = ErrClientClosed
parseDataErr := c.handleMessage(message)
if parseDataErr != nil {
c.closedErr = parseDataErr
return
default:
}
}
}
@ -358,109 +313,13 @@ func (c *Client) writeBinaryMsg(resp Resp) error {
c.w.Lock()
defer c.w.Unlock()
err = c.conn.SetWriteDeadline(writeWait)
if err != nil {
return err
}
if c.IsCompress {
resultBuf, compressErr := c.longConnServer.CompressWithPool(encodedBuf)
if compressErr != nil {
return compressErr
}
return c.conn.WriteMessage(MessageBinary, resultBuf)
return c.conn.WriteMessage(resultBuf)
}
return c.conn.WriteMessage(MessageBinary, encodedBuf)
}
// Actively initiate Heartbeat when platform in Web.
func (c *Client) activeHeartbeat(ctx context.Context) {
if c.PlatformID == constant.WebPlatformID {
go func() {
defer func() {
if r := recover(); r != nil {
log.ZPanic(ctx, "activeHeartbeat Panic", errs.ErrPanic(r))
}
}()
log.ZDebug(ctx, "server initiative send heartbeat start.")
ticker := time.NewTicker(pingPeriod)
defer ticker.Stop()
for {
select {
case <-ticker.C:
if err := c.writePingMsg(); err != nil {
log.ZWarn(c.ctx, "send Ping Message error.", err)
return
}
case <-c.hbCtx.Done():
return
}
}
}()
}
}
func (c *Client) writePingMsg() error {
if c.closed.Load() {
return nil
}
c.w.Lock()
defer c.w.Unlock()
err := c.conn.SetWriteDeadline(writeWait)
if err != nil {
return err
}
return c.conn.WriteMessage(PingMessage, nil)
}
func (c *Client) writePongMsg(appData string) error {
log.ZDebug(c.ctx, "write Pong Msg in Server", "appData", appData)
if c.closed.Load() {
log.ZWarn(c.ctx, "is closed in server", nil, "appdata", appData, "closed err", c.closedErr)
return nil
}
c.w.Lock()
defer c.w.Unlock()
err := c.conn.SetWriteDeadline(writeWait)
if err != nil {
log.ZWarn(c.ctx, "SetWriteDeadline in Server have error", errs.Wrap(err), "writeWait", writeWait, "appData", appData)
return errs.Wrap(err)
}
err = c.conn.WriteMessage(PongMessage, []byte(appData))
if err != nil {
log.ZWarn(c.ctx, "Write Message have error", errs.Wrap(err), "Pong msg", PongMessage)
}
return errs.Wrap(err)
}
func (c *Client) handlerTextMessage(b []byte) error {
var msg TextMessage
if err := json.Unmarshal(b, &msg); err != nil {
return err
}
switch msg.Type {
case TextPong:
return nil
case TextPing:
msg.Type = TextPong
msgData, err := json.Marshal(msg)
if err != nil {
return err
}
c.w.Lock()
defer c.w.Unlock()
if err := c.conn.SetWriteDeadline(writeWait); err != nil {
return err
}
return c.conn.WriteMessage(MessageText, msgData)
default:
return fmt.Errorf("not support message type %s", msg.Type)
}
return c.conn.WriteMessage(encodedBuf)
}

View File

@ -0,0 +1,233 @@
package msggateway
import (
"context"
"encoding/json"
"errors"
"fmt"
"sync/atomic"
"time"
"github.com/gorilla/websocket"
"github.com/openimsdk/tools/log"
)
var ErrWriteFull = fmt.Errorf("websocket write buffer full,close connection")
type ClientConn interface {
ReadMessage() ([]byte, error)
WriteMessage(message []byte) error
Close() error
}
type websocketMessage struct {
MessageType int
Data []byte
}
func NewWebSocketClientConn(conn *websocket.Conn, readLimit int64, readTimeout time.Duration, pingInterval time.Duration) ClientConn {
c := &websocketClientConn{
readTimeout: readTimeout,
conn: conn,
writer: make(chan *websocketMessage, 256),
done: make(chan struct{}),
}
if readLimit > 0 {
c.conn.SetReadLimit(readLimit)
}
c.conn.SetPingHandler(c.pingHandler)
c.conn.SetPongHandler(c.pongHandler)
go c.loopSend()
if pingInterval > 0 {
go c.doPing(pingInterval)
}
return c
}
type websocketClientConn struct {
readTimeout time.Duration
conn *websocket.Conn
writer chan *websocketMessage
done chan struct{}
err atomic.Pointer[error]
}
func (c *websocketClientConn) ReadMessage() ([]byte, error) {
buf, err := c.readMessage()
if err != nil {
return nil, c.closeBy(fmt.Errorf("read message %w", err))
}
return buf, nil
}
func (c *websocketClientConn) WriteMessage(message []byte) error {
return c.writeMessage(websocket.BinaryMessage, message)
}
func (c *websocketClientConn) Close() error {
return c.closeBy(fmt.Errorf("websocket connection closed"))
}
func (c *websocketClientConn) closeBy(err error) error {
if !c.err.CompareAndSwap(nil, &err) {
return *c.err.Load()
}
close(c.done)
log.ZWarn(context.Background(), "websocket connection closed", err, "remoteAddr", c.conn.RemoteAddr(),
"chan length", len(c.writer))
return err
}
func (c *websocketClientConn) writeMessage(messageType int, data []byte) error {
if errPtr := c.err.Load(); errPtr != nil {
return *errPtr
}
select {
case c.writer <- &websocketMessage{MessageType: messageType, Data: data}:
return nil
default:
return c.closeBy(ErrWriteFull)
}
}
func (c *websocketClientConn) loopSend() {
defer func() {
_ = c.conn.Close()
}()
var err error
for {
select {
case <-c.done:
for {
select {
case msg := <-c.writer:
switch msg.MessageType {
case websocket.TextMessage, websocket.BinaryMessage:
err = c.conn.WriteMessage(msg.MessageType, msg.Data)
default:
err = c.conn.WriteControl(msg.MessageType, msg.Data, time.Time{})
}
if err != nil {
_ = c.closeBy(err)
return
}
default:
return
}
}
case msg := <-c.writer:
switch msg.MessageType {
case websocket.TextMessage, websocket.BinaryMessage:
err = c.conn.WriteMessage(msg.MessageType, msg.Data)
default:
err = c.conn.WriteControl(msg.MessageType, msg.Data, time.Time{})
}
if err != nil {
_ = c.closeBy(err)
return
}
}
}
}
func (c *websocketClientConn) setReadDeadline() error {
deadline := time.Now().Add(c.readTimeout)
return c.conn.SetReadDeadline(deadline)
}
func (c *websocketClientConn) readMessage() ([]byte, error) {
for {
if err := c.setReadDeadline(); err != nil {
return nil, err
}
messageType, buf, err := c.conn.ReadMessage()
if err != nil {
return nil, err
}
switch messageType {
case websocket.BinaryMessage:
return buf, nil
case websocket.TextMessage:
if err := c.onReadTextMessage(buf); err != nil {
return nil, err
}
case websocket.PingMessage:
if err := c.pingHandler(string(buf)); err != nil {
return nil, err
}
case websocket.PongMessage:
if err := c.pongHandler(string(buf)); err != nil {
return nil, err
}
case websocket.CloseMessage:
if len(buf) == 0 {
return nil, errors.New("websocket connection closed by peer")
}
return nil, fmt.Errorf("websocket connection closed by peer, data %s", string(buf))
default:
return nil, fmt.Errorf("unknown websocket message type %d", messageType)
}
}
}
func (c *websocketClientConn) onReadTextMessage(buf []byte) error {
var msg struct {
Type string `json:"type"`
Body json.RawMessage `json:"body"`
}
if err := json.Unmarshal(buf, &msg); err != nil {
return err
}
switch msg.Type {
case TextPong:
return nil
case TextPing:
msg.Type = TextPong
msgData, err := json.Marshal(msg)
if err != nil {
return err
}
return c.writeMessage(websocket.TextMessage, msgData)
default:
return fmt.Errorf("not support text message type %s", msg.Type)
}
}
func (c *websocketClientConn) pingHandler(appData string) error {
log.ZDebug(context.Background(), "ping handler recv ping", "remoteAddr", c.conn.RemoteAddr(), "appData", appData)
if err := c.setReadDeadline(); err != nil {
return err
}
err := c.conn.WriteControl(websocket.PongMessage, []byte(appData), time.Now().Add(time.Second*1))
if err != nil {
log.ZWarn(context.Background(), "ping handler write pong error", err, "remoteAddr", c.conn.RemoteAddr(), "appData", appData)
}
log.ZDebug(context.Background(), "ping handler write pong success", "remoteAddr", c.conn.RemoteAddr(), "appData", appData)
return nil
}
func (c *websocketClientConn) pongHandler(appData string) error {
log.ZDebug(context.Background(), "pong handler recv pong", "remoteAddr", c.conn.RemoteAddr(), "appData", appData)
if err := c.setReadDeadline(); err != nil {
return err
}
return nil
}
func (c *websocketClientConn) doPing(d time.Duration) {
ticker := time.NewTicker(d)
defer ticker.Stop()
for {
select {
case <-c.done:
return
case <-ticker.C:
if err := c.writeMessage(websocket.PingMessage, nil); err != nil {
_ = c.closeBy(fmt.Errorf("send ping %w", err))
return
}
}
}
}

View File

@ -32,7 +32,7 @@ func TestCompressDecompress(t *testing.T) {
compressor := NewGzipCompressor()
for i := 0; i < 2000; i++ {
for range 2000 {
src := mockRandom()
// compress
@ -58,10 +58,8 @@ func TestCompressDecompressWithConcurrency(t *testing.T) {
wg := sync.WaitGroup{}
compressor := NewGzipCompressor()
for i := 0; i < 200; i++ {
wg.Add(1)
go func() {
defer wg.Done()
for range 200 {
wg.Go(func() {
src := mockRandom()
// compress
@ -80,8 +78,7 @@ func TestCompressDecompressWithConcurrency(t *testing.T) {
// check
assert.EqualValues(t, src, res)
}()
})
}
wg.Wait()
}
@ -90,7 +87,7 @@ func BenchmarkCompress(b *testing.B) {
src := mockRandom()
compressor := NewGzipCompressor()
for i := 0; i < b.N; i++ {
for b.Loop() {
_, err := compressor.Compress(src)
assert.Equal(b, nil, err)
}
@ -100,7 +97,7 @@ func BenchmarkCompressWithSyncPool(b *testing.B) {
src := mockRandom()
compressor := NewGzipCompressor()
for i := 0; i < b.N; i++ {
for b.Loop() {
_, err := compressor.CompressWithPool(src)
assert.Equal(b, nil, err)
}
@ -114,7 +111,7 @@ func BenchmarkDecompress(b *testing.B) {
assert.Equal(b, nil, err)
for i := 0; i < b.N; i++ {
for b.Loop() {
_, err := compressor.DeCompress(comdata)
assert.Equal(b, nil, err)
}
@ -127,7 +124,7 @@ func BenchmarkDecompressWithSyncPool(b *testing.B) {
comdata, err := compressor.Compress(src)
assert.Equal(b, nil, err)
for i := 0; i < b.N; i++ {
for b.Loop() {
_, err := compressor.DecompressWithPool(comdata)
assert.Equal(b, nil, err)
}

View File

@ -15,6 +15,8 @@
package msggateway
import (
"encoding/base64"
"encoding/json"
"net/http"
"net/url"
"strconv"
@ -24,10 +26,21 @@ import (
"github.com/openimsdk/protocol/constant"
"github.com/openimsdk/tools/utils/encrypt"
"github.com/openimsdk/tools/utils/stringutil"
"github.com/openimsdk/tools/utils/timeutil"
)
type UserConnContextInfo struct {
Token string `json:"token"`
UserID string `json:"userID"`
PlatformID int `json:"platformID"`
OperationID string `json:"operationID"`
Compression string `json:"compression"`
SDKType string `json:"sdkType"`
SendResponse bool `json:"sendResponse"`
Background bool `json:"background"`
SDKVersion string `json:"sdkVersion"`
}
type UserConnContext struct {
RespWriter http.ResponseWriter
Req *http.Request
@ -35,6 +48,7 @@ type UserConnContext struct {
Method string
RemoteAddr string
ConnID string
info *UserConnContextInfo
}
func (c *UserConnContext) Deadline() (deadline time.Time, ok bool) {
@ -58,9 +72,11 @@ func (c *UserConnContext) Value(key any) any {
case constant.ConnID:
return c.GetConnID()
case constant.OpUserPlatform:
return constant.PlatformIDToName(stringutil.StringToInt(c.GetPlatformID()))
return c.GetPlatformID()
case constant.RemoteAddr:
return c.RemoteAddr
case SDKVersion:
return c.info.SDKVersion
default:
return ""
}
@ -83,30 +99,92 @@ func newContext(respWriter http.ResponseWriter, req *http.Request) *UserConnCont
func newTempContext() *UserConnContext {
return &UserConnContext{
Req: &http.Request{URL: &url.URL{}},
Req: &http.Request{URL: &url.URL{}},
info: &UserConnContextInfo{},
}
}
func (c *UserConnContext) ParseEssentialArgs() error {
query := c.Req.URL.Query()
if data := query.Get("v"); data != "" {
return c.parseByJson(data)
} else {
return c.parseByQuery(query, c.Req.Header)
}
}
func (c *UserConnContext) parseByQuery(query url.Values, header http.Header) error {
info := UserConnContextInfo{
Token: query.Get(Token),
UserID: query.Get(WsUserID),
OperationID: query.Get(OperationID),
Compression: query.Get(Compression),
SDKType: query.Get(SDKType),
SDKVersion: query.Get(SDKVersion),
}
platformID, err := strconv.Atoi(query.Get(PlatformID))
if err != nil {
return servererrs.ErrConnArgsErr.WrapMsg("platformID is not int")
}
info.PlatformID = platformID
if val := query.Get(SendResponse); val != "" {
ok, err := strconv.ParseBool(val)
if err != nil {
return servererrs.ErrConnArgsErr.WrapMsg("isMsgResp is not bool")
}
info.SendResponse = ok
}
if info.Compression == "" {
info.Compression = header.Get(Compression)
}
background, err := strconv.ParseBool(query.Get(BackgroundStatus))
if err != nil {
return err
}
info.Background = background
return c.checkInfo(&info)
}
func (c *UserConnContext) parseByJson(data string) error {
reqInfo, err := base64.RawURLEncoding.DecodeString(data)
if err != nil {
return servererrs.ErrConnArgsErr.WrapMsg("data is not base64")
}
var info UserConnContextInfo
if err := json.Unmarshal(reqInfo, &info); err != nil {
return servererrs.ErrConnArgsErr.WrapMsg("data is not json", "info", err.Error())
}
return c.checkInfo(&info)
}
func (c *UserConnContext) checkInfo(info *UserConnContextInfo) error {
if info.OperationID == "" {
return servererrs.ErrConnArgsErr.WrapMsg("operationID is empty")
}
if info.Token == "" {
return servererrs.ErrConnArgsErr.WrapMsg("token is empty")
}
if info.UserID == "" {
return servererrs.ErrConnArgsErr.WrapMsg("sendID is empty")
}
if _, ok := constant.PlatformID2Name[info.PlatformID]; !ok {
return servererrs.ErrConnArgsErr.WrapMsg("platformID is invalid")
}
switch info.SDKType {
case "":
info.SDKType = GoSDK
case GoSDK, JsSDK:
default:
return servererrs.ErrConnArgsErr.WrapMsg("sdkType is invalid")
}
c.info = info
return nil
}
func (c *UserConnContext) GetRemoteAddr() string {
return c.RemoteAddr
}
func (c *UserConnContext) Query(key string) (string, bool) {
var value string
if value = c.Req.URL.Query().Get(key); value == "" {
return value, false
}
return value, true
}
func (c *UserConnContext) GetHeader(key string) (string, bool) {
var value string
if value = c.Req.Header.Get(key); value == "" {
return value, false
}
return value, true
}
func (c *UserConnContext) SetHeader(key, value string) {
c.RespWriter.Header().Set(key, value)
}
@ -120,97 +198,76 @@ func (c *UserConnContext) GetConnID() string {
}
func (c *UserConnContext) GetUserID() string {
return c.Req.URL.Query().Get(WsUserID)
if c == nil || c.info == nil {
return ""
}
return c.info.UserID
}
func (c *UserConnContext) GetPlatformID() string {
return c.Req.URL.Query().Get(PlatformID)
func (c *UserConnContext) GetPlatformID() int {
if c == nil || c.info == nil {
return 0
}
return c.info.PlatformID
}
func (c *UserConnContext) GetOperationID() string {
return c.Req.URL.Query().Get(OperationID)
if c == nil || c.info == nil {
return ""
}
return c.info.OperationID
}
func (c *UserConnContext) SetOperationID(operationID string) {
values := c.Req.URL.Query()
values.Set(OperationID, operationID)
c.Req.URL.RawQuery = values.Encode()
if c.info == nil {
c.info = &UserConnContextInfo{}
}
c.info.OperationID = operationID
}
func (c *UserConnContext) GetToken() string {
return c.Req.URL.Query().Get(Token)
}
func (c *UserConnContext) GetSDKVersion() string {
return c.Req.URL.Query().Get(SDKVersion)
if c == nil || c.info == nil {
return ""
}
return c.info.Token
}
func (c *UserConnContext) GetCompression() bool {
compression, exists := c.Query(Compression)
if exists && compression == GzipCompressionProtocol {
return true
} else {
compression, exists := c.GetHeader(Compression)
if exists && compression == GzipCompressionProtocol {
return true
}
}
return false
return c != nil && c.info != nil && c.info.Compression == GzipCompressionProtocol
}
func (c *UserConnContext) GetSDKType() string {
sdkType := c.Req.URL.Query().Get(SDKType)
if sdkType == "" {
sdkType = GoSDK
if c == nil || c.info == nil {
return GoSDK
}
return sdkType
switch c.info.SDKType {
case "", GoSDK:
return GoSDK
case JsSDK:
return JsSDK
default:
return ""
}
}
func (c *UserConnContext) GetSDKVersion() string {
if c == nil || c.info == nil {
return ""
}
return c.info.SDKVersion
}
func (c *UserConnContext) ShouldSendResp() bool {
errResp, exists := c.Query(SendResponse)
if exists {
b, err := strconv.ParseBool(errResp)
if err != nil {
return false
} else {
return b
}
}
return false
return c != nil && c.info != nil && c.info.SendResponse
}
func (c *UserConnContext) SetToken(token string) {
c.Req.URL.RawQuery = Token + "=" + token
if c.info == nil {
c.info = &UserConnContextInfo{}
}
c.info.Token = token
}
func (c *UserConnContext) GetBackground() bool {
b, err := strconv.ParseBool(c.Req.URL.Query().Get(BackgroundStatus))
if err != nil {
return false
}
return b
}
func (c *UserConnContext) ParseEssentialArgs() error {
_, exists := c.Query(Token)
if !exists {
return servererrs.ErrConnArgsErr.WrapMsg("token is empty")
}
_, exists = c.Query(WsUserID)
if !exists {
return servererrs.ErrConnArgsErr.WrapMsg("sendID is empty")
}
platformIDStr, exists := c.Query(PlatformID)
if !exists {
return servererrs.ErrConnArgsErr.WrapMsg("platformID is empty")
}
_, err := strconv.Atoi(platformIDStr)
if err != nil {
return servererrs.ErrConnArgsErr.WrapMsg("platformID is not int")
}
switch sdkType, _ := c.Query(SDKType); sdkType {
case "", GoSDK, JsSDK:
default:
return servererrs.ErrConnArgsErr.WrapMsg("sdkType is not go or js")
}
return nil
return c != nil && c.info != nil && c.info.Background
}

View File

@ -152,19 +152,16 @@ func (s *Server) pushToUser(ctx context.Context, userID string, msgData *sdkws.M
userPlatform := &msggateway.SingleMsgToUserPlatform{
RecvPlatFormID: int32(client.PlatformID),
}
if !client.IsBackground ||
(client.IsBackground && client.PlatformID != constant.IOSPlatformID) {
err := client.PushMessage(ctx, msgData)
if err != nil {
log.ZWarn(ctx, "online push msg failed", err, "userID", userID, "platformID", client.PlatformID)
userPlatform.ResultCode = int64(servererrs.ErrPushMsgErr.Code())
} else {
if _, ok := s.pushTerminal[client.PlatformID]; ok {
result.OnlinePush = true
}
}
} else {
if client.IsBackground && client.PlatformID == constant.IOSPlatformID {
userPlatform.ResultCode = int64(servererrs.ErrIOSBackgroundPushErr.Code())
result.Resp = append(result.Resp, userPlatform)
continue
}
if err := client.PushMessage(ctx, msgData); err != nil {
log.ZWarn(ctx, "online push msg failed", err, "userID", userID, "platformID", client.PlatformID)
userPlatform.ResultCode = int64(servererrs.ErrPushMsgErr.Code())
} else if _, ok := s.pushTerminal[client.PlatformID]; ok {
result.OnlinePush = true
}
result.Resp = append(result.Resp, userPlatform)
}

View File

@ -18,13 +18,14 @@ import (
"context"
"time"
"google.golang.org/grpc"
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
"github.com/openimsdk/open-im-server/v3/pkg/dbbuild"
"github.com/openimsdk/open-im-server/v3/pkg/rpccache"
"github.com/openimsdk/tools/discovery"
"github.com/openimsdk/tools/utils/datautil"
"github.com/openimsdk/tools/utils/runtimeenv"
"google.golang.org/grpc"
"github.com/openimsdk/tools/log"
)
@ -76,42 +77,3 @@ func Start(ctx context.Context, conf *Config, client discovery.SvcDiscoveryRegis
return hubServer.LongConnServer.Run(ctx)
}
//
//// Start run ws server.
//func Start(ctx context.Context, index int, conf *Config) error {
// log.CInfo(ctx, "MSG-GATEWAY server is initializing", "runtimeEnv", runtimeenv.RuntimeEnvironment(),
// "rpcPorts", conf.MsgGateway.RPC.Ports,
// "wsPort", conf.MsgGateway.LongConnSvr.Ports, "prometheusPorts", conf.MsgGateway.Prometheus.Ports)
// wsPort, err := datautil.GetElemByIndex(conf.MsgGateway.LongConnSvr.Ports, index)
// if err != nil {
// return err
// }
//
// rdb, err := redisutil.NewRedisClient(ctx, conf.RedisConfig.Build())
// if err != nil {
// return err
// }
// longServer := NewWsServer(
// conf,
// WithPort(wsPort),
// WithMaxConnNum(int64(conf.MsgGateway.LongConnSvr.WebsocketMaxConnNum)),
// WithHandshakeTimeout(time.Duration(conf.MsgGateway.LongConnSvr.WebsocketTimeout)*time.Second),
// WithMessageMaxMsgLength(conf.MsgGateway.LongConnSvr.WebsocketMaxMsgLen),
// )
//
// hubServer := NewServer(longServer, conf, func(srv *Server) error {
// var err error
// longServer.online, err = rpccache.NewOnlineCache(srv.userClient, nil, rdb, false, longServer.subscriberUserOnlineStatusChanges)
// return err
// })
//
// go longServer.ChangeOnlineStatus(4)
//
// netDone := make(chan error)
// go func() {
// err = hubServer.Start(ctx, index, conf)
// netDone <- err
// }()
// return hubServer.LongConnServer.Run(netDone)
//}

View File

@ -1,179 +0,0 @@
// Copyright © 2023 OpenIM. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package msggateway
import (
"encoding/json"
"net/http"
"time"
"github.com/openimsdk/tools/apiresp"
"github.com/gorilla/websocket"
"github.com/openimsdk/tools/errs"
)
type LongConn interface {
// Close this connection
Close() error
// WriteMessage Write message to connection,messageType means data type,can be set binary(2) and text(1).
WriteMessage(messageType int, message []byte) error
// ReadMessage Read message from connection.
ReadMessage() (int, []byte, error)
// SetReadDeadline sets the read deadline on the underlying network connection,
// after a read has timed out, will return an error.
SetReadDeadline(timeout time.Duration) error
// SetWriteDeadline sets to write deadline when send message,when read has timed out,will return error.
SetWriteDeadline(timeout time.Duration) error
// Dial Try to dial a connection,url must set auth args,header can control compress data
Dial(urlStr string, requestHeader http.Header) (*http.Response, error)
// IsNil Whether the connection of the current long connection is nil
IsNil() bool
// SetConnNil Set the connection of the current long connection to nil
SetConnNil()
// SetReadLimit sets the maximum size for a message read from the peer.bytes
SetReadLimit(limit int64)
SetPongHandler(handler PingPongHandler)
SetPingHandler(handler PingPongHandler)
// GenerateLongConn Check the connection of the current and when it was sent are the same
GenerateLongConn(w http.ResponseWriter, r *http.Request) error
}
type GWebSocket struct {
protocolType int
conn *websocket.Conn
handshakeTimeout time.Duration
writeBufferSize int
}
func newGWebSocket(protocolType int, handshakeTimeout time.Duration, wbs int) *GWebSocket {
return &GWebSocket{protocolType: protocolType, handshakeTimeout: handshakeTimeout, writeBufferSize: wbs}
}
func (d *GWebSocket) Close() error {
return d.conn.Close()
}
func (d *GWebSocket) GenerateLongConn(w http.ResponseWriter, r *http.Request) error {
upgrader := &websocket.Upgrader{
HandshakeTimeout: d.handshakeTimeout,
CheckOrigin: func(r *http.Request) bool { return true },
}
if d.writeBufferSize > 0 { // default is 4kb.
upgrader.WriteBufferSize = d.writeBufferSize
}
conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
// The upgrader.Upgrade method usually returns enough error messages to diagnose problems that may occur during the upgrade
return errs.WrapMsg(err, "GenerateLongConn: WebSocket upgrade failed")
}
d.conn = conn
return nil
}
func (d *GWebSocket) WriteMessage(messageType int, message []byte) error {
// d.setSendConn(d.conn)
return d.conn.WriteMessage(messageType, message)
}
// func (d *GWebSocket) setSendConn(sendConn *websocket.Conn) {
// d.sendConn = sendConn
//}
func (d *GWebSocket) ReadMessage() (int, []byte, error) {
return d.conn.ReadMessage()
}
func (d *GWebSocket) SetReadDeadline(timeout time.Duration) error {
return d.conn.SetReadDeadline(time.Now().Add(timeout))
}
func (d *GWebSocket) SetWriteDeadline(timeout time.Duration) error {
if timeout <= 0 {
return errs.New("timeout must be greater than 0")
}
// TODO SetWriteDeadline Future add error handling
if err := d.conn.SetWriteDeadline(time.Now().Add(timeout)); err != nil {
return errs.WrapMsg(err, "GWebSocket.SetWriteDeadline failed")
}
return nil
}
func (d *GWebSocket) Dial(urlStr string, requestHeader http.Header) (*http.Response, error) {
conn, httpResp, err := websocket.DefaultDialer.Dial(urlStr, requestHeader)
if err != nil {
return httpResp, errs.WrapMsg(err, "GWebSocket.Dial failed", "url", urlStr)
}
d.conn = conn
return httpResp, nil
}
func (d *GWebSocket) IsNil() bool {
return d.conn == nil
//
// if d.conn != nil {
// return false
// }
// return true
}
func (d *GWebSocket) SetConnNil() {
d.conn = nil
}
func (d *GWebSocket) SetReadLimit(limit int64) {
d.conn.SetReadLimit(limit)
}
func (d *GWebSocket) SetPongHandler(handler PingPongHandler) {
d.conn.SetPongHandler(handler)
}
func (d *GWebSocket) SetPingHandler(handler PingPongHandler) {
d.conn.SetPingHandler(handler)
}
func (d *GWebSocket) RespondWithError(err error, w http.ResponseWriter, r *http.Request) error {
if err := d.GenerateLongConn(w, r); err != nil {
return err
}
data, err := json.Marshal(apiresp.ParseError(err))
if err != nil {
_ = d.Close()
return errs.WrapMsg(err, "json marshal failed")
}
if err := d.WriteMessage(MessageText, data); err != nil {
_ = d.Close()
return errs.WrapMsg(err, "WriteMessage failed")
}
_ = d.Close()
return nil
}
func (d *GWebSocket) RespondWithSuccess() error {
data, err := json.Marshal(apiresp.ParseError(nil))
if err != nil {
_ = d.Close()
return errs.WrapMsg(err, "json marshal failed")
}
if err := d.WriteMessage(MessageText, data); err != nil {
_ = d.Close()
return errs.WrapMsg(err, "WriteMessage failed")
}
return nil
}

View File

@ -2,18 +2,20 @@ package msggateway
import (
"context"
"encoding/json"
"fmt"
"net/http"
"sync"
"sync/atomic"
"time"
"github.com/gorilla/websocket"
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
"github.com/openimsdk/tools/apiresp"
"github.com/openimsdk/open-im-server/v3/pkg/common/webhook"
"github.com/openimsdk/open-im-server/v3/pkg/rpccache"
pbAuth "github.com/openimsdk/protocol/auth"
"github.com/openimsdk/tools/errs"
"github.com/openimsdk/tools/mcontext"
"github.com/go-playground/validator/v10"
@ -23,10 +25,11 @@ import (
"github.com/openimsdk/protocol/msggateway"
"github.com/openimsdk/tools/discovery"
"github.com/openimsdk/tools/log"
"github.com/openimsdk/tools/utils/stringutil"
"golang.org/x/sync/errgroup"
)
var wsSuccessResponse, _ = json.Marshal(&apiresp.ApiResponse{})
type LongConnServer interface {
Run(ctx context.Context) error
wsHandler(w http.ResponseWriter, r *http.Request)
@ -43,6 +46,7 @@ type LongConnServer interface {
}
type WsServer struct {
websocket *websocket.Upgrader
msgGatewayConfig *Config
port int
wsMaxConnNum int64
@ -136,9 +140,13 @@ func NewWsServer(msgGatewayConfig *Config, opts ...Option) *WsServer {
o(&config)
}
//userRpcClient := rpcclient.NewUserRpcClient(client, config.Discovery.RpcService.User, config.Share.IMAdminUser)
upgrader := &websocket.Upgrader{
HandshakeTimeout: config.handshakeTimeout,
CheckOrigin: func(r *http.Request) bool { return true },
}
v := validator.New()
return &WsServer{
websocket: upgrader,
msgGatewayConfig: msgGatewayConfig,
port: config.port,
wsMaxConnNum: config.maxConnNum,
@ -260,8 +268,7 @@ func (ws *WsServer) registerClient(client *Client) {
)
oldClients, userOK, clientOK = ws.clients.Get(client.UserID, client.PlatformID)
log.ZInfo(client.ctx, "registerClient", "userID", client.UserID, "platformID", client.PlatformID,
"sdkVersion", client.SDKVersion)
log.ZInfo(client.ctx, "registerClient", "userID", client.UserID, "platformID", client.PlatformID)
if !userOK {
ws.clients.Set(client.UserID, client)
@ -448,7 +455,7 @@ func (ws *WsServer) unregisterClient(client *Client) {
// validateRespWithRequest checks if the response matches the expected userID and platformID.
func (ws *WsServer) validateRespWithRequest(ctx *UserConnContext, resp *pbAuth.ParseTokenResp) error {
userID := ctx.GetUserID()
platformID := stringutil.StringToInt32(ctx.GetPlatformID())
platformID := int32(ctx.GetPlatformID())
if resp.UserID != userID {
return servererrs.ErrTokenInvalid.WrapMsg(fmt.Sprintf("token uid %s != userID %s", resp.UserID, userID))
}
@ -458,19 +465,37 @@ func (ws *WsServer) validateRespWithRequest(ctx *UserConnContext, resp *pbAuth.P
return nil
}
func (ws *WsServer) handlerError(ctx *UserConnContext, w http.ResponseWriter, r *http.Request, err error) {
if !ctx.ShouldSendResp() {
httpError(ctx, err)
return
}
// the browser cannot get the response of upgrade failure
data, err := json.Marshal(apiresp.ParseError(err))
if err != nil {
log.ZError(ctx, "json marshal failed", err)
return
}
conn, upgradeErr := ws.websocket.Upgrade(w, r, nil)
if upgradeErr != nil {
log.ZWarn(ctx, "websocket upgrade failed", upgradeErr, "respErr", err, "resp", string(data))
return
}
defer conn.Close()
if err := conn.WriteMessage(websocket.TextMessage, data); err != nil {
log.ZWarn(ctx, "WriteMessage failed", err, "respErr", err, "resp", string(data))
return
}
}
func (ws *WsServer) wsHandler(w http.ResponseWriter, r *http.Request) {
// Create a new connection context
connContext := newContext(w, r)
if !ws.ready.Load() {
httpError(connContext, errs.New("ws server not ready"))
return
}
// Check if the current number of online user connections exceeds the maximum limit
if ws.onlineUserConnNum.Load() >= ws.wsMaxConnNum {
// If it exceeds the maximum connection number, return an error via HTTP and stop processing
httpError(connContext, servererrs.ErrConnOverMaxNumLimit.WrapMsg("over max conn num limit"))
ws.handlerError(connContext, w, r, servererrs.ErrConnOverMaxNumLimit.WrapMsg("over max conn num limit"))
return
}
@ -478,31 +503,14 @@ func (ws *WsServer) wsHandler(w http.ResponseWriter, r *http.Request) {
err := connContext.ParseEssentialArgs()
if err != nil {
// If there's an error during parsing, return an error via HTTP and stop processing
httpError(connContext, err)
return
}
if ws.authClient == nil {
httpError(connContext, errs.New("auth client is not initialized"))
ws.handlerError(connContext, w, r, err)
return
}
// Call the authentication client to parse the Token obtained from the context
resp, err := ws.authClient.ParseToken(connContext, connContext.GetToken())
if err != nil {
// If there's an error parsing the Token, decide whether to send the error message via WebSocket based on the context flag
shouldSendError := connContext.ShouldSendResp()
if shouldSendError {
// Create a WebSocket connection object and attempt to send the error message via WebSocket
wsLongConn := newGWebSocket(WebSocket, ws.handshakeTimeout, ws.writeBufferSize)
if err := wsLongConn.RespondWithError(err, w, r); err == nil {
// If the error message is successfully sent via WebSocket, stop processing
return
}
}
// If sending via WebSocket is not required or fails, return the error via HTTP and stop processing
httpError(connContext, err)
ws.handlerError(connContext, w, r, err)
return
}
@ -510,32 +518,30 @@ func (ws *WsServer) wsHandler(w http.ResponseWriter, r *http.Request) {
err = ws.validateRespWithRequest(connContext, resp)
if err != nil {
// If validation fails, return an error via HTTP and stop processing
httpError(connContext, err)
ws.handlerError(connContext, w, r, err)
return
}
log.ZDebug(connContext, "new conn", "token", connContext.GetToken())
// Create a WebSocket long connection object
wsLongConn := newGWebSocket(WebSocket, ws.handshakeTimeout, ws.writeBufferSize)
if err := wsLongConn.GenerateLongConn(w, r); err != nil {
//If the creation of the long connection fails, the error is handled internally during the handshake process.
log.ZWarn(connContext, "long connection fails", err)
conn, err := ws.websocket.Upgrade(w, r, nil)
if err != nil {
log.ZWarn(connContext, "websocket upgrade failed", err)
return
} else {
// Check if a normal response should be sent via WebSocket
shouldSendSuccessResp := connContext.ShouldSendResp()
if shouldSendSuccessResp {
// Attempt to send a success message through WebSocket
if err := wsLongConn.RespondWithSuccess(); err != nil {
// If the success message is successfully sent, end further processing
return
}
}
if connContext.ShouldSendResp() {
if err := conn.WriteMessage(websocket.TextMessage, wsSuccessResponse); err != nil {
log.ZWarn(connContext, "WriteMessage first response", err)
return
}
}
// Retrieve a client object from the client pool, reset its state, and associate it with the current WebSocket long connection
client := ws.clientPool.Get().(*Client)
client.ResetClient(connContext, wsLongConn, ws)
log.ZDebug(connContext, "new conn", "token", connContext.GetToken())
var pingInterval time.Duration
if connContext.GetPlatformID() == constant.WebPlatformID {
pingInterval = pingPeriod
}
client := new(Client)
client.ResetClient(connContext, NewWebSocketClientConn(conn, maxMessageSize, pongWait, pingInterval), ws)
// Register the client with the server and start message processing
ws.registerChan <- client

View File

@ -18,8 +18,6 @@ import (
"context"
"fmt"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/mcache"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/redis"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database/mgo"
"github.com/openimsdk/open-im-server/v3/pkg/dbbuild"
@ -28,10 +26,11 @@ import (
"github.com/openimsdk/tools/mq"
"github.com/openimsdk/tools/utils/runtimeenv"
"google.golang.org/grpc"
conf "github.com/openimsdk/open-im-server/v3/pkg/common/config"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/controller"
"github.com/openimsdk/tools/log"
"google.golang.org/grpc"
)
type MsgTransfer struct {
@ -59,8 +58,6 @@ type Config struct {
}
func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryRegistry, server grpc.ServiceRegistrar) error {
builder := mqbuild.NewBuilder(&config.KafkaConfig)
log.CInfo(ctx, "MSG-TRANSFER server is initializing", "runTimeEnv", runtimeenv.RuntimeEnvironment(), "prometheusPorts",
config.MsgTransfer.Prometheus.Ports, "index", config.Index)
dbb := dbbuild.NewBuilder(&config.MongodbConfig, &config.RedisConfig)
@ -72,25 +69,15 @@ func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryReg
if err != nil {
return err
}
//if config.Discovery.Enable == conf.ETCD {
// cm := disetcd.NewConfigManager(client.(*etcd.SvcDiscoveryRegistryImpl).GetClient(), []string{
// config.MsgTransfer.GetConfigFileName(),
// config.RedisConfig.GetConfigFileName(),
// config.MongodbConfig.GetConfigFileName(),
// config.KafkaConfig.GetConfigFileName(),
// config.Share.GetConfigFileName(),
// config.WebhooksConfig.GetConfigFileName(),
// config.Discovery.GetConfigFileName(),
// conf.LogConfigFileName,
// })
// cm.Watch(ctx)
//}
mongoProducer, err := builder.GetTopicProducer(ctx, config.KafkaConfig.ToMongoTopic)
builder, err := mqbuild.NewBuilder(config.Share.Queue, &config.KafkaConfig, rdb)
if err != nil {
return err
}
pushProducer, err := builder.GetTopicProducer(ctx, config.KafkaConfig.ToPushTopic)
mongoProducer, err := builder.GetTopicProducer(ctx, mqbuild.TopicToMongo)
if err != nil {
return err
}
pushProducer, err := builder.GetTopicProducer(ctx, mqbuild.TopicToPush)
if err != nil {
return err
}
@ -98,16 +85,7 @@ func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryReg
if err != nil {
return err
}
var msgModel cache.MsgCache
if rdb == nil {
cm, err := mgo.NewCacheMgo(mgocli.GetDB())
if err != nil {
return err
}
msgModel = mcache.NewMsgCache(cm, msgDocModel)
} else {
msgModel = redis.NewMsgCache(rdb, msgDocModel)
}
msgModel := redis.NewMsgCache(rdb, msgDocModel)
seqConversation, err := mgo.NewSeqConversationMongo(mgocli.GetDB())
if err != nil {
return err
@ -122,11 +100,11 @@ func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryReg
if err != nil {
return err
}
historyConsumer, err := builder.GetTopicConsumer(ctx, config.KafkaConfig.ToRedisTopic)
historyConsumer, err := builder.GetTopicConsumer(ctx, mqbuild.TopicToRedis)
if err != nil {
return err
}
historyMongoConsumer, err := builder.GetTopicConsumer(ctx, config.KafkaConfig.ToMongoTopic)
historyMongoConsumer, err := builder.GetTopicConsumer(ctx, mqbuild.TopicToMongo)
if err != nil {
return err
}

View File

@ -5,6 +5,8 @@ import (
"fmt"
"sync"
"golang.org/x/sync/errgroup"
"github.com/openimsdk/protocol/msggateway"
"github.com/openimsdk/protocol/sdkws"
"github.com/openimsdk/tools/discovery"
@ -12,8 +14,6 @@ import (
"github.com/openimsdk/tools/log"
"github.com/openimsdk/tools/utils/datautil"
"github.com/openimsdk/tools/utils/runtimeenv"
"golang.org/x/sync/errgroup"
"google.golang.org/grpc"
conf "github.com/openimsdk/open-im-server/v3/pkg/common/config"
)
@ -137,78 +137,3 @@ func (d *DefaultAllNode) GetOnlinePushFailedUserIDs(_ context.Context, msg *sdkw
return datautil.SliceSub(*pushToUserIDs, onlineSuccessUserIDs)
}
type K8sStaticConsistentHash struct {
disCov discovery.SvcDiscoveryRegistry
config *Config
}
func NewK8sStaticConsistentHash(disCov discovery.SvcDiscoveryRegistry, config *Config) *K8sStaticConsistentHash {
return &K8sStaticConsistentHash{disCov: disCov, config: config}
}
func (k *K8sStaticConsistentHash) GetConnsAndOnlinePush(ctx context.Context, msg *sdkws.MsgData,
pushToUserIDs []string) (wsResults []*msggateway.SingleMsgToUserResults, err error) {
var usersHost = make(map[string][]string)
for _, v := range pushToUserIDs {
tHost, err := k.disCov.GetUserIdHashGatewayHost(ctx, v)
if err != nil {
log.ZError(ctx, "get msg gateway hash error", err)
return nil, err
}
tUsers, tbl := usersHost[tHost]
if tbl {
tUsers = append(tUsers, v)
usersHost[tHost] = tUsers
} else {
usersHost[tHost] = []string{v}
}
}
log.ZDebug(ctx, "genUsers send hosts struct:", "usersHost", usersHost)
var usersConns = make(map[grpc.ClientConnInterface][]string)
for host, userIds := range usersHost {
tconn, _ := k.disCov.GetConn(ctx, host)
usersConns[tconn] = userIds
}
var (
mu sync.Mutex
wg = errgroup.Group{}
maxWorkers = k.config.RpcConfig.MaxConcurrentWorkers
)
if maxWorkers < 3 {
maxWorkers = 3
}
wg.SetLimit(maxWorkers)
for conn, userIds := range usersConns {
tcon := conn
tuserIds := userIds
wg.Go(func() error {
input := &msggateway.OnlineBatchPushOneMsgReq{MsgData: msg, PushToUserIDs: tuserIds}
msgClient := msggateway.NewMsgGatewayClient(tcon)
reply, err := msgClient.SuperGroupOnlineBatchPushOneMsg(ctx, input)
if err != nil {
return nil
}
log.ZDebug(ctx, "push result", "reply", reply)
if reply != nil && reply.SinglePushResult != nil {
mu.Lock()
wsResults = append(wsResults, reply.SinglePushResult...)
mu.Unlock()
}
return nil
})
}
_ = wg.Wait()
return wsResults, nil
}
func (k *K8sStaticConsistentHash) GetOnlinePushFailedUserIDs(_ context.Context, _ *sdkws.MsgData,
wsResults []*msggateway.SingleMsgToUserResults, _ *[]string) []string {
var needOfflinePushUserIDs []string
for _, v := range wsResults {
if !v.OnlinePush {
needOfflinePushUserIDs = append(needOfflinePushUserIDs, v.UserID)
}
}
return needOfflinePushUserIDs
}

View File

@ -2,25 +2,24 @@ package push
import (
"context"
"github.com/openimsdk/tools/mq"
"math/rand"
"strconv"
"github.com/openimsdk/tools/mq"
"google.golang.org/grpc"
"github.com/openimsdk/open-im-server/v3/internal/push/offlinepush"
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/mcache"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/redis"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/controller"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database/mgo"
"github.com/openimsdk/open-im-server/v3/pkg/dbbuild"
"github.com/openimsdk/open-im-server/v3/pkg/mqbuild"
pbpush "github.com/openimsdk/protocol/push"
"github.com/openimsdk/tools/discovery"
"github.com/openimsdk/tools/log"
"github.com/openimsdk/tools/mcontext"
"google.golang.org/grpc"
)
type pushServer struct {
@ -57,37 +56,26 @@ func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryReg
if err != nil {
return err
}
var cacheModel cache.ThirdCache
if rdb == nil {
mdb, err := dbb.Mongo(ctx)
if err != nil {
return err
}
mc, err := mgo.NewCacheMgo(mdb.GetDB())
if err != nil {
return err
}
cacheModel = mcache.NewThirdCache(mc)
} else {
cacheModel = redis.NewThirdCache(rdb)
}
cacheModel := redis.NewThirdCache(rdb)
offlinePusher, err := offlinepush.NewOfflinePusher(&config.RpcConfig, cacheModel, string(config.FcmConfigPath))
if err != nil {
return err
}
builder := mqbuild.NewBuilder(&config.KafkaConfig)
offlinePushProducer, err := builder.GetTopicProducer(ctx, config.KafkaConfig.ToOfflinePushTopic)
builder, err := mqbuild.NewBuilder(config.Share.Queue, &config.KafkaConfig, rdb)
if err != nil {
return err
}
offlinePushProducer, err := builder.GetTopicProducer(ctx, mqbuild.TopicToOfflinePush)
if err != nil {
return err
}
database := controller.NewPushDatabase(cacheModel, offlinePushProducer)
pushConsumer, err := builder.GetTopicConsumer(ctx, config.KafkaConfig.ToPushTopic)
pushConsumer, err := builder.GetTopicConsumer(ctx, mqbuild.TopicToPush)
if err != nil {
return err
}
offlinePushConsumer, err := builder.GetTopicConsumer(ctx, config.KafkaConfig.ToOfflinePushTopic)
offlinePushConsumer, err := builder.GetTopicConsumer(ctx, mqbuild.TopicToOfflinePush)
if err != nil {
return err
}

View File

@ -19,18 +19,18 @@ import (
"errors"
"github.com/openimsdk/open-im-server/v3/pkg/common/convert"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/mcache"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database/mgo"
"github.com/openimsdk/open-im-server/v3/pkg/dbbuild"
"github.com/openimsdk/open-im-server/v3/pkg/localcache"
"github.com/openimsdk/open-im-server/v3/pkg/rpccache"
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
"github.com/redis/go-redis/v9"
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
redis2 "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/redis"
"github.com/openimsdk/tools/utils/datautil"
"github.com/redis/go-redis/v9"
"google.golang.org/grpc"
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
"github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics"
@ -43,7 +43,6 @@ import (
"github.com/openimsdk/tools/errs"
"github.com/openimsdk/tools/log"
"github.com/openimsdk/tools/tokenverify"
"google.golang.org/grpc"
)
type authServer struct {
@ -71,20 +70,7 @@ func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryReg
if err != nil {
return err
}
var token cache.TokenModel
if rdb == nil {
mdb, err := dbb.Mongo(ctx)
if err != nil {
return err
}
mc, err := mgo.NewCacheMgo(mdb.GetDB())
if err != nil {
return err
}
token = mcache.NewTokenCacheModel(mc, config.RpcConfig.TokenPolicy.Expire)
} else {
token = redis2.NewTokenCacheModel(rdb, &config.LocalCacheConfig, config.RpcConfig.TokenPolicy.Expire)
}
token := redis2.NewTokenCacheModel(rdb, &config.LocalCacheConfig, config.RpcConfig.TokenPolicy.Expire)
userConn, err := client.GetConn(ctx, config.Discovery.RpcService.User)
if err != nil {
return err

View File

@ -513,14 +513,6 @@ func (c *conversationServer) GetUserConversationIDsHash(ctx context.Context, req
return &pbconversation.GetUserConversationIDsHashResp{Hash: hash}, nil
}
func (c *conversationServer) GetConversationsByConversationID(ctx context.Context, req *pbconversation.GetConversationsByConversationIDReq) (*pbconversation.GetConversationsByConversationIDResp, error) {
conversations, err := c.conversationDatabase.GetConversationsByConversationID(ctx, req.ConversationIDs)
if err != nil {
return nil, err
}
return &pbconversation.GetConversationsByConversationIDResp{Conversations: convert.ConversationsDB2Pb(conversations)}, nil
}
func (c *conversationServer) GetConversationOfflinePushUserIDs(ctx context.Context, req *pbconversation.GetConversationOfflinePushUserIDsReq) (*pbconversation.GetConversationOfflinePushUserIDsResp, error) {
if req.ConversationID == "" {
return nil, errs.ErrArgs.WrapMsg("conversationID is empty")
@ -717,56 +709,6 @@ func (c *conversationServer) GetOwnerConversation(ctx context.Context, req *pbco
}, nil
}
func (c *conversationServer) GetConversationsNeedClearMsg(ctx context.Context, _ *pbconversation.GetConversationsNeedClearMsgReq) (*pbconversation.GetConversationsNeedClearMsgResp, error) {
num, err := c.conversationDatabase.GetAllConversationIDsNumber(ctx)
if err != nil {
log.ZError(ctx, "GetAllConversationIDsNumber failed", err)
return nil, err
}
const batchNum = 100
if num == 0 {
return nil, errs.New("Need Destruct Msg is nil").Wrap()
}
maxPage := (num + batchNum - 1) / batchNum
temp := make([]*dbModel.Conversation, 0, maxPage*batchNum)
for pageNumber := 0; pageNumber < int(maxPage); pageNumber++ {
pagination := &sdkws.RequestPagination{
PageNumber: int32(pageNumber),
ShowNumber: batchNum,
}
conversationIDs, err := c.conversationDatabase.PageConversationIDs(ctx, pagination)
if err != nil {
log.ZError(ctx, "PageConversationIDs failed", err, "pageNumber", pageNumber)
continue
}
// log.ZDebug(ctx, "PageConversationIDs success", "pageNumber", pageNumber, "conversationIDsNum", len(conversationIDs), "conversationIDs", conversationIDs)
if len(conversationIDs) == 0 {
continue
}
conversations, err := c.conversationDatabase.GetConversationsByConversationID(ctx, conversationIDs)
if err != nil {
log.ZError(ctx, "GetConversationsByConversationID failed", err, "conversationIDs", conversationIDs)
continue
}
for _, conversation := range conversations {
if conversation.IsMsgDestruct && conversation.MsgDestructTime != 0 && ((time.Now().UnixMilli() > (conversation.MsgDestructTime + conversation.LatestMsgDestructTime.UnixMilli() + 8*60*60)) || // 8*60*60 is UTC+8
conversation.LatestMsgDestructTime.IsZero()) {
temp = append(temp, conversation)
}
}
}
return &pbconversation.GetConversationsNeedClearMsgResp{Conversations: convert.ConversationsDB2Pb(temp)}, nil
}
func (c *conversationServer) GetNotNotifyConversationIDs(ctx context.Context, req *pbconversation.GetNotNotifyConversationIDsReq) (*pbconversation.GetNotNotifyConversationIDsResp, error) {
if err := authverify.CheckAccess(ctx, req.UserID); err != nil {
return nil, err

View File

@ -287,6 +287,19 @@ func (g *groupServer) webhookAfterJoinGroup(ctx context.Context, after *config.A
g.webhookClient.AsyncPost(ctx, cbReq.GetCallbackCommand(), cbReq, &callbackstruct.CallbackAfterJoinGroupResp{}, after)
}
func afterJoinGroupRequests(members []*model.GroupMember, reqMessage string) []*group.JoinGroupReq {
requests := make([]*group.JoinGroupReq, 0, len(members))
for _, member := range members {
requests = append(requests, &group.JoinGroupReq{
GroupID: member.GroupID,
ReqMessage: reqMessage,
JoinSource: member.JoinSource,
InviterUserID: member.UserID,
})
}
return requests
}
func (g *groupServer) webhookBeforeSetGroupInfo(ctx context.Context, before *config.BeforeConfig, req *group.SetGroupInfoReq) error {
return webhook.WithCondition(ctx, before, func(ctx context.Context) error {
cbReq := &callbackstruct.CallbackBeforeSetGroupInfoReq{

View File

@ -23,9 +23,12 @@ import (
"strings"
"time"
"google.golang.org/grpc"
"github.com/openimsdk/tools/utils/stringutil"
"github.com/openimsdk/open-im-server/v3/pkg/dbbuild"
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
"google.golang.org/grpc"
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
"github.com/openimsdk/open-im-server/v3/pkg/callbackstruct"
@ -143,8 +146,8 @@ func (g *groupServer) NotificationUserInfoUpdate(ctx context.Context, req *pbgro
return nil, err
}
}
for _, groupID := range groupIDs {
g.notification.GroupMemberInfoSetNotification(ctx, groupID, req.UserID)
if err = g.notification.GroupMemberInfoSetNotificationBulk(ctx, groupIDs, req.NewUserInfo); err != nil {
log.ZError(ctx, stringutil.GetFuncName(1)+" failed", err)
}
if err = g.db.DeleteGroupMemberHash(ctx, groupIDs); err != nil {
return nil, err
@ -472,6 +475,12 @@ func (g *groupServer) InviteUserToGroup(ctx context.Context, req *pbgroup.Invite
g.notification.GroupApplicationAgreeMemberEnterNotification(ctx, req.GroupID, req.SendMessage, opUserID, userIDs...)
}
}
if err := g.setMemberJoinSeq(ctx, req.GroupID, req.InvitedUserIDs); err != nil {
return nil, err
}
for _, joinReq := range afterJoinGroupRequests(groupMembers, req.Reason) {
g.webhookAfterJoinGroup(ctx, &g.config.WebhooksConfig.AfterJoinGroup, joinReq)
}
return &pbgroup.InviteUserToGroupResp{}, nil
}
@ -602,10 +611,6 @@ func (g *groupServer) KickGroupMember(ctx context.Context, req *pbgroup.KickGrou
}
}
}
num, err := g.db.FindGroupMemberNum(ctx, req.GroupID)
if err != nil {
return nil, err
}
ownerUserIDs, err := g.db.GetGroupRoleLevelMemberIDs(ctx, req.GroupID, constant.GroupOwner)
if err != nil {
return nil, err
@ -617,6 +622,10 @@ func (g *groupServer) KickGroupMember(ctx context.Context, req *pbgroup.KickGrou
if err := g.db.DeleteGroupMember(ctx, group.GroupID, req.KickedUserIDs); err != nil {
return nil, err
}
num, err := g.db.FindGroupMemberNum(ctx, req.GroupID)
if err != nil {
return nil, err
}
tips := &sdkws.MemberKickedTips{
Group: &sdkws.GroupInfo{
GroupID: group.GroupID,
@ -626,7 +635,7 @@ func (g *groupServer) KickGroupMember(ctx context.Context, req *pbgroup.KickGrou
FaceURL: group.FaceURL,
OwnerUserID: ownerUserID,
CreateTime: group.CreateTime.UnixMilli(),
MemberCount: num - uint32(len(req.KickedUserIDs)),
MemberCount: num,
Ex: group.Ex,
Status: group.Status,
CreatorUserID: group.CreatorUserID,
@ -905,6 +914,12 @@ func (g *groupServer) GroupApplicationResponse(ctx context.Context, req *pbgroup
return nil, err
}
}
if err := g.setMemberJoinSeq(ctx, req.GroupID, []string{req.FromUserID}); err != nil {
return nil, err
}
for _, joinReq := range afterJoinGroupRequests([]*model.GroupMember{member}, groupRequest.ReqMsg) {
g.webhookAfterJoinGroup(ctx, &g.config.WebhooksConfig.AfterJoinGroup, joinReq)
}
}
case constant.GroupResponseRefuse:
g.notification.GroupApplicationRejectedNotification(ctx, req)
@ -967,6 +982,9 @@ func (g *groupServer) JoinGroup(ctx context.Context, req *pbgroup.JoinGroupReq)
if err = g.notification.MemberEnterNotification(ctx, req.GroupID, req.InviterUserID); err != nil {
return nil, err
}
if err := g.setMemberJoinSeq(ctx, req.GroupID, []string{req.InviterUserID}); err != nil {
return nil, err
}
g.webhookAfterJoinGroup(ctx, &g.config.WebhooksConfig.AfterJoinGroup, req)
return &pbgroup.JoinGroupResp{}, nil
@ -1028,6 +1046,11 @@ func (g *groupServer) deleteMemberAndSetConversationSeq(ctx context.Context, gro
return g.conversationClient.SetConversationMaxSeq(ctx, conversationID, userIDs, maxSeq)
}
func (g *groupServer) setMemberJoinSeq(ctx context.Context, groupID string, userIDs []string) error {
conversationID := msgprocessor.GetConversationIDBySessionType(constant.ReadGroupChatType, groupID)
return g.conversationClient.SetConversationMaxSeq(ctx, conversationID, userIDs, 0)
}
func (g *groupServer) SetGroupInfo(ctx context.Context, req *pbgroup.SetGroupInfoReq) (*pbgroup.SetGroupInfoResp, error) {
var opMember *model.GroupMember
if !authverify.IsAdmin(ctx) {
@ -1299,6 +1322,9 @@ func (g *groupServer) TransferGroupOwner(ctx context.Context, req *pbgroup.Trans
}
func (g *groupServer) GetGroups(ctx context.Context, req *pbgroup.GetGroupsReq) (*pbgroup.GetGroupsResp, error) {
if err := authverify.CheckAdmin(ctx); err != nil {
return nil, err
}
var (
group []*model.Group
err error

View File

@ -802,6 +802,182 @@ func (g *NotificationSender) GroupCancelMutedNotification(ctx context.Context, g
g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupCancelMutedNotification, tips)
}
func (g *NotificationSender) getPublicUserInfos(ctx context.Context, userIDs []string) ([]*sdkws.PublicUserInfo, error) {
users, err := g.getUsersInfo(ctx, userIDs)
if err != nil {
return nil, err
}
userMap := make(map[string]common_user.CommonUser)
for _, user := range users {
userMap[user.GetUserID()] = user
}
for _, userID := range userIDs {
if _, ok := userMap[userID]; !ok {
return nil, servererrs.ErrUserIDNotFound.WrapMsg(fmt.Sprintf("user %s not found", userID))
}
}
return datautil.Slice(users, func(e common_user.CommonUser) *sdkws.PublicUserInfo {
return &sdkws.PublicUserInfo{
UserID: e.GetUserID(),
Nickname: e.GetNickname(),
FaceURL: e.GetFaceURL(),
Ex: e.GetEx(),
}
}), nil
}
func (g *NotificationSender) getGroupMembersForUser(ctx context.Context, groupIDs []string, userID string) ([]*sdkws.GroupMemberFullInfo, error) {
members, err := g.db.FindGroupMemberUser(ctx, groupIDs, userID)
if err != nil {
return nil, err
}
if err := g.PopulateGroupMember(ctx, members...); err != nil {
return nil, err
}
log.ZDebug(ctx, "getGroupMembers", "members", members)
return datautil.Slice(members, func(e *model.GroupMember) *sdkws.GroupMemberFullInfo { return g.groupMemberDB2PB(e, 0) }), nil
}
func (g *NotificationSender) getGroupMemberMapForUser(ctx context.Context, groupIDs []string, userID string) (map[string]*sdkws.GroupMemberFullInfo, error) {
members, err := g.getGroupMembersForUser(ctx, groupIDs, userID)
if err != nil {
return nil, err
}
m := make(map[string]*sdkws.GroupMemberFullInfo)
for i, member := range members {
m[member.GroupID] = members[i]
}
return m, nil
}
func (g *NotificationSender) migrateFallbackToGroupMemberFullInfo(groupMemberFullInfo *sdkws.GroupMemberFullInfo, publicUserInfo *sdkws.PublicUserInfo) *sdkws.GroupMemberFullInfo {
if groupMemberFullInfo == nil {
groupMemberFullInfo = &sdkws.GroupMemberFullInfo{}
}
if publicUserInfo == nil {
publicUserInfo = &sdkws.PublicUserInfo{}
}
firstNotEmpty := func(s ...string) string {
for _, s := range s {
if s != "" {
return s
}
}
return ""
}
return &sdkws.GroupMemberFullInfo{
GroupID: groupMemberFullInfo.GroupID,
UserID: firstNotEmpty(groupMemberFullInfo.UserID, publicUserInfo.UserID),
RoleLevel: groupMemberFullInfo.RoleLevel,
JoinTime: groupMemberFullInfo.JoinTime,
Nickname: firstNotEmpty(groupMemberFullInfo.Nickname, publicUserInfo.Nickname),
FaceURL: firstNotEmpty(groupMemberFullInfo.FaceURL, publicUserInfo.FaceURL),
AppMangerLevel: groupMemberFullInfo.AppMangerLevel,
JoinSource: groupMemberFullInfo.JoinSource,
OperatorUserID: firstNotEmpty(groupMemberFullInfo.OperatorUserID, publicUserInfo.UserID),
InviterUserID: groupMemberFullInfo.InviterUserID,
Ex: groupMemberFullInfo.Ex,
MuteEndTime: groupMemberFullInfo.MuteEndTime,
}
}
func (g *NotificationSender) getGroupInfos(ctx context.Context, groupIDs []string) ([]*sdkws.GroupInfo, error) {
var err error
defer func() {
if err != nil {
log.ZError(ctx, stringutil.GetFuncName(1)+" failed", err)
}
}()
groups, err := g.db.FindGroup(ctx, groupIDs)
if err != nil {
return nil, err
}
numMap, err := g.db.FindGroupMemberNums(ctx, groupIDs)
if err != nil {
return nil, err
}
owners, err := g.db.FindGroupsOwner(ctx, groupIDs)
if err != nil {
return nil, err
}
ownerMap := make(map[string]string)
for _, owner := range owners {
ownerMap[owner.GroupID] = owner.UserID
}
return datautil.Slice(groups, func(group *model.Group) *sdkws.GroupInfo {
return convert.Db2PbGroupInfo(group, ownerMap[group.GroupID], numMap[group.GroupID])
}), nil
}
func (g *NotificationSender) GroupMemberInfoSetNotificationBulk(ctx context.Context, groupIDs []string, changedUserInfo *sdkws.UserInfo) error {
opUserID := mcontext.GetOpUserID(ctx)
opIsAdmin := authverify.CheckUserIsAdmin(ctx, opUserID)
groupInfos, err := g.getGroupInfos(ctx, groupIDs)
if err != nil {
return err
}
groupMemberMap, err := g.getGroupMemberMapForUser(ctx, groupIDs, changedUserInfo.UserID)
if err != nil {
return err
}
opMemberMap := groupMemberMap
if opUserID != changedUserInfo.UserID {
opMemberMap, err = g.getGroupMemberMapForUser(ctx, groupIDs, opUserID)
if err != nil {
return err
}
}
opPublicUser := &sdkws.PublicUserInfo{
UserID: changedUserInfo.GetUserID(),
Nickname: changedUserInfo.GetNickname(),
FaceURL: changedUserInfo.GetFaceURL(),
Ex: changedUserInfo.GetEx(),
}
if opUserID != changedUserInfo.UserID {
opPublicUser, err = g.getUser(ctx, opUserID)
if err != nil {
return err
}
}
for _, groupInfo := range groupInfos {
if groupMemberMap[groupInfo.GroupID] == nil {
continue
}
opUserGroupMemberFullInfo := datautil.If(opIsAdmin, &sdkws.GroupMemberFullInfo{
GroupID: groupInfo.GroupID,
UserID: opUserID,
RoleLevel: constant.GroupAdmin,
AppMangerLevel: constant.AppAdmin,
}, opMemberMap[groupInfo.GroupID])
if opUserGroupMemberFullInfo == nil {
opUserGroupMemberFullInfo = &sdkws.GroupMemberFullInfo{}
}
opUserGroupMemberFullInfo.GroupID = groupInfo.GroupID
tips := &sdkws.GroupMemberInfoSetTips{
Group: groupInfo,
OpUser: g.migrateFallbackToGroupMemberFullInfo(opUserGroupMemberFullInfo, opPublicUser),
ChangedUser: groupMemberMap[groupInfo.GroupID],
}
g.setSortVersion(ctx, &tips.GroupMemberVersion, &tips.GroupMemberVersionID, database.GroupMemberVersionName, tips.Group.GroupID, &tips.GroupSortVersion)
g.Notification(ctx, opUserID, groupInfo.GroupID, constant.GroupMemberInfoSetNotification, tips)
}
return nil
}
func (g *NotificationSender) GroupMemberInfoSetNotification(ctx context.Context, groupID, groupMemberUserID string) {
var err error
defer func() {
@ -809,13 +985,11 @@ func (g *NotificationSender) GroupMemberInfoSetNotification(ctx context.Context,
log.ZError(ctx, stringutil.GetFuncName(1)+" failed", err)
}
}()
var group *sdkws.GroupInfo
group, err = g.getGroupInfo(ctx, groupID)
group, err := g.getGroupInfo(ctx, groupID)
if err != nil {
return
}
var user map[string]*sdkws.GroupMemberFullInfo
user, err = g.getGroupMemberMap(ctx, groupID, []string{groupMemberUserID})
user, err := g.getGroupMemberMap(ctx, groupID, []string{groupMemberUserID})
if err != nil {
return
}
@ -834,8 +1008,7 @@ func (g *NotificationSender) GroupMemberSetToAdminNotification(ctx context.Conte
log.ZError(ctx, stringutil.GetFuncName(1)+" failed", err)
}
}()
var group *sdkws.GroupInfo
group, err = g.getGroupInfo(ctx, groupID)
group, err := g.getGroupInfo(ctx, groupID)
if err != nil {
return
}
@ -858,13 +1031,11 @@ func (g *NotificationSender) GroupMemberSetToOrdinaryUserNotification(ctx contex
log.ZError(ctx, stringutil.GetFuncName(1)+" failed", err)
}
}()
var group *sdkws.GroupInfo
group, err = g.getGroupInfo(ctx, groupID)
group, err := g.getGroupInfo(ctx, groupID)
if err != nil {
return
}
var user map[string]*sdkws.GroupMemberFullInfo
user, err = g.getGroupMemberMap(ctx, groupID, []string{mcontext.GetOpUserID(ctx), groupMemberUserID})
user, err := g.getGroupMemberMap(ctx, groupID, []string{mcontext.GetOpUserID(ctx), groupMemberUserID})
if err != nil {
return
}

View File

@ -19,7 +19,6 @@ import (
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
"github.com/openimsdk/protocol/constant"
"github.com/openimsdk/protocol/conversation"
"github.com/openimsdk/protocol/msg"
"github.com/openimsdk/protocol/sdkws"
"github.com/openimsdk/tools/log"
@ -74,7 +73,7 @@ func (m *msgServer) DeleteMsgs(ctx context.Context, req *msg.DeleteMsgsReq) (*ms
if err := m.MsgDatabase.DeleteMsgsPhysicalBySeqs(ctx, req.ConversationID, req.Seqs); err != nil {
return nil, err
}
conv, err := m.conversationClient.GetConversationsByConversationID(ctx, req.ConversationID)
conv, err := m.conversationClient.GetConversation(ctx, req.ConversationID, req.UserID)
if err != nil {
return nil, err
}
@ -116,14 +115,12 @@ func (m *msgServer) DeleteMsgPhysical(ctx context.Context, req *msg.DeleteMsgPhy
}
func (m *msgServer) clearConversation(ctx context.Context, conversationIDs []string, userID string, deleteSyncOpt *msg.DeleteSyncOpt) error {
conversations, err := m.conversationClient.GetConversationsByConversationIDs(ctx, conversationIDs)
conversations, err := m.conversationClient.GetConversations(ctx, conversationIDs, userID)
if err != nil {
return err
}
var existConversations []*conversation.Conversation
var existConversationIDs []string
for _, conversation := range conversations {
existConversations = append(existConversations, conversation)
existConversationIDs = append(existConversationIDs, conversation.ConversationID)
}
log.ZDebug(ctx, "ClearConversationsMsg", "existConversationIDs", existConversationIDs)
@ -152,7 +149,7 @@ func (m *msgServer) clearConversation(ctx context.Context, conversationIDs []str
if err := m.MsgDatabase.SetMinSeqs(ctx, m.getMinSeqs(maxSeqs)); err != nil {
return err
}
for _, conversation := range existConversations {
for _, conversation := range conversations {
tips := &sdkws.ClearConversationTips{UserID: userID, ConversationIDs: []string{conversation.ConversationID}}
m.notificationSender.NotificationWithSessionType(ctx, userID, m.conversationAndGetRecvID(conversation, userID), constant.ClearConversationNotification, conversation.ConversationType, tips)
}

View File

@ -17,12 +17,11 @@ package msg
import (
"context"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/mcache"
"google.golang.org/grpc"
"github.com/openimsdk/open-im-server/v3/pkg/dbbuild"
"github.com/openimsdk/open-im-server/v3/pkg/mqbuild"
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
"google.golang.org/grpc"
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/redis"
@ -80,11 +79,6 @@ func (m *msgServer) addInterceptorHandler(interceptorFunc ...MessageInterceptorF
}
func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryRegistry, server grpc.ServiceRegistrar) error {
builder := mqbuild.NewBuilder(&config.KafkaConfig)
redisProducer, err := builder.GetTopicProducer(ctx, config.KafkaConfig.ToRedisTopic)
if err != nil {
return err
}
dbb := dbbuild.NewBuilder(&config.MongodbConfig, &config.RedisConfig)
mgocli, err := dbb.Mongo(ctx)
if err != nil {
@ -94,20 +88,19 @@ func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryReg
if err != nil {
return err
}
builder, err := mqbuild.NewBuilder(config.Share.Queue, &config.KafkaConfig, rdb)
if err != nil {
return err
}
redisProducer, err := builder.GetTopicProducer(ctx, mqbuild.TopicToRedis)
if err != nil {
return err
}
msgDocModel, err := mgo.NewMsgMongo(mgocli.GetDB())
if err != nil {
return err
}
var msgModel cache.MsgCache
if rdb == nil {
cm, err := mgo.NewCacheMgo(mgocli.GetDB())
if err != nil {
return err
}
msgModel = mcache.NewMsgCache(cm, msgDocModel)
} else {
msgModel = redis.NewMsgCache(rdb, msgDocModel)
}
msgModel := redis.NewMsgCache(rdb, msgDocModel)
seqConversation, err := mgo.NewSeqConversationMongo(mgocli.GetDB())
if err != nil {
return err

View File

@ -150,6 +150,9 @@ func (m *msgServer) GetMaxSeq(ctx context.Context, req *sdkws.GetMaxSeqReq) (*sd
}
func (m *msgServer) SearchMessage(ctx context.Context, req *msg.SearchMessageReq) (resp *msg.SearchMessageResp, err error) {
if err := authverify.CheckAdmin(ctx); err != nil {
return nil, err
}
// var chatLogs []*sdkws.MsgData
var chatLogs []*msg.SearchedMsgData
var total int64

View File

@ -20,12 +20,12 @@ import (
"time"
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/mcache"
"github.com/openimsdk/open-im-server/v3/pkg/dbbuild"
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
"github.com/openimsdk/tools/s3/disable"
"google.golang.org/grpc"
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/redis"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database/mgo"
@ -40,7 +40,6 @@ import (
"github.com/openimsdk/tools/s3/cos"
"github.com/openimsdk/tools/s3/minio"
"github.com/openimsdk/tools/s3/oss"
"google.golang.org/grpc"
)
type thirdServer struct {
@ -83,30 +82,12 @@ func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryReg
if err != nil {
return err
}
var thirdCache cache.ThirdCache
if rdb == nil {
tc, err := mgo.NewCacheMgo(mgocli.GetDB())
if err != nil {
return err
}
thirdCache = mcache.NewThirdCache(tc)
} else {
thirdCache = redis.NewThirdCache(rdb)
}
thirdCache := redis.NewThirdCache(rdb)
// Select the oss method according to the profile policy
var o s3.Interface
switch enable := config.RpcConfig.Object.Enable; enable {
case "minio":
var minioCache minio.Cache
if rdb == nil {
mc, err := mgo.NewCacheMgo(mgocli.GetDB())
if err != nil {
return err
}
minioCache = mcache.NewMinioCache(mc)
} else {
minioCache = redis.NewMinioCache(rdb)
}
minioCache := redis.NewMinioCache(rdb)
o, err = minio.NewMinio(ctx, minioCache, *config.MinioConfig.Build())
case "cos":
o, err = cos.NewCos(*config.RpcConfig.Object.Cos.Build())
@ -141,6 +122,9 @@ func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryReg
}
func (t *thirdServer) FcmUpdateToken(ctx context.Context, req *third.FcmUpdateTokenReq) (resp *third.FcmUpdateTokenResp, err error) {
if err := authverify.CheckAccess(ctx, req.Account); err != nil {
return nil, err
}
err = t.thirdDatabase.FcmUpdateToken(ctx, req.Account, int(req.PlatformID), req.FcmToken, req.ExpireTime)
if err != nil {
return nil, err

View File

@ -18,11 +18,15 @@ import (
"context"
"time"
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
pbuser "github.com/openimsdk/protocol/user"
"github.com/openimsdk/tools/errs"
)
func (s *userServer) UserRegisterCount(ctx context.Context, req *pbuser.UserRegisterCountReq) (*pbuser.UserRegisterCountResp, error) {
if err := authverify.CheckAdmin(ctx); err != nil {
return nil, err
}
if req.Start > req.End {
return nil, errs.ErrArgs.WrapMsg("start > end")
}

View File

@ -22,6 +22,8 @@ import (
"sync"
"time"
"google.golang.org/grpc"
"github.com/openimsdk/open-im-server/v3/internal/rpc/relation"
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
@ -46,7 +48,6 @@ import (
"github.com/openimsdk/tools/discovery"
"github.com/openimsdk/tools/errs"
"github.com/openimsdk/tools/utils/datautil"
"google.golang.org/grpc"
)
const (
@ -226,6 +227,9 @@ func (s *userServer) UpdateUserInfoEx(ctx context.Context, req *pbuser.UpdateUse
return resp, nil
}
func (s *userServer) SetGlobalRecvMessageOpt(ctx context.Context, req *pbuser.SetGlobalRecvMessageOptReq) (resp *pbuser.SetGlobalRecvMessageOptResp, err error) {
if err := authverify.CheckAccess(ctx, req.UserID); err != nil {
return nil, err
}
resp = &pbuser.SetGlobalRecvMessageOptResp{}
if _, err := s.db.FindWithError(ctx, []string{req.UserID}); err != nil {
return nil, err
@ -268,6 +272,9 @@ func (s *userServer) AccountCheck(ctx context.Context, req *pbuser.AccountCheckR
}
func (s *userServer) GetPaginationUsers(ctx context.Context, req *pbuser.GetPaginationUsersReq) (resp *pbuser.GetPaginationUsersResp, err error) {
if err = authverify.CheckAdmin(ctx); err != nil {
return nil, err
}
if req.UserID == "" && req.NickName == "" {
total, users, err := s.db.PageFindUser(ctx, constant.IMOrdinaryUser, constant.AppOrdinaryUsers, req.Pagination)
if err != nil {
@ -353,6 +360,9 @@ func (s *userServer) GetGlobalRecvMessageOpt(ctx context.Context, req *pbuser.Ge
// GetAllUserID Get user account by page.
func (s *userServer) GetAllUserID(ctx context.Context, req *pbuser.GetAllUserIDReq) (resp *pbuser.GetAllUserIDResp, err error) {
if err = authverify.CheckAdmin(ctx); err != nil {
return nil, err
}
total, userIDs, err := s.db.GetAllUserID(ctx, req.Pagination)
if err != nil {
return nil, err
@ -712,6 +722,9 @@ func (s *userServer) NotificationUserInfoUpdate(ctx context.Context, userID stri
}
func (s *userServer) SortQuery(ctx context.Context, req *pbuser.SortQueryReq) (*pbuser.SortQueryResp, error) {
if err := authverify.CheckAdmin(ctx); err != nil {
return nil, err
}
users, err := s.db.SortQuery(ctx, req.UserIDName, req.Asc)
if err != nil {
return nil, err

View File

@ -3,8 +3,12 @@ package cron
import (
"context"
"github.com/robfig/cron/v3"
"google.golang.org/grpc"
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
disetcd "github.com/openimsdk/open-im-server/v3/pkg/common/discovery/etcd"
"github.com/openimsdk/open-im-server/v3/pkg/dbbuild"
pbconversation "github.com/openimsdk/protocol/conversation"
"github.com/openimsdk/protocol/msg"
"github.com/openimsdk/protocol/third"
@ -14,14 +18,13 @@ import (
"github.com/openimsdk/tools/log"
"github.com/openimsdk/tools/mcontext"
"github.com/openimsdk/tools/utils/runtimeenv"
"github.com/robfig/cron/v3"
"google.golang.org/grpc"
)
type Config struct {
CronTask config.CronTask
Share config.Share
Discovery config.Discovery
CronTask config.CronTask
Share config.Share
Discovery config.Discovery
RedisConfig config.Redis
}
func Start(ctx context.Context, conf *Config, client discovery.SvcDiscoveryRegistry, service grpc.ServiceRegistrar) error {
@ -60,10 +63,13 @@ func Start(ctx context.Context, conf *Config, client discovery.SvcDiscoveryRegis
if err != nil {
return err
}
}
if locker == nil {
locker = emptyLocker{}
} else {
builder := dbbuild.NewBuilder(nil, &conf.RedisConfig)
rdb, err := builder.Redis(ctx)
if err != nil {
return err
}
locker = NewRedisLocker(rdb)
}
srv := &cronServer{
@ -95,16 +101,6 @@ func Start(ctx context.Context, conf *Config, client discovery.SvcDiscoveryRegis
return nil
}
type Locker interface {
ExecuteWithLock(ctx context.Context, taskName string, task func())
}
type emptyLocker struct{}
func (emptyLocker) ExecuteWithLock(ctx context.Context, taskName string, task func()) {
task()
}
type cronServer struct {
ctx context.Context
config *Config

View File

@ -6,13 +6,10 @@ import (
"os"
"time"
"github.com/openimsdk/tools/log"
clientv3 "go.etcd.io/etcd/client/v3"
"go.etcd.io/etcd/client/v3/concurrency"
)
const (
lockLeaseTTL = 300
"github.com/openimsdk/tools/log"
)
type EtcdLocker struct {
@ -35,7 +32,7 @@ func NewEtcdLocker(client *clientv3.Client) (*EtcdLocker, error) {
}
func (e *EtcdLocker) ExecuteWithLock(ctx context.Context, taskName string, task func()) {
session, err := concurrency.NewSession(e.client, concurrency.WithTTL(lockLeaseTTL))
session, err := concurrency.NewSession(e.client, concurrency.WithTTL(int(lockLeaseTTL/time.Second)))
if err != nil {
log.ZWarn(ctx, "Failed to create etcd session", err,
"taskName", taskName,

View File

@ -0,0 +1,14 @@
package cron
import (
"context"
"time"
)
const (
lockLeaseTTL = time.Second * 300
)
type Locker interface {
ExecuteWithLock(ctx context.Context, taskName string, task func())
}

View File

@ -0,0 +1,68 @@
package cron
import (
"context"
"strings"
"time"
"github.com/google/uuid"
"github.com/redis/go-redis/v9"
"github.com/openimsdk/tools/log"
)
func NewRedisLocker(client redis.UniversalClient) *RedisLocker {
return &RedisLocker{
client: client,
script: redis.NewScript(strings.TrimSpace(`
if redis.call("get", KEYS[1]) == ARGV[1] then
return redis.call("del", KEYS[1])
else
return 0
end
`)),
}
}
type RedisLocker struct {
client redis.UniversalClient
script *redis.Script
}
func (e *RedisLocker) getKey(name string) string {
return "CRON_LOCKED:" + name
}
func (e *RedisLocker) lock(ctx context.Context, name string, owner string) (bool, error) {
ctx, cancel := context.WithTimeout(ctx, time.Second)
defer cancel()
return e.client.SetNX(ctx, e.getKey(name), owner, lockLeaseTTL).Result()
}
func (e *RedisLocker) unlock(ctx context.Context, name string, owner string) error {
ctx, cancel := context.WithTimeout(ctx, time.Second)
defer cancel()
return e.script.Run(ctx, e.client, []string{e.getKey(name)}, owner).Err()
}
func (e *RedisLocker) ExecuteWithLock(ctx context.Context, taskName string, task func()) {
owner := uuid.New().String()
ok, err := e.lock(ctx, taskName, owner)
if err != nil {
log.ZWarn(ctx, "cron lock get lock", err, "taskName", taskName)
return
}
log.ZDebug(ctx, "cron lock get lock", "taskName", taskName, "ok", ok, "owner", owner)
if !ok {
return
}
defer func() {
err := e.unlock(ctx, taskName, owner)
if err == nil {
log.ZDebug(ctx, "cron lock unlock", "taskName", taskName, "owner", owner)
} else {
log.ZWarn(ctx, "cron lock unlock", err, "taskName", taskName, "owner", owner)
}
}()
task()
}

View File

@ -4,13 +4,14 @@
package main
import (
"flag"
"os"
"fmt"
"github.com/openimsdk/gomake/mageutil"
"github.com/openimsdk/open-im-server/v3/version"
"github.com/openimsdk/tools/utils/datautil"
)
var Default = Build
var Default = BuildAll
var Aliases = map[string]any{
"buildcc": BuildWithCustomConfig,
@ -25,26 +26,21 @@ var (
customToolsDir = "tools" // tools source code directory, default is "tools"
)
func BuildAll() error { return Build(nil, nil) }
// Build support specifical binary build.
//
// Example: `mage build openim-api openim-rpc-user seq`
func Build() {
flag.Parse()
bin := flag.Args()
if len(bin) != 0 {
bin = bin[1:]
}
func Build(services, tools *string) (err error) {
defer mageutil.PrintErrPtr(&err)
mageutil.Build(bin, nil)
return mageutil.WithSpinnerR("Building binaries...", func() error {
return mageutil.Build(mageutil.ParseArgList(services), mageutil.ParseArgList(tools), nil, nil)
})
}
func BuildWithCustomConfig() {
flag.Parse()
bin := flag.Args()
if len(bin) != 0 {
bin = bin[1:]
}
func BuildWithCustomConfig(services, tools *string) (err error) {
defer mageutil.PrintErrPtr(&err)
config := &mageutil.PathOptions{
RootDir: &customRootDir,
@ -53,39 +49,21 @@ func BuildWithCustomConfig() {
ToolsDir: &customToolsDir,
}
mageutil.Build(bin, config)
return mageutil.WithSpinnerR("Building binaries with custom config...", func() error {
return mageutil.Build(mageutil.ParseArgList(services), mageutil.ParseArgList(tools), config, nil)
})
}
func Start() {
mageutil.InitForSSC()
err := setMaxOpenFiles()
if err != nil {
mageutil.PrintRed("setMaxOpenFiles failed " + err.Error())
os.Exit(1)
}
func Start() (err error) {
defer mageutil.PrintErrPtr(&err)
flag.Parse()
bin := flag.Args()
if len(bin) != 0 {
bin = bin[1:]
}
mageutil.StartToolsAndServices(bin, nil)
return mageutil.WithSpinnerR("Starting...", func() error {
return mageutil.StartToolsAndServices(nil, nil, nil)
})
}
func StartWithCustomConfig() {
mageutil.InitForSSC()
err := setMaxOpenFiles()
if err != nil {
mageutil.PrintRed("setMaxOpenFiles failed " + err.Error())
os.Exit(1)
}
flag.Parse()
bin := flag.Args()
if len(bin) != 0 {
bin = bin[1:]
}
func StartWithCustomConfig(services, tools *string) (err error) {
defer mageutil.PrintErrPtr(&err)
config := &mageutil.PathOptions{
RootDir: &customRootDir,
@ -93,13 +71,46 @@ func StartWithCustomConfig() {
ConfigDir: &customConfigDir,
}
mageutil.StartToolsAndServices(bin, config)
return mageutil.WithSpinnerR("Starting with custom config...", func() error {
return mageutil.StartToolsAndServices(mageutil.ParseArgList(tools), mageutil.ParseArgList(services), config)
})
}
func Stop() {
mageutil.StopAndCheckBinaries()
func Stop() (err error) {
defer mageutil.PrintErrPtr(&err)
return mageutil.WithSpinnerR("Stopping...", mageutil.StopAndCheckServices)
}
func Check() {
mageutil.CheckAndReportBinariesStatus()
func Check() (err error) {
defer mageutil.PrintErrPtr(&err)
return mageutil.WithSpinnerR("Checking binaries...", mageutil.CheckAndReportServicesStatus)
}
func Export() (err error) {
defer mageutil.PrintErrPtr(&err)
mappingPaths, err := mageutil.GetDefaultExportMappingPaths([]string{
"cmd",
"internal",
"pkg",
"test",
"tools",
"**/*.go",
"go.mod",
"go.sum",
"go.work",
})
if err != nil {
return fmt.Errorf("GetDefaultExportMappingPaths failed: %v", err)
}
return mageutil.WithSpinnerR("Exporting...", func() error {
return mageutil.ExportMageLauncherArchived(mappingPaths, &mageutil.ExportOptions{
ProjectName: datautil.ToPtr(fmt.Sprintf("open-im-server_%s", version.Version)),
BuildOpt: &mageutil.BuildOptions{
Release: datautil.ToPtr(true),
Compress: datautil.ToPtr(true),
},
})
})
}

View File

@ -1,21 +0,0 @@
//go:build mage && !windows
// +build mage,!windows
package main
import (
"syscall"
"github.com/openimsdk/gomake/mageutil"
)
func setMaxOpenFiles() error {
var rLimit syscall.Rlimit
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
return err
}
rLimit.Max = uint64(mageutil.MaxFileDescriptors)
rLimit.Cur = uint64(mageutil.MaxFileDescriptors)
return syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit)
}

View File

@ -1,8 +0,0 @@
//go:build mage
// +build mage
package main
func setMaxOpenFiles() error {
return nil
}

View File

@ -92,7 +92,9 @@ func (a *ApiCmd) runE() error {
&a.apiConfig.Notification,
a.apiConfig,
[]string{},
[]string{},
[]string{
a.apiConfig.Discovery.RpcService.MessageGateway,
},
api.Start,
)
}

View File

@ -17,12 +17,13 @@ package cmd
import (
"context"
"github.com/spf13/cobra"
"github.com/openimsdk/open-im-server/v3/internal/tools/cron"
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
"github.com/openimsdk/open-im-server/v3/pkg/common/startrpc"
"github.com/openimsdk/open-im-server/v3/version"
"github.com/openimsdk/tools/system/program"
"github.com/spf13/cobra"
)
type CronTaskCmd struct {
@ -39,6 +40,7 @@ func NewCronTaskCmd() *CronTaskCmd {
config.OpenIMCronTaskCfgFileName: &cronTaskConfig.CronTask,
config.ShareFileName: &cronTaskConfig.Share,
config.DiscoveryConfigFilename: &cronTaskConfig.Discovery,
config.RedisConfigFileName: &cronTaskConfig.RedisConfig,
}
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
ret.ctx = context.WithValue(context.Background(), "version", version.Version)

View File

@ -28,6 +28,13 @@ import (
"github.com/openimsdk/tools/s3/oss"
)
// FileConfig is implemented by every config struct that is backed by a config
// file; GetConfigFileName reports that file's name (e.g. "redis.yml"). It is the
// single marker used to decide whether a struct field is loaded from a file.
type FileConfig interface {
GetConfigFileName() string
}
const StructTagName = "yaml"
type Path string
@ -135,6 +142,7 @@ type API struct {
Api struct {
ListenIP string `yaml:"listenIP"`
Ports []int `yaml:"ports"`
RegisterIP string `yaml:"registerIP"`
CompressionLevel int `yaml:"compressionLevel"`
} `yaml:"api"`
Prometheus struct {
@ -418,7 +426,8 @@ type AfterConfig struct {
}
type Share struct {
Secret string `yaml:"secret"`
Secret string `yaml:"secret"`
Queue EngineSelector `yaml:"queue"`
IMAdminUser struct {
UserIDs []string `yaml:"userIDs"`
Nicknames []string `yaml:"nicknames"`

View File

@ -3,12 +3,14 @@ package config
import (
"os"
"path/filepath"
"reflect"
"strings"
"github.com/mitchellh/mapstructure"
"github.com/spf13/viper"
"github.com/openimsdk/tools/errs"
"github.com/openimsdk/tools/utils/runtimeenv"
"github.com/spf13/viper"
)
func Load(configDirectory string, configFileName string, envPrefix string, config any) error {
@ -35,10 +37,27 @@ func loadConfig(path string, envPrefix string, config any) error {
return errs.WrapMsg(err, "failed to read config file", "path", path, "envPrefix", envPrefix)
}
if err := v.Unmarshal(config, func(config *mapstructure.DecoderConfig) {
config.TagName = StructTagName
}); err != nil {
if err := v.Unmarshal(config, ApplyDecoderConfig); err != nil {
return errs.WrapMsg(err, "failed to unmarshal config", "path", path, "envPrefix", envPrefix)
}
return nil
}
func ApplyDecoderConfig(config *mapstructure.DecoderConfig) {
config.TagName = StructTagName
config.DecodeHook = mapstructure.ComposeDecodeHookFunc(
mapstructure.StringToTimeDurationHookFunc(),
mapstructure.StringToSliceHookFunc(","),
stringToEngineSelectorHookFunc(),
)
}
func stringToEngineSelectorHookFunc() mapstructure.DecodeHookFuncType {
engineSelectorType := reflect.TypeOf(EngineSelector{})
return func(from reflect.Type, to reflect.Type, data any) (any, error) {
if to != engineSelectorType || from.Kind() != reflect.String {
return data, nil
}
return EngineSelector{Engine: data.(string)}, nil
}
}

41
pkg/common/config/mq.go Normal file
View File

@ -0,0 +1,41 @@
package config
import (
"strings"
"github.com/openimsdk/tools/errs"
)
const (
QueueEngineKafka = "kafka"
QueueEngineRedis = "redis"
QueueEngineMemory = "memory"
)
func NormalizeQueueEngine(engine string) string {
switch strings.ToLower(strings.TrimSpace(engine)) {
case "", "kafka":
return QueueEngineKafka
case "redis":
return QueueEngineRedis
case "memory":
return QueueEngineMemory
default:
return strings.ToLower(strings.TrimSpace(engine))
}
}
func ValidateQueueEngine(engine string, standalone bool) (string, error) {
normalized := NormalizeQueueEngine(engine)
switch normalized {
case QueueEngineKafka, QueueEngineRedis:
return normalized, nil
case QueueEngineMemory:
if standalone {
return normalized, nil
}
return "", errs.ErrArgs.WrapMsg("unsupported queue engine for microservice deployment", "engine", engine)
default:
return "", errs.ErrArgs.WrapMsg("unsupported queue engine", "engine", engine)
}
}

View File

@ -0,0 +1,43 @@
package config
import "encoding/json"
type EngineSelector struct {
Engine string `yaml:"engine" mapstructure:"engine" json:"engine"`
}
func (e EngineSelector) String() string {
return e.Engine
}
func (e *EngineSelector) UnmarshalYAML(unmarshal func(any) error) error {
var engine string
if err := unmarshal(&engine); err == nil {
e.Engine = engine
return nil
}
var cfg struct {
Engine string `yaml:"engine"`
}
if err := unmarshal(&cfg); err != nil {
return err
}
e.Engine = cfg.Engine
return nil
}
func (e *EngineSelector) UnmarshalJSON(data []byte) error {
var engine string
if err := json.Unmarshal(data, &engine); err == nil {
e.Engine = engine
return nil
}
var cfg struct {
Engine string `json:"engine"`
}
if err := json.Unmarshal(data, &cfg); err != nil {
return err
}
e.Engine = cfg.Engine
return nil
}

View File

@ -53,10 +53,6 @@ package direct
// return nil
//}
//
//func (cd *ConnDirect) GetUserIdHashGatewayHost(ctx context.Context, userId string) (string, error) {
// return "", nil
//}
//
//func (cd *ConnDirect) Register(serviceName, host string, port int, opts ...grpc.DialOption) error {
// return nil
//}

View File

@ -15,13 +15,15 @@
package discovery
import (
"strings"
"time"
"google.golang.org/grpc"
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
"github.com/openimsdk/tools/discovery"
"github.com/openimsdk/tools/discovery/standalone"
"github.com/openimsdk/tools/utils/runtimeenv"
"google.golang.org/grpc"
"github.com/openimsdk/tools/discovery/kubernetes"
@ -34,15 +36,26 @@ func NewDiscoveryRegister(discovery *config.Discovery, watchNames []string) (dis
if config.Standalone() {
return standalone.GetSvcDiscoveryRegistry(), nil
}
if runtimeenv.RuntimeEnvironment() == config.KUBERNETES {
return kubernetes.NewConnManager(discovery.Kubernetes.Namespace, nil,
runtimeEnvironment := runtimeenv.RuntimeEnvironment()
discoveryType := discovery.Enable
if discoveryType == "" && runtimeEnvironment == config.KUBERNETES {
discoveryType = config.KUBERNETES
}
if discoveryType == config.KUBERNETES && runtimeEnvironment != config.KUBERNETES {
return nil, errs.New("unsupported discovery type", "type", discoveryType).Wrap()
}
switch discoveryType {
case config.KUBERNETES:
for i := range watchNames {
watchNames[i] = strings.Split(watchNames[i], ":")[0]
}
return kubernetes.NewConnManager(discovery.Kubernetes.Namespace, watchNames,
grpc.WithDefaultCallOptions(
grpc.MaxCallSendMsgSize(1024*1024*20),
),
grpc.WithDefaultServiceConfig(`{"loadBalancingPolicy":"round_robin"}`),
)
}
switch discovery.Enable {
case config.ETCD:
return etcd.NewSvcDiscoveryRegistry(
discovery.Etcd.RootDirectory,
@ -52,6 +65,6 @@ func NewDiscoveryRegister(discovery *config.Discovery, watchNames []string) (dis
etcd.WithMaxCallSendMsgSize(20*1024*1024),
etcd.WithUsernameAndPassword(discovery.Etcd.Username, discovery.Etcd.Password))
default:
return nil, errs.New("unsupported discovery type", "type", discovery.Enable).Wrap()
return nil, errs.New("unsupported discovery type", "type", discoveryType).Wrap()
}
}

View File

@ -208,10 +208,6 @@ func (k *KubernetesConnManager) UnRegister() error {
return nil
}
func (k *KubernetesConnManager) GetUserIdHashGatewayHost(ctx context.Context, userId string) (string, error) {
return "", nil
}
func (k *KubernetesConnManager) getServicePort(serviceName string) (int32, error) {
var svcPort int32

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