mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-05 09:36:00 +08:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 24c438b699 |
@@ -1,6 +1,6 @@
|
|||||||
MONGO_IMAGE=mongo:7.0
|
MONGO_IMAGE=mongo:7.0
|
||||||
REDIS_IMAGE=redis:7.0.0
|
REDIS_IMAGE=redis:7.0.0
|
||||||
KAFKA_IMAGE=bitnamilegacy/kafka:3.5.1
|
KAFKA_IMAGE=bitnami/kafka:3.5.1
|
||||||
MINIO_IMAGE=minio/minio:RELEASE.2024-01-11T07-46-16Z
|
MINIO_IMAGE=minio/minio:RELEASE.2024-01-11T07-46-16Z
|
||||||
ETCD_IMAGE=quay.io/coreos/etcd:v3.5.13
|
ETCD_IMAGE=quay.io/coreos/etcd:v3.5.13
|
||||||
PROMETHEUS_IMAGE=prom/prometheus:v2.45.6
|
PROMETHEUS_IMAGE=prom/prometheus:v2.45.6
|
||||||
@@ -22,5 +22,4 @@ MONGO_BACKUP_DIR=${DATA_DIR}components/backup/mongo/
|
|||||||
PROMETHEUS_PORT=19091
|
PROMETHEUS_PORT=19091
|
||||||
ALERTMANAGER_PORT=19093
|
ALERTMANAGER_PORT=19093
|
||||||
GRAFANA_PORT=13000
|
GRAFANA_PORT=13000
|
||||||
|
|
||||||
NODE_EXPORTER_PORT=19100
|
NODE_EXPORTER_PORT=19100
|
||||||
@@ -92,13 +92,12 @@ jobs:
|
|||||||
contents: write
|
contents: write
|
||||||
env:
|
env:
|
||||||
SDK_DIR: openim-sdk-core
|
SDK_DIR: openim-sdk-core
|
||||||
NOTIFICATION_CONFIG_PATH: config/notification.yml
|
CONFIG_PATH: config/notification.yml
|
||||||
SHARE_CONFIG_PATH: config/share.yml
|
# pull-requests: write
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest]
|
os: [ ubuntu-latest ]
|
||||||
go_version: ["1.22.x"]
|
go_version: [ "1.22.x" ]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Server repository
|
- name: Checkout Server repository
|
||||||
@@ -107,8 +106,7 @@ jobs:
|
|||||||
- name: Checkout SDK repository
|
- name: Checkout SDK repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
repository: "openimsdk/openim-sdk-core"
|
repository: 'openimsdk/openim-sdk-core'
|
||||||
ref: "main"
|
|
||||||
path: ${{ env.SDK_DIR }}
|
path: ${{ env.SDK_DIR }}
|
||||||
|
|
||||||
- name: Set up Go ${{ matrix.go_version }}
|
- name: Set up Go ${{ matrix.go_version }}
|
||||||
@@ -121,11 +119,15 @@ jobs:
|
|||||||
go install github.com/magefile/mage@latest
|
go install github.com/magefile/mage@latest
|
||||||
go mod download
|
go mod download
|
||||||
|
|
||||||
|
- name: Install yq
|
||||||
|
run: |
|
||||||
|
sudo wget https://github.com/mikefarah/yq/releases/download/v4.34.1/yq_linux_amd64 -O /usr/bin/yq
|
||||||
|
sudo chmod +x /usr/bin/yq
|
||||||
|
|
||||||
- name: Modify Server Configuration
|
- name: Modify Server Configuration
|
||||||
run: |
|
run: |
|
||||||
yq e '.groupCreated.isSendMsg = true' -i ${{ env.NOTIFICATION_CONFIG_PATH }}
|
yq e '.groupCreated.unreadCount = true' -i ${{ env.CONFIG_PATH }}
|
||||||
yq e '.friendApplicationApproved.isSendMsg = true' -i ${{ env.NOTIFICATION_CONFIG_PATH }}
|
yq e '.friendApplicationApproved.unreadCount = true' -i ${{ env.CONFIG_PATH }}
|
||||||
yq e '.secret = 123456' -i ${{ env.SHARE_CONFIG_PATH }}
|
|
||||||
|
|
||||||
- name: Start Server Services
|
- name: Start Server Services
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -4,80 +4,45 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- release-*
|
- release-*
|
||||||
|
# tags:
|
||||||
|
# - 'v*'
|
||||||
|
|
||||||
release:
|
release:
|
||||||
types: [published]
|
types: [published]
|
||||||
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
tag:
|
tag:
|
||||||
description: "Tag version to be used for Docker image"
|
description: "Tag version to be used for Docker image"
|
||||||
required: true
|
required: true
|
||||||
default: "v3.8.3"
|
default: "v3.8.0"
|
||||||
|
|
||||||
env:
|
|
||||||
GO_VERSION: "1.22"
|
|
||||||
IMAGE_NAME: "openim-server"
|
|
||||||
# IMAGE_NAME: ${{ github.event.repository.name }}
|
|
||||||
DOCKER_BUILDKIT: 1
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish-docker-images:
|
build-and-test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.merged == false) }}
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout main repository
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
with:
|
||||||
path: main-repo
|
path: main-repo
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3.3.0
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
id: buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Build Docker image
|
||||||
|
id: build
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
driver-opts: network=host
|
context: ./main-repo
|
||||||
|
load: true
|
||||||
|
tags: "openim/openim-server:local"
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
|
||||||
- name: Extract metadata for Docker
|
- name: Save Docker image to file
|
||||||
id: meta
|
run: docker save -o image.tar openim/openim-server:local
|
||||||
uses: docker/metadata-action@v5.6.0
|
|
||||||
with:
|
|
||||||
images: |
|
|
||||||
${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}
|
|
||||||
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
|
|
||||||
registry.cn-hangzhou.aliyuncs.com/openimsdk/${{ env.IMAGE_NAME }}
|
|
||||||
tags: |
|
|
||||||
type=ref,event=tag
|
|
||||||
type=schedule
|
|
||||||
type=ref,event=branch
|
|
||||||
type=ref,event=pr
|
|
||||||
type=semver,pattern={{version}}
|
|
||||||
type=semver,pattern=v{{version}}
|
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
|
||||||
type=semver,pattern={{major}}
|
|
||||||
type=sha
|
|
||||||
|
|
||||||
- name: Install skopeo
|
|
||||||
run: |
|
|
||||||
sudo apt-get update && sudo apt-get install -y skopeo
|
|
||||||
|
|
||||||
- name: Build multi-arch images as OCI
|
|
||||||
run: |
|
|
||||||
mkdir -p /tmp/oci-image /tmp/docker-cache
|
|
||||||
|
|
||||||
# Build multi-architecture image and save in OCI format
|
|
||||||
docker buildx build \
|
|
||||||
--platform linux/amd64,linux/arm64 \
|
|
||||||
--output type=oci,dest=/tmp/oci-image/multi-arch.tar \
|
|
||||||
--cache-to type=local,dest=/tmp/docker-cache \
|
|
||||||
--cache-from type=gha \
|
|
||||||
./main-repo
|
|
||||||
|
|
||||||
# Use skopeo to convert the amd64 image from OCI format to Docker format and load it
|
|
||||||
skopeo copy --override-arch amd64 oci-archive:/tmp/oci-image/multi-arch.tar docker-daemon:${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:local
|
|
||||||
|
|
||||||
# check image
|
|
||||||
docker image ls | grep openim
|
|
||||||
|
|
||||||
- name: Checkout compose repository
|
- name: Checkout compose repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -90,19 +55,18 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
IP=$(hostname -I | awk '{print $1}')
|
IP=$(hostname -I | awk '{print $1}')
|
||||||
echo "The IP Address is: $IP"
|
echo "The IP Address is: $IP"
|
||||||
echo "ip=$IP" >> $GITHUB_OUTPUT
|
echo "::set-output name=ip::$IP"
|
||||||
|
|
||||||
- name: Update .env to use the local image
|
- name: Update .env to use the local image
|
||||||
run: |
|
run: |
|
||||||
sed -i 's|OPENIM_SERVER_IMAGE=.*|OPENIM_SERVER_IMAGE=${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:local|' ${{ github.workspace }}/compose-repo/.env
|
sed -i 's|OPENIM_SERVER_IMAGE=.*|OPENIM_SERVER_IMAGE=openim/openim-server:local|' ${{ github.workspace }}/compose-repo/.env
|
||||||
sed -i 's|MINIO_EXTERNAL_ADDRESS=.*|MINIO_EXTERNAL_ADDRESS=http://${{ steps.get-ip.outputs.ip }}:10005|' ${{ github.workspace }}/compose-repo/.env
|
sed -i 's|MINIO_EXTERNAL_ADDRESS=.*|MINIO_EXTERNAL_ADDRESS=http://${{ steps.get-ip.outputs.ip }}:10005|' ${{ github.workspace }}/compose-repo/.env
|
||||||
|
|
||||||
- name: Start services using Docker Compose
|
- name: Start services using Docker Compose
|
||||||
run: |
|
run: |
|
||||||
cd ${{ github.workspace }}/compose-repo
|
cd ${{ github.workspace }}/compose-repo
|
||||||
docker compose up -d
|
docker compose up -d
|
||||||
|
sleep 60
|
||||||
docker compose ps
|
|
||||||
|
|
||||||
# - name: Check openim-server health
|
# - name: Check openim-server health
|
||||||
# run: |
|
# run: |
|
||||||
@@ -133,62 +97,54 @@ jobs:
|
|||||||
# exit 0
|
# exit 0
|
||||||
# fi
|
# fi
|
||||||
|
|
||||||
|
- name: Load Docker image from file
|
||||||
|
run: docker load -i image.tar
|
||||||
|
|
||||||
|
- name: Extract metadata for Docker (tags, labels)
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5.5.1
|
||||||
|
with:
|
||||||
|
images: |
|
||||||
|
openim/openim-server
|
||||||
|
ghcr.io/openimsdk/openim-server
|
||||||
|
registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-server
|
||||||
|
tags: |
|
||||||
|
type=ref,event=tag
|
||||||
|
type=schedule
|
||||||
|
type=ref,event=branch
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern=v{{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=semver,pattern={{major}}
|
||||||
|
type=semver,pattern=release-{{raw}}
|
||||||
|
type=sha
|
||||||
|
type=raw,value=${{ github.event.inputs.tag }}
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
- name: Log in to Docker Hub
|
||||||
uses: docker/login-action@v3.3.0
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
- name: Log in to GitHub Container Registry
|
- name: Log in to GitHub Container Registry
|
||||||
uses: docker/login-action@v3.3.0
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.repository_owner }}
|
username: ${{ github.repository_owner }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Log in to Aliyun Container Registry
|
- name: Log in to Aliyun Container Registry
|
||||||
uses: docker/login-action@v3.3.0
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
registry: registry.cn-hangzhou.aliyuncs.com
|
registry: registry.cn-hangzhou.aliyuncs.com
|
||||||
username: ${{ secrets.ALIREGISTRY_USERNAME }}
|
username: ${{ secrets.ALIREGISTRY_USERNAME }}
|
||||||
password: ${{ secrets.ALIREGISTRY_TOKEN }}
|
password: ${{ secrets.ALIREGISTRY_TOKEN }}
|
||||||
|
|
||||||
- name: Push multi-architecture images
|
- name: Push Docker images
|
||||||
if: success()
|
uses: docker/build-push-action@v5
|
||||||
run: |
|
with:
|
||||||
docker buildx build \
|
context: ./main-repo
|
||||||
--platform linux/amd64,linux/arm64 \
|
push: true
|
||||||
$(echo "${{ steps.meta.outputs.tags }}" | sed 's/,/ --tag /g' | sed 's/^/--tag /') \
|
platforms: linux/amd64,linux/arm64
|
||||||
--cache-from type=local,src=/tmp/docker-cache \
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
--push \
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
./main-repo
|
|
||||||
|
|
||||||
- name: Verify multi-platform support
|
|
||||||
run: |
|
|
||||||
images=(
|
|
||||||
"${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}"
|
|
||||||
"ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}"
|
|
||||||
"registry.cn-hangzhou.aliyuncs.com/openimsdk/${{ env.IMAGE_NAME }}"
|
|
||||||
)
|
|
||||||
|
|
||||||
for image in "${images[@]}"; do
|
|
||||||
for tag in $(echo "${{ steps.meta.outputs.tags }}" | tr ',' '\n' | cut -d':' -f2); do
|
|
||||||
echo "Verifying multi-arch support for $image:$tag"
|
|
||||||
manifest=$(docker manifest inspect "$image:$tag" || echo "error")
|
|
||||||
if [[ "$manifest" == "error" ]]; then
|
|
||||||
echo "Manifest not found for $image:$tag"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
amd64_found=$(echo "$manifest" | jq '.manifests[] | select(.platform.architecture == "amd64")')
|
|
||||||
arm64_found=$(echo "$manifest" | jq '.manifests[] | select(.platform.architecture == "arm64")')
|
|
||||||
if [[ -z "$amd64_found" ]]; then
|
|
||||||
echo "Multi-platform support check failed for $image:$tag - missing amd64"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [[ -z "$arm64_found" ]]; then
|
|
||||||
echo "Multi-platform support check failed for $image:$tag - missing arm64"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "✅ $image:$tag supports both amd64 and arm64 architectures"
|
|
||||||
done
|
|
||||||
done
|
|
||||||
|
|||||||
@@ -8,40 +8,19 @@ jobs:
|
|||||||
update-version:
|
update-version:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
TAG_VERSION: ${{ github.event.release.tag_name }}
|
TAG_VERSION: ${{ github.event.release.tag_name }}
|
||||||
steps:
|
steps:
|
||||||
# Step 1: Checkout the original repository's code
|
# Step 1: Checkout the original repository's code
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
# submodules: "recursive"
|
|
||||||
|
|
||||||
- name: Safe submodule initialization
|
|
||||||
run: |
|
|
||||||
echo "Checking for submodules..."
|
|
||||||
if [ -f .gitmodules ]; then
|
|
||||||
if [ -s .gitmodules ]; then
|
|
||||||
echo "Initializing submodules..."
|
|
||||||
if git submodule sync --recursive 2>/dev/null; then
|
|
||||||
git submodule update --init --force --recursive || {
|
|
||||||
echo "Warning: Some submodules failed to initialize, continuing anyway..."
|
|
||||||
}
|
|
||||||
else
|
|
||||||
echo "Warning: Submodule sync failed, continuing without submodules..."
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo ".gitmodules exists but is empty, skipping submodule initialization"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "No .gitmodules file found, no submodules to initialize"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Step 2: Set up Git with official account
|
# Step 2: Set up Git with official account
|
||||||
- name: Set up Git
|
- name: Set up Git
|
||||||
run: |
|
run: |
|
||||||
git config --global user.name "github-actions[bot]"
|
git config user.name "github-actions[bot]"
|
||||||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
|
||||||
# Step 3: Check and delete existing tag
|
# Step 3: Check and delete existing tag
|
||||||
- name: Check and delete existing tag
|
- name: Check and delete existing tag
|
||||||
@@ -54,8 +33,7 @@ jobs:
|
|||||||
# Step 4: Update version file
|
# Step 4: Update version file
|
||||||
- name: Update version file
|
- name: Update version file
|
||||||
run: |
|
run: |
|
||||||
mkdir -p version
|
echo "${{ env.TAG_VERSION }}" > version/version
|
||||||
echo -n "${{ env.TAG_VERSION }}" > version/version
|
|
||||||
|
|
||||||
# Step 5: Commit and push changes
|
# Step 5: Commit and push changes
|
||||||
- name: Commit and push changes
|
- name: Commit and push changes
|
||||||
@@ -64,56 +42,43 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
git add version/version
|
git add version/version
|
||||||
git commit -m "Update version to ${{ env.TAG_VERSION }}"
|
git commit -m "Update version to ${{ env.TAG_VERSION }}"
|
||||||
|
git push origin HEAD:${{ github.ref }}
|
||||||
|
|
||||||
# Step 6: Update tag
|
# Step 6: Create and push tag
|
||||||
- name: Update tag
|
- name: Create and push tag
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
git tag -fa ${{ env.TAG_VERSION }} -m "Update version to ${{ env.TAG_VERSION }}"
|
git tag ${{ env.TAG_VERSION }}
|
||||||
git push origin ${{ env.TAG_VERSION }} --force
|
git push origin ${{ env.TAG_VERSION }}
|
||||||
|
|
||||||
# Step 7: Find and Publish Draft Release
|
# Step 7: Find and Publish Draft Release
|
||||||
- name: Find and Publish Draft Release
|
- name: Find and Publish Draft Release
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v6
|
||||||
with:
|
with:
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
script: |
|
script: |
|
||||||
const { owner, repo } = context.repo;
|
// Get the list of releases
|
||||||
const tagName = process.env.TAG_VERSION;
|
const releases = await github.rest.repos.listReleases({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
// Find the draft release where the title and tag_name are the same
|
||||||
let release;
|
const draftRelease = releases.data.find(release =>
|
||||||
try {
|
release.draft && release.name === release.tag_name
|
||||||
const response = await github.rest.repos.getReleaseByTag({
|
);
|
||||||
owner,
|
|
||||||
repo,
|
if (draftRelease) {
|
||||||
tag: tagName
|
// Publish the draft release using the release_id
|
||||||
});
|
|
||||||
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({
|
await github.rest.repos.updateRelease({
|
||||||
owner,
|
owner: context.repo.owner,
|
||||||
repo,
|
repo: context.repo.repo,
|
||||||
release_id: release.id,
|
release_id: draftRelease.id, // Use release_id
|
||||||
draft: false,
|
draft: false
|
||||||
prerelease: release.prerelease
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const status = release.draft ? "was draft" : "was already published";
|
core.info(`Draft Release ${draftRelease.tag_name} published successfully.`);
|
||||||
core.info(`Release ${tagName} ensured to be published (${status}).`);
|
} else {
|
||||||
|
core.info("No matching draft release found.");
|
||||||
} catch (error) {
|
}
|
||||||
core.warning(`Could not find or update release for tag ${tagName}: ${error.message}`);
|
|
||||||
}
|
|
||||||
+1
-1
@@ -43,7 +43,7 @@ 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.mod $SERVER_DIR/
|
||||||
COPY --from=builder $SERVER_DIR/go.sum $SERVER_DIR/
|
COPY --from=builder $SERVER_DIR/go.sum $SERVER_DIR/
|
||||||
|
|
||||||
RUN go get github.com/openimsdk/gomake@v0.0.15-alpha.5
|
RUN go get github.com/openimsdk/gomake@v0.0.14-alpha.5
|
||||||
|
|
||||||
# Set the command to run when the container starts
|
# Set the command to run when the container starts
|
||||||
ENTRYPOINT ["sh", "-c", "mage start && tail -f /dev/null"]
|
ENTRYPOINT ["sh", "-c", "mage start && tail -f /dev/null"]
|
||||||
|
|||||||
+1
-2
@@ -1,8 +1,7 @@
|
|||||||
address: [ localhost:16379 ]
|
address: [ localhost:16379 ]
|
||||||
username:
|
username:
|
||||||
password: openIM123
|
password: openIM123
|
||||||
# redisMode can be "cluster", "sentinel", or "standalone"
|
clusterMode: false
|
||||||
redisMode: "standalone"
|
|
||||||
db: 0
|
db: 0
|
||||||
maxRetry: 10
|
maxRetry: 10
|
||||||
poolSize: 100
|
poolSize: 100
|
||||||
|
|||||||
+1
-5
@@ -15,8 +15,4 @@ imAdminUserID: [ imAdmin ]
|
|||||||
# 1: For Android, iOS, Windows, Mac, and web platforms, only one instance can be online at a time
|
# 1: For Android, iOS, Windows, Mac, and web platforms, only one instance can be online at a time
|
||||||
multiLogin:
|
multiLogin:
|
||||||
policy: 1
|
policy: 1
|
||||||
maxNumOneEnd: 30
|
maxNumOneEnd: 30
|
||||||
|
|
||||||
rpcMaxBodySize:
|
|
||||||
requestMaxBodySize: 8388608
|
|
||||||
responseMaxBodySize: 8388608
|
|
||||||
+4
-56
@@ -63,12 +63,7 @@ services:
|
|||||||
restart: always
|
restart: always
|
||||||
sysctls:
|
sysctls:
|
||||||
net.core.somaxconn: 1024
|
net.core.somaxconn: 1024
|
||||||
command: >
|
command: redis-server /usr/local/redis/config/redis.conf --requirepass openIM123 --appendonly yes
|
||||||
redis-server
|
|
||||||
--requirepass openIM123
|
|
||||||
--appendonly yes
|
|
||||||
--aof-use-rdb-preamble yes
|
|
||||||
--save ""
|
|
||||||
networks:
|
networks:
|
||||||
- openim
|
- openim
|
||||||
|
|
||||||
@@ -104,62 +99,15 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
#KAFKA_HEAP_OPTS: "-Xms128m -Xmx256m"
|
#KAFKA_HEAP_OPTS: "-Xms128m -Xmx256m"
|
||||||
TZ: Asia/Shanghai
|
TZ: Asia/Shanghai
|
||||||
# Unique identifier for the Kafka node (required in controller mode)
|
|
||||||
KAFKA_CFG_NODE_ID: 0
|
KAFKA_CFG_NODE_ID: 0
|
||||||
# Defines the roles this Kafka node plays: broker, controller, or both
|
|
||||||
KAFKA_CFG_PROCESS_ROLES: controller,broker
|
KAFKA_CFG_PROCESS_ROLES: controller,broker
|
||||||
# Specifies which nodes are controller nodes for quorum voting.
|
|
||||||
# The syntax follows the KRaft mode (no ZooKeeper): node.id@host:port
|
|
||||||
# The controller listener endpoint here is kafka:9093
|
|
||||||
KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 0@kafka:9093
|
KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 0@kafka:9093
|
||||||
# Specifies which listener is used for controller-to-controller communication
|
KAFKA_CFG_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094
|
||||||
|
KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,EXTERNAL://localhost:19094
|
||||||
|
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT
|
||||||
KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER
|
KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER
|
||||||
# Default number of partitions for new topics
|
|
||||||
KAFKA_NUM_PARTITIONS: 8
|
KAFKA_NUM_PARTITIONS: 8
|
||||||
# Whether to enable automatic topic creation
|
|
||||||
KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: "true"
|
KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: "true"
|
||||||
# Kafka internal listeners; Kafka supports multiple ports with different protocols
|
|
||||||
# Each port is used for a specific purpose: INTERNAL for internal broker communication,
|
|
||||||
# CONTROLLER for controller communication, EXTERNAL for external client connections.
|
|
||||||
# These logical listener names are mapped to actual protocols via KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP
|
|
||||||
# In short, Kafka is listening on three logical ports: 9092 for internal communication,
|
|
||||||
# 9093 for controller traffic, and 9094 for external access.
|
|
||||||
KAFKA_CFG_LISTENERS: "INTERNAL://:9092,CONTROLLER://:9093,EXTERNAL://:9094"
|
|
||||||
# Addresses advertised to clients. INTERNAL://kafka:9092 uses the internal Docker service name 'kafka',
|
|
||||||
# so other containers can access Kafka via kafka:9092.
|
|
||||||
# EXTERNAL://localhost:19094 is the address external clients (e.g., in the LAN) should use to connect.
|
|
||||||
# If Kafka is deployed on a different machine than IM, 'localhost' should be replaced with the LAN IP.
|
|
||||||
KAFKA_CFG_ADVERTISED_LISTENERS: "INTERNAL://kafka:9092,EXTERNAL://localhost:19094"
|
|
||||||
# Maps logical listener names to actual protocols.
|
|
||||||
# Supported protocols include: PLAINTEXT, SSL, SASL_PLAINTEXT, SASL_SSL
|
|
||||||
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: "CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,INTERNAL:PLAINTEXT"
|
|
||||||
# Defines which listener is used for inter-broker communication within the Kafka cluster
|
|
||||||
KAFKA_CFG_INTER_BROKER_LISTENER_NAME: "INTERNAL"
|
|
||||||
|
|
||||||
|
|
||||||
# Authentication configuration variables - comment out to disable auth
|
|
||||||
# KAFKA_USERNAME: "openIM"
|
|
||||||
# KAFKA_PASSWORD: "openIM123"
|
|
||||||
command: >
|
|
||||||
/bin/sh -c '
|
|
||||||
if [ -n "$${KAFKA_USERNAME}" ] && [ -n "$${KAFKA_PASSWORD}" ]; then
|
|
||||||
echo "=== Kafka SASL Authentication ENABLED ==="
|
|
||||||
echo "Username: $${KAFKA_USERNAME}"
|
|
||||||
|
|
||||||
# Set environment variables for SASL authentication
|
|
||||||
export KAFKA_CFG_LISTENERS="SASL_PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094"
|
|
||||||
export KAFKA_CFG_ADVERTISED_LISTENERS="SASL_PLAINTEXT://kafka:9092,EXTERNAL://localhost:19094"
|
|
||||||
export KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP="CONTROLLER:PLAINTEXT,EXTERNAL:SASL_PLAINTEXT,SASL_PLAINTEXT:SASL_PLAINTEXT"
|
|
||||||
export KAFKA_CFG_SASL_ENABLED_MECHANISMS="PLAIN"
|
|
||||||
export KAFKA_CFG_SASL_MECHANISM_INTER_BROKER_PROTOCOL="PLAIN"
|
|
||||||
export KAFKA_CFG_INTER_BROKER_LISTENER_NAME="SASL_PLAINTEXT"
|
|
||||||
export KAFKA_CLIENT_USERS="$${KAFKA_USERNAME}"
|
|
||||||
export KAFKA_CLIENT_PASSWORDS="$${KAFKA_PASSWORD}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Start Kafka with the configured environment
|
|
||||||
exec /opt/bitnami/scripts/kafka/entrypoint.sh /opt/bitnami/scripts/kafka/run.sh
|
|
||||||
'
|
|
||||||
networks:
|
networks:
|
||||||
- openim
|
- openim
|
||||||
|
|
||||||
|
|||||||
@@ -12,15 +12,15 @@ require (
|
|||||||
github.com/gorilla/websocket v1.5.1
|
github.com/gorilla/websocket v1.5.1
|
||||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
|
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
|
||||||
github.com/mitchellh/mapstructure v1.5.0
|
github.com/mitchellh/mapstructure v1.5.0
|
||||||
github.com/openimsdk/protocol v0.0.73-alpha.18
|
github.com/openimsdk/protocol v0.0.72-alpha.78
|
||||||
github.com/openimsdk/tools v0.0.50-alpha.106
|
github.com/openimsdk/tools v0.0.50-alpha.74
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/prometheus/client_golang v1.18.0
|
github.com/prometheus/client_golang v1.18.0
|
||||||
github.com/stretchr/testify v1.10.0
|
github.com/stretchr/testify v1.9.0
|
||||||
go.mongodb.org/mongo-driver v1.14.0
|
go.mongodb.org/mongo-driver v1.14.0
|
||||||
google.golang.org/api v0.170.0
|
google.golang.org/api v0.170.0
|
||||||
google.golang.org/grpc v1.71.0
|
google.golang.org/grpc v1.68.0
|
||||||
google.golang.org/protobuf v1.36.4
|
google.golang.org/protobuf v1.35.1
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -35,18 +35,19 @@ require (
|
|||||||
github.com/hashicorp/golang-lru/v2 v2.0.7
|
github.com/hashicorp/golang-lru/v2 v2.0.7
|
||||||
github.com/kelindar/bitmap v1.5.2
|
github.com/kelindar/bitmap v1.5.2
|
||||||
github.com/likexian/gokit v0.25.13
|
github.com/likexian/gokit v0.25.13
|
||||||
github.com/openimsdk/gomake v0.0.15-alpha.5
|
github.com/openimsdk/gomake v0.0.14-alpha.5
|
||||||
github.com/redis/go-redis/v9 v9.4.0
|
github.com/redis/go-redis/v9 v9.4.0
|
||||||
github.com/robfig/cron/v3 v3.0.1
|
github.com/robfig/cron/v3 v3.0.1
|
||||||
github.com/shirou/gopsutil v3.21.11+incompatible
|
github.com/shirou/gopsutil v3.21.11+incompatible
|
||||||
github.com/spf13/viper v1.18.2
|
github.com/spf13/viper v1.18.2
|
||||||
|
go.etcd.io/etcd/client/v3 v3.5.13
|
||||||
go.uber.org/automaxprocs v1.5.3
|
go.uber.org/automaxprocs v1.5.3
|
||||||
golang.org/x/sync v0.10.0
|
golang.org/x/sync v0.8.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
cloud.google.com/go v0.112.1 // 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.5.0 // indirect
|
||||||
cloud.google.com/go/firestore v1.15.0 // indirect
|
cloud.google.com/go/firestore v1.15.0 // indirect
|
||||||
cloud.google.com/go/iam v1.1.7 // indirect
|
cloud.google.com/go/iam v1.1.7 // indirect
|
||||||
cloud.google.com/go/longrunning v0.5.5 // indirect
|
cloud.google.com/go/longrunning v0.5.5 // indirect
|
||||||
@@ -88,7 +89,7 @@ require (
|
|||||||
github.com/eapache/queue v1.1.0 // indirect
|
github.com/eapache/queue v1.1.0 // indirect
|
||||||
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
|
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
|
||||||
github.com/felixge/httpsnoop v1.0.4 // indirect
|
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||||
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||||
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
|
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
|
||||||
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
|
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
|
||||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||||
@@ -155,7 +156,6 @@ require (
|
|||||||
github.com/rs/xid v1.5.0 // indirect
|
github.com/rs/xid v1.5.0 // indirect
|
||||||
github.com/sagikazarmark/locafero v0.4.0 // indirect
|
github.com/sagikazarmark/locafero v0.4.0 // indirect
|
||||||
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
|
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
|
||||||
github.com/sercand/kuberesolver/v6 v6.0.1 // indirect
|
|
||||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||||
github.com/spf13/afero v1.11.0 // indirect
|
github.com/spf13/afero v1.11.0 // indirect
|
||||||
github.com/spf13/cast v1.6.0 // indirect
|
github.com/spf13/cast v1.6.0 // indirect
|
||||||
@@ -174,29 +174,27 @@ require (
|
|||||||
github.com/yusufpapurcu/wmi v1.2.4 // indirect
|
github.com/yusufpapurcu/wmi v1.2.4 // indirect
|
||||||
go.etcd.io/etcd/api/v3 v3.5.13 // indirect
|
go.etcd.io/etcd/api/v3 v3.5.13 // indirect
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.13 // indirect
|
go.etcd.io/etcd/client/pkg/v3 v3.5.13 // indirect
|
||||||
go.etcd.io/etcd/client/v3 v3.5.13 // indirect
|
|
||||||
go.opencensus.io v0.24.0 // indirect
|
go.opencensus.io v0.24.0 // indirect
|
||||||
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
|
|
||||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // 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/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
|
||||||
go.opentelemetry.io/otel v1.34.0 // indirect
|
go.opentelemetry.io/otel v1.24.0 // indirect
|
||||||
go.opentelemetry.io/otel/metric v1.34.0 // indirect
|
go.opentelemetry.io/otel/metric v1.24.0 // indirect
|
||||||
go.opentelemetry.io/otel/trace v1.34.0 // indirect
|
go.opentelemetry.io/otel/trace v1.24.0 // indirect
|
||||||
go.uber.org/atomic v1.9.0 // indirect
|
go.uber.org/atomic v1.9.0 // indirect
|
||||||
go.uber.org/multierr v1.11.0 // indirect
|
go.uber.org/multierr v1.11.0 // indirect
|
||||||
golang.org/x/arch v0.7.0 // indirect
|
golang.org/x/arch v0.7.0 // indirect
|
||||||
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
|
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
|
||||||
golang.org/x/image v0.15.0 // indirect
|
golang.org/x/image v0.15.0 // indirect
|
||||||
golang.org/x/net v0.34.0 // indirect
|
golang.org/x/net v0.29.0 // indirect
|
||||||
golang.org/x/oauth2 v0.25.0 // indirect
|
golang.org/x/oauth2 v0.23.0 // indirect
|
||||||
golang.org/x/sys v0.29.0 // indirect
|
golang.org/x/sys v0.25.0 // indirect
|
||||||
golang.org/x/term v0.28.0 // indirect
|
golang.org/x/term v0.24.0 // indirect
|
||||||
golang.org/x/text v0.21.0 // indirect
|
golang.org/x/text v0.18.0 // indirect
|
||||||
golang.org/x/time v0.5.0 // indirect
|
golang.org/x/time v0.5.0 // indirect
|
||||||
google.golang.org/appengine/v2 v2.0.2 // indirect
|
google.golang.org/appengine/v2 v2.0.2 // indirect
|
||||||
google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // 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/api v0.0.0-20240903143218-8af14fe29dc1 // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
|
||||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||||
gorm.io/gorm v1.25.8 // indirect
|
gorm.io/gorm v1.25.8 // indirect
|
||||||
@@ -218,6 +216,6 @@ require (
|
|||||||
github.com/spf13/cobra v1.8.0
|
github.com/spf13/cobra v1.8.0
|
||||||
github.com/ugorji/go/codec v1.2.12 // indirect
|
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||||
go.uber.org/zap v1.24.0 // indirect
|
go.uber.org/zap v1.24.0 // indirect
|
||||||
golang.org/x/crypto v0.32.0 // indirect
|
golang.org/x/crypto v0.27.0 // indirect
|
||||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
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 h1:uJSeirPke5UNZHIb4SxfZklVSiWWVqW4oXlETwZziwM=
|
||||||
cloud.google.com/go v0.112.1/go.mod h1:+Vbu+Y1UU+I1rjmzeMOb/8RfkKJK2Gyxi1X6jJCZLo4=
|
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.5.0 h1:Zr0eK8JbFv6+Wi4ilXAR8FJ3wyNdpxHKJNPos6LTZOY=
|
||||||
cloud.google.com/go/compute/metadata v0.6.0/go.mod h1:FjyFAW1MW0C203CEOMDTu3Dk1FlqW3Rga40jzHL4hfg=
|
cloud.google.com/go/compute/metadata v0.5.0/go.mod h1:aHnloV2TPI38yx4s9+wAZhHykWvVCfu7hQbF+9CWoiY=
|
||||||
cloud.google.com/go/firestore v1.15.0 h1:/k8ppuWOtNuDHt2tsRV42yI21uaGnKDEQnRFeBpbFF8=
|
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/firestore v1.15.0/go.mod h1:GWOxFXcv8GZUtYpWHw/w6IuYNux/BtmeVTMmjrm4yhk=
|
||||||
cloud.google.com/go/iam v1.1.7 h1:z4VHOhwKLF/+UYXAJDFwGtNF0b6gjsW1Pk9Ml0U/IoM=
|
cloud.google.com/go/iam v1.1.7 h1:z4VHOhwKLF/+UYXAJDFwGtNF0b6gjsW1Pk9Ml0U/IoM=
|
||||||
@@ -117,8 +117,8 @@ github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8
|
|||||||
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
|
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
|
||||||
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
||||||
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
||||||
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
|
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
|
||||||
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
|
||||||
github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E=
|
github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E=
|
||||||
github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
|
github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
|
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
|
||||||
@@ -345,14 +345,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/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 h1:Vw7br2PCDYijJHSfBOWhov+8cAnUf8MfMaIOV323l6Y=
|
||||||
github.com/onsi/gomega v1.25.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM=
|
github.com/onsi/gomega v1.25.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM=
|
||||||
github.com/openimsdk/gomake v0.0.15-alpha.5 h1:eEZCEHm+NsmcO3onXZPIUbGFCYPYbsX5beV3ZyOsGhY=
|
github.com/openimsdk/gomake v0.0.14-alpha.5 h1:VY9c5x515lTfmdhhPjMvR3BBRrRquAUCFsz7t7vbv7Y=
|
||||||
github.com/openimsdk/gomake v0.0.15-alpha.5/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI=
|
github.com/openimsdk/gomake v0.0.14-alpha.5/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI=
|
||||||
github.com/openimsdk/protocol v0.0.73-alpha.12 h1:2NYawXeHChYUeSme6QJ9pOLh+Empce2WmwEtbP4JvKk=
|
github.com/openimsdk/protocol v0.0.72-alpha.78 h1:n9HVj5olMPiGLF3Z4apPvvYzn2yOpyrsn2/YiAaIsxw=
|
||||||
github.com/openimsdk/protocol v0.0.73-alpha.12/go.mod h1:WF7EuE55vQvpyUAzDXcqg+B+446xQyEba0X35lTINmw=
|
github.com/openimsdk/protocol v0.0.72-alpha.78/go.mod h1:WF7EuE55vQvpyUAzDXcqg+B+446xQyEba0X35lTINmw=
|
||||||
github.com/openimsdk/protocol v0.0.73-alpha.18 h1:LXmDFx3KnMd2mN0/S3Q2U33Ft/DHvplSsINO0/bto/c=
|
github.com/openimsdk/tools v0.0.50-alpha.74 h1:yh10SiMiivMEjicEQg+QAsH4pvaO+4noMPdlw+ew0Kc=
|
||||||
github.com/openimsdk/protocol v0.0.73-alpha.18/go.mod h1:WF7EuE55vQvpyUAzDXcqg+B+446xQyEba0X35lTINmw=
|
github.com/openimsdk/tools v0.0.50-alpha.74/go.mod h1:n2poR3asX1e1XZce4O+MOWAp+X02QJRFvhcLCXZdzRo=
|
||||||
github.com/openimsdk/tools v0.0.50-alpha.106 h1:gaqU08IbRxOdL16ZEQNyYLhCTf7K1HNkrik8KZLA+BM=
|
|
||||||
github.com/openimsdk/tools v0.0.50-alpha.106/go.mod h1:x9i/e+WJFW4tocy6RNJQ9NofQiP3KJ1Y576/06TqOG4=
|
|
||||||
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
|
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/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
|
||||||
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
|
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
|
||||||
@@ -386,8 +384,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/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.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.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.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
|
||||||
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
|
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
|
||||||
github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
|
github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
|
||||||
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
@@ -395,8 +393,6 @@ github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6ke
|
|||||||
github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
|
github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
|
||||||
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
|
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
|
||||||
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
|
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/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=
|
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.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
|
||||||
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
|
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
|
||||||
@@ -424,9 +420,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
|||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
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.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
|
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
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/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
|
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
|
||||||
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
|
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/common v1.0.563/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
|
||||||
@@ -466,22 +461,18 @@ 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.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 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
|
||||||
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
|
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
|
||||||
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
|
|
||||||
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
|
|
||||||
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 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/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 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk=
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw=
|
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.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=
|
||||||
go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI=
|
go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=
|
||||||
go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ=
|
go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI=
|
||||||
go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE=
|
go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco=
|
||||||
go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7Wr1A=
|
go.opentelemetry.io/otel/sdk v1.22.0 h1:6coWHw9xw7EfClIC/+O31R8IY3/+EiRFHevmHafB2Gw=
|
||||||
go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU=
|
go.opentelemetry.io/otel/sdk v1.22.0/go.mod h1:iu7luyVGYovrRpe2fmj3CVKouQNdTOkxtLzPvPz1DOc=
|
||||||
go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk=
|
go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI=
|
||||||
go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w=
|
go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU=
|
||||||
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 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
|
||||||
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||||
go.uber.org/automaxprocs v1.5.3 h1:kWazyxZUrS3Gs4qUpbwo5kEIMGe/DAvi5Z4tl2NW4j8=
|
go.uber.org/automaxprocs v1.5.3 h1:kWazyxZUrS3Gs4qUpbwo5kEIMGe/DAvi5Z4tl2NW4j8=
|
||||||
@@ -502,8 +493,8 @@ 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.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.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.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
|
||||||
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
|
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
|
||||||
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
|
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
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 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
|
||||||
golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
|
golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
|
||||||
@@ -531,19 +522,19 @@ 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.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.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
|
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
|
||||||
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
|
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.25.0 h1:CY4y7XT9v0cRI9oupztF8AgiIu99L/ksR/Xp/6jrZ70=
|
golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs=
|
||||||
golang.org/x/oauth2 v0.25.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
|
golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
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-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-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-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-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.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.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
|
||||||
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
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-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
@@ -558,14 +549,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.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.5.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.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
|
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
|
||||||
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
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.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.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.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||||
golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg=
|
golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
|
||||||
golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
|
golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
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.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
@@ -574,8 +565,8 @@ 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.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
|
||||||
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
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.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
|
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
|
||||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||||
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
|
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/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
@@ -606,17 +597,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-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 h1:9+tzLLstTlPTRyJTh+ah5wIMsBW5c4tQwGTN3thOW9Y=
|
||||||
google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9/go.mod h1:mqHbVIp48Muh7Ywss/AD6I5kNVKZMmAa/QEW58Gxp2s=
|
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-20240903143218-8af14fe29dc1 h1:hjSy6tcFQZ171igDaN5QHOw2n6vx40juYbC/x67CEhc=
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20250106144421-5f5ef82da422/go.mod h1:b6h1vNKhxaSoEI+5jc3PJUCustfli/mRab7295pY7rw=
|
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:qpvKtACPCQhAdu3PyQgV4l3LMXZEtft7y8QcarRsp9I=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f h1:OxYkA3wjPsZyBylwymxSHa7ViiW1Sml4ToBrncvFehI=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 h1:pPJltXNxVzT4pK9yD8vR9X75DaWYYmLGMsEvBfFQZzQ=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f/go.mod h1:+2Yz8+CLJbIfL9z73EW45avw8Lmge3xVElCP9zEKi50=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
|
||||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
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.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
|
||||||
google.golang.org/grpc v1.71.0 h1:kF77BGdPTQ4/JZWMlb9VpJ5pa25aqvVqogsxNHHdeBg=
|
google.golang.org/grpc v1.68.0 h1:aHQeeJbo8zAkAa3pRzrVjZlbz6uSfeOXlJNQM0RAbz0=
|
||||||
google.golang.org/grpc v1.71.0/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec=
|
google.golang.org/grpc v1.68.0/go.mod h1:fmSPC5AsjSBCK54MyHRx48kpOti1/jRfOlwEWywNjWA=
|
||||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
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-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||||
@@ -626,8 +617,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.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.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.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||||
google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM=
|
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
|
||||||
google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
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-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||||
|
|||||||
@@ -114,7 +114,3 @@ func (o *FriendApi) GetIncrementalBlacks(c *gin.Context) {
|
|||||||
func (o *FriendApi) GetFullFriendUserIDs(c *gin.Context) {
|
func (o *FriendApi) GetFullFriendUserIDs(c *gin.Context) {
|
||||||
a2r.Call(c, relation.FriendClient.GetFullFriendUserIDs, o.Client)
|
a2r.Call(c, relation.FriendClient.GetFullFriendUserIDs, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *FriendApi) GetSelfUnhandledApplyCount(c *gin.Context) {
|
|
||||||
a2r.Call(c, relation.FriendClient.GetSelfUnhandledApplyCount, o.Client)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -165,7 +165,3 @@ func (o *GroupApi) GetFullGroupMemberUserIDs(c *gin.Context) {
|
|||||||
func (o *GroupApi) GetFullJoinGroupIDs(c *gin.Context) {
|
func (o *GroupApi) GetFullJoinGroupIDs(c *gin.Context) {
|
||||||
a2r.Call(c, group.GroupClient.GetFullJoinGroupIDs, o.Client)
|
a2r.Call(c, group.GroupClient.GetFullJoinGroupIDs, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) GetGroupApplicationUnhandledCount(c *gin.Context) {
|
|
||||||
a2r.Call(c, group.GroupClient.GetGroupApplicationUnhandledCount, o.Client)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -94,16 +94,9 @@ func Start(ctx context.Context, index int, cfg *Config) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
etcdClient, ok := client.(*etcd.SvcDiscoveryRegistryImpl)
|
etcdClient := client.(*etcd.SvcDiscoveryRegistryImpl).GetClient()
|
||||||
if !ok {
|
|
||||||
return errs.New("only etcd support autoSetPorts").Wrap()
|
|
||||||
}
|
|
||||||
|
|
||||||
target, err := jsonutil.JsonMarshal(prommetrics.BuildDefaultTarget(registerIP, prometheusPort))
|
_, err = etcdClient.Put(ctx, prommetrics.BuildDiscoveryKey(prommetrics.APIKeyName), jsonutil.StructToJsonString(prommetrics.BuildDefaultTarget(registerIP, prometheusPort)))
|
||||||
if err != nil {
|
|
||||||
return errs.Wrap(err)
|
|
||||||
}
|
|
||||||
err = etcdClient.SetWithLease(ctx, prommetrics.BuildDiscoveryKey(prommetrics.APIKeyName, index), target, prommetrics.TTL)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errs.WrapMsg(err, "etcd put err")
|
return errs.WrapMsg(err, "etcd put err")
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-61
@@ -2,14 +2,10 @@ package jssdk
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
|
||||||
"github.com/openimsdk/protocol/constant"
|
|
||||||
"github.com/openimsdk/tools/log"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
|
||||||
"github.com/openimsdk/protocol/conversation"
|
"github.com/openimsdk/protocol/conversation"
|
||||||
"github.com/openimsdk/protocol/jssdk"
|
"github.com/openimsdk/protocol/jssdk"
|
||||||
"github.com/openimsdk/protocol/msg"
|
"github.com/openimsdk/protocol/msg"
|
||||||
@@ -113,7 +109,10 @@ func (x *JSSdk) getActiveConversations(ctx context.Context, req *jssdk.GetActive
|
|||||||
if len(conversationIDs) == 0 {
|
if len(conversationIDs) == 0 {
|
||||||
return &jssdk.GetActiveConversationsResp{}, nil
|
return &jssdk.GetActiveConversationsResp{}, nil
|
||||||
}
|
}
|
||||||
|
readSeq, err := x.msgClient.GetHasReadSeqs(ctx, conversationIDs, req.OwnerUserID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
activeConversation, err := x.msgClient.GetActiveConversation(ctx, conversationIDs)
|
activeConversation, err := x.msgClient.GetActiveConversation(ctx, conversationIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -121,10 +120,6 @@ func (x *JSSdk) getActiveConversations(ctx context.Context, req *jssdk.GetActive
|
|||||||
if len(activeConversation) == 0 {
|
if len(activeConversation) == 0 {
|
||||||
return &jssdk.GetActiveConversationsResp{}, nil
|
return &jssdk.GetActiveConversationsResp{}, nil
|
||||||
}
|
}
|
||||||
readSeq, err := x.msgClient.GetHasReadSeqs(ctx, conversationIDs, req.OwnerUserID)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
sortConversations := sortActiveConversations{
|
sortConversations := sortActiveConversations{
|
||||||
Conversation: activeConversation,
|
Conversation: activeConversation,
|
||||||
}
|
}
|
||||||
@@ -152,7 +147,6 @@ func (x *JSSdk) getActiveConversations(ctx context.Context, req *jssdk.GetActive
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
x.checkMessagesAndGetLastMessage(ctx, req.OwnerUserID, msgs)
|
|
||||||
conversationMap := datautil.SliceToMap(conversations, func(c *conversation.Conversation) string {
|
conversationMap := datautil.SliceToMap(conversations, func(c *conversation.Conversation) string {
|
||||||
return c.ConversationID
|
return c.ConversationID
|
||||||
})
|
})
|
||||||
@@ -162,15 +156,16 @@ func (x *JSSdk) getActiveConversations(ctx context.Context, req *jssdk.GetActive
|
|||||||
if !ok {
|
if !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
var lastMsg *sdkws.MsgData
|
||||||
if msgList, ok := msgs[c.ConversationID]; ok && len(msgList.Msgs) > 0 {
|
if msgList, ok := msgs[c.ConversationID]; ok && len(msgList.Msgs) > 0 {
|
||||||
resp = append(resp, &jssdk.ConversationMsg{
|
lastMsg = msgList.Msgs[0]
|
||||||
Conversation: conv,
|
|
||||||
LastMsg: msgList.Msgs[0],
|
|
||||||
MaxSeq: c.MaxSeq,
|
|
||||||
ReadSeq: readSeq[c.ConversationID],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
resp = append(resp, &jssdk.ConversationMsg{
|
||||||
|
Conversation: conv,
|
||||||
|
LastMsg: lastMsg,
|
||||||
|
MaxSeq: c.MaxSeq,
|
||||||
|
ReadSeq: readSeq[c.ConversationID],
|
||||||
|
})
|
||||||
}
|
}
|
||||||
if err := x.fillConversations(ctx, resp); err != nil {
|
if err := x.fillConversations(ctx, resp); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -224,18 +219,18 @@ func (x *JSSdk) getConversations(ctx context.Context, req *jssdk.GetConversation
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
x.checkMessagesAndGetLastMessage(ctx, req.OwnerUserID, msgs)
|
|
||||||
resp := make([]*jssdk.ConversationMsg, 0, len(conversations))
|
resp := make([]*jssdk.ConversationMsg, 0, len(conversations))
|
||||||
for _, c := range conversations {
|
for _, c := range conversations {
|
||||||
|
var lastMsg *sdkws.MsgData
|
||||||
if msgList, ok := msgs[c.ConversationID]; ok && len(msgList.Msgs) > 0 {
|
if msgList, ok := msgs[c.ConversationID]; ok && len(msgList.Msgs) > 0 {
|
||||||
resp = append(resp, &jssdk.ConversationMsg{
|
lastMsg = msgList.Msgs[0]
|
||||||
Conversation: c,
|
|
||||||
LastMsg: msgList.Msgs[0],
|
|
||||||
MaxSeq: maxSeqs[c.ConversationID],
|
|
||||||
ReadSeq: readSeqs[c.ConversationID],
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
resp = append(resp, &jssdk.ConversationMsg{
|
||||||
|
Conversation: c,
|
||||||
|
LastMsg: lastMsg,
|
||||||
|
MaxSeq: maxSeqs[c.ConversationID],
|
||||||
|
ReadSeq: readSeqs[c.ConversationID],
|
||||||
|
})
|
||||||
}
|
}
|
||||||
if err := x.fillConversations(ctx, resp); err != nil {
|
if err := x.fillConversations(ctx, resp); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -252,38 +247,3 @@ func (x *JSSdk) getConversations(ctx context.Context, req *jssdk.GetConversation
|
|||||||
UnreadCount: unreadCount,
|
UnreadCount: unreadCount,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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) {
|
|
||||||
var conversationIDs []string
|
|
||||||
|
|
||||||
for conversationID, message := range messages {
|
|
||||||
allInValid := true
|
|
||||||
for _, data := range message.Msgs {
|
|
||||||
if data.Status < constant.MsgStatusHasDeleted {
|
|
||||||
allInValid = false
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// when the conversation has been deleted by the user, the length of message.Msgs is empty
|
|
||||||
if allInValid && len(message.Msgs) > 0 {
|
|
||||||
conversationIDs = append(conversationIDs, conversationID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(conversationIDs) > 0 {
|
|
||||||
resp, err := x.msgClient.GetLastMessage(ctx, &msg.GetLastMessageReq{
|
|
||||||
UserID: userID,
|
|
||||||
ConversationIDs: conversationIDs,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
log.ZError(ctx, "fetchLatestValidMessages", err, "conversationIDs", conversationIDs)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
for conversationID, message := range resp.Msgs {
|
|
||||||
messages[conversationID] = &sdkws.PullMsgs{Msgs: []*sdkws.MsgData{message}}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -12,11 +11,13 @@ import (
|
|||||||
"github.com/openimsdk/tools/discovery"
|
"github.com/openimsdk/tools/discovery"
|
||||||
"github.com/openimsdk/tools/discovery/etcd"
|
"github.com/openimsdk/tools/discovery/etcd"
|
||||||
"github.com/openimsdk/tools/errs"
|
"github.com/openimsdk/tools/errs"
|
||||||
|
"github.com/openimsdk/tools/log"
|
||||||
|
clientv3 "go.etcd.io/etcd/client/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PrometheusDiscoveryApi struct {
|
type PrometheusDiscoveryApi struct {
|
||||||
config *Config
|
config *Config
|
||||||
client discovery.SvcDiscoveryRegistry
|
client *clientv3.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPrometheusDiscoveryApi(cfg *Config, client discovery.SvcDiscoveryRegistry) *PrometheusDiscoveryApi {
|
func NewPrometheusDiscoveryApi(cfg *Config, client discovery.SvcDiscoveryRegistry) *PrometheusDiscoveryApi {
|
||||||
@@ -24,7 +25,7 @@ func NewPrometheusDiscoveryApi(cfg *Config, client discovery.SvcDiscoveryRegistr
|
|||||||
config: cfg,
|
config: cfg,
|
||||||
}
|
}
|
||||||
if cfg.Discovery.Enable == config.ETCD {
|
if cfg.Discovery.Enable == config.ETCD {
|
||||||
api.client = client.(*etcd.SvcDiscoveryRegistryImpl)
|
api.client = client.(*etcd.SvcDiscoveryRegistryImpl).GetClient()
|
||||||
}
|
}
|
||||||
return api
|
return api
|
||||||
}
|
}
|
||||||
@@ -37,32 +38,35 @@ func (p *PrometheusDiscoveryApi) Enable(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *PrometheusDiscoveryApi) discovery(c *gin.Context, key string) {
|
func (p *PrometheusDiscoveryApi) discovery(c *gin.Context, key string) {
|
||||||
value, err := p.client.GetKeyWithPrefix(c, prommetrics.BuildDiscoveryKeyPrefix(key))
|
eResp, err := p.client.Get(c, prommetrics.BuildDiscoveryKey(key))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, discovery.ErrNotSupported) {
|
// Log and respond with an error if preparation fails.
|
||||||
c.JSON(http.StatusOK, []struct{}{})
|
apiresp.GinError(c, errs.WrapMsg(err, "etcd get err"))
|
||||||
return
|
|
||||||
}
|
|
||||||
apiresp.GinError(c, errs.WrapMsg(err, "get key value"))
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(value) == 0 {
|
if len(eResp.Kvs) == 0 {
|
||||||
c.JSON(http.StatusOK, []*prommetrics.RespTarget{})
|
c.JSON(http.StatusOK, []*prommetrics.Target{})
|
||||||
return
|
|
||||||
}
|
}
|
||||||
var resp prommetrics.RespTarget
|
|
||||||
for i := range value {
|
var (
|
||||||
var tmp prommetrics.Target
|
resp = &prommetrics.RespTarget{
|
||||||
if err = json.Unmarshal(value[i], &tmp); err != nil {
|
Targets: make([]string, 0, len(eResp.Kvs)),
|
||||||
apiresp.GinError(c, errs.WrapMsg(err, "json unmarshal err"))
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
|
||||||
resp.Targets = append(resp.Targets, tmp.Target)
|
for i := range eResp.Kvs {
|
||||||
resp.Labels = tmp.Labels // default label is fixed. See prommetrics.BuildDefaultTarget
|
var target prommetrics.Target
|
||||||
|
err = json.Unmarshal(eResp.Kvs[i].Value, &target)
|
||||||
|
if err != nil {
|
||||||
|
log.ZError(c, "prometheus unmarshal err", errs.Wrap(err))
|
||||||
|
}
|
||||||
|
resp.Targets = append(resp.Targets, target.Target)
|
||||||
|
if resp.Labels == nil {
|
||||||
|
resp.Labels = target.Labels
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSON(http.StatusOK, []*prommetrics.RespTarget{&resp})
|
c.JSON(200, []*prommetrics.RespTarget{resp})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PrometheusDiscoveryApi) Api(c *gin.Context) {
|
func (p *PrometheusDiscoveryApi) Api(c *gin.Context) {
|
||||||
|
|||||||
@@ -149,7 +149,6 @@ func newGinRouter(ctx context.Context, client discovery.SvcDiscoveryRegistry, co
|
|||||||
friendRouterGroup.POST("/update_friends", f.UpdateFriends)
|
friendRouterGroup.POST("/update_friends", f.UpdateFriends)
|
||||||
friendRouterGroup.POST("/get_incremental_friends", f.GetIncrementalFriends)
|
friendRouterGroup.POST("/get_incremental_friends", f.GetIncrementalFriends)
|
||||||
friendRouterGroup.POST("/get_full_friend_user_ids", f.GetFullFriendUserIDs)
|
friendRouterGroup.POST("/get_full_friend_user_ids", f.GetFullFriendUserIDs)
|
||||||
friendRouterGroup.POST("/get_self_unhandled_apply_count", f.GetSelfUnhandledApplyCount)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g := NewGroupApi(group.NewGroupClient(groupConn))
|
g := NewGroupApi(group.NewGroupClient(groupConn))
|
||||||
@@ -186,7 +185,6 @@ func newGinRouter(ctx context.Context, client discovery.SvcDiscoveryRegistry, co
|
|||||||
groupRouterGroup.POST("/get_incremental_group_members_batch", g.GetIncrementalGroupMemberBatch)
|
groupRouterGroup.POST("/get_incremental_group_members_batch", g.GetIncrementalGroupMemberBatch)
|
||||||
groupRouterGroup.POST("/get_full_group_member_user_ids", g.GetFullGroupMemberUserIDs)
|
groupRouterGroup.POST("/get_full_group_member_user_ids", g.GetFullGroupMemberUserIDs)
|
||||||
groupRouterGroup.POST("/get_full_join_group_ids", g.GetFullJoinGroupIDs)
|
groupRouterGroup.POST("/get_full_join_group_ids", g.GetFullJoinGroupIDs)
|
||||||
groupRouterGroup.POST("/get_group_application_unhandled_count", g.GetGroupApplicationUnhandledCount)
|
|
||||||
}
|
}
|
||||||
// certificate
|
// certificate
|
||||||
{
|
{
|
||||||
|
|||||||
+151
-10
@@ -16,6 +16,7 @@ package msggateway
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
@@ -30,6 +31,7 @@ import (
|
|||||||
"github.com/openimsdk/tools/errs"
|
"github.com/openimsdk/tools/errs"
|
||||||
"github.com/openimsdk/tools/log"
|
"github.com/openimsdk/tools/log"
|
||||||
"github.com/openimsdk/tools/mcontext"
|
"github.com/openimsdk/tools/mcontext"
|
||||||
|
"github.com/openimsdk/tools/utils/stringutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -62,7 +64,7 @@ type PingPongHandler func(string) error
|
|||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
w *sync.Mutex
|
w *sync.Mutex
|
||||||
conn ClientConn
|
conn LongConn
|
||||||
PlatformID int `json:"platformID"`
|
PlatformID int `json:"platformID"`
|
||||||
IsCompress bool `json:"isCompress"`
|
IsCompress bool `json:"isCompress"`
|
||||||
UserID string `json:"userID"`
|
UserID string `json:"userID"`
|
||||||
@@ -81,10 +83,10 @@ type Client struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ResetClient updates the client's state with new connection and context information.
|
// ResetClient updates the client's state with new connection and context information.
|
||||||
func (c *Client) ResetClient(ctx *UserConnContext, conn ClientConn, longConnServer LongConnServer) {
|
func (c *Client) ResetClient(ctx *UserConnContext, conn LongConn, longConnServer LongConnServer) {
|
||||||
c.w = new(sync.Mutex)
|
c.w = new(sync.Mutex)
|
||||||
c.conn = conn
|
c.conn = conn
|
||||||
c.PlatformID = ctx.GetPlatformID()
|
c.PlatformID = stringutil.StringToInt(ctx.GetPlatformID())
|
||||||
c.IsCompress = ctx.GetCompression()
|
c.IsCompress = ctx.GetCompression()
|
||||||
c.IsBackground = ctx.GetBackground()
|
c.IsBackground = ctx.GetBackground()
|
||||||
c.UserID = ctx.GetUserID()
|
c.UserID = ctx.GetUserID()
|
||||||
@@ -108,6 +110,22 @@ func (c *Client) ResetClient(ctx *UserConnContext, conn ClientConn, longConnServ
|
|||||||
c.subUserIDs = make(map[string]struct{})
|
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.
|
// readMessage continuously reads messages from the connection.
|
||||||
func (c *Client) readMessage() {
|
func (c *Client) readMessage() {
|
||||||
defer func() {
|
defer func() {
|
||||||
@@ -118,25 +136,52 @@ func (c *Client) readMessage() {
|
|||||||
c.close()
|
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 {
|
for {
|
||||||
log.ZDebug(c.ctx, "readMessage")
|
log.ZDebug(c.ctx, "readMessage")
|
||||||
message, returnErr := c.conn.ReadMessage()
|
messageType, message, returnErr := c.conn.ReadMessage()
|
||||||
if returnErr != nil {
|
if returnErr != nil {
|
||||||
log.ZWarn(c.ctx, "readMessage", returnErr)
|
log.ZWarn(c.ctx, "readMessage", returnErr, "messageType", messageType)
|
||||||
c.closedErr = returnErr
|
c.closedErr = returnErr
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.ZDebug(c.ctx, "readMessage", "messageType", messageType)
|
||||||
if c.closed.Load() {
|
if c.closed.Load() {
|
||||||
// The scenario where the connection has just been closed, but the coroutine has not exited
|
// The scenario where the connection has just been closed, but the coroutine has not exited
|
||||||
c.closedErr = ErrConnClosed
|
c.closedErr = ErrConnClosed
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
parseDataErr := c.handleMessage(message)
|
switch messageType {
|
||||||
if parseDataErr != nil {
|
case MessageBinary:
|
||||||
c.closedErr = parseDataErr
|
_ = 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
|
||||||
return
|
return
|
||||||
|
|
||||||
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -311,13 +356,109 @@ func (c *Client) writeBinaryMsg(resp Resp) error {
|
|||||||
c.w.Lock()
|
c.w.Lock()
|
||||||
defer c.w.Unlock()
|
defer c.w.Unlock()
|
||||||
|
|
||||||
|
err = c.conn.SetWriteDeadline(writeWait)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if c.IsCompress {
|
if c.IsCompress {
|
||||||
resultBuf, compressErr := c.longConnServer.CompressWithPool(encodedBuf)
|
resultBuf, compressErr := c.longConnServer.CompressWithPool(encodedBuf)
|
||||||
if compressErr != nil {
|
if compressErr != nil {
|
||||||
return compressErr
|
return compressErr
|
||||||
}
|
}
|
||||||
return c.conn.WriteMessage(resultBuf)
|
return c.conn.WriteMessage(MessageBinary, resultBuf)
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.conn.WriteMessage(encodedBuf)
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,212 +0,0 @@
|
|||||||
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 {
|
|
||||||
_ = c.closeBy(fmt.Errorf("websocket connection closed"))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
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))
|
|
||||||
_ = c.conn.Close()
|
|
||||||
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() {
|
|
||||||
var err error
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-c.done:
|
|
||||||
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.ZWarn(context.Background(), "ping handler recv ping", nil, "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.ZWarn(context.Background(), "ping handler write pong success", nil, "remoteAddr", c.conn.RemoteAddr(), "appData", appData)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *websocketClientConn) pongHandler(string) error {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+82
-133
@@ -15,31 +15,18 @@
|
|||||||
package msggateway
|
package msggateway
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/servererrs"
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/servererrs"
|
|
||||||
|
|
||||||
"github.com/openimsdk/protocol/constant"
|
"github.com/openimsdk/protocol/constant"
|
||||||
"github.com/openimsdk/tools/utils/encrypt"
|
"github.com/openimsdk/tools/utils/encrypt"
|
||||||
|
"github.com/openimsdk/tools/utils/stringutil"
|
||||||
"github.com/openimsdk/tools/utils/timeutil"
|
"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"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserConnContext struct {
|
type UserConnContext struct {
|
||||||
RespWriter http.ResponseWriter
|
RespWriter http.ResponseWriter
|
||||||
Req *http.Request
|
Req *http.Request
|
||||||
@@ -47,7 +34,6 @@ type UserConnContext struct {
|
|||||||
Method string
|
Method string
|
||||||
RemoteAddr string
|
RemoteAddr string
|
||||||
ConnID string
|
ConnID string
|
||||||
info *UserConnContextInfo
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *UserConnContext) Deadline() (deadline time.Time, ok bool) {
|
func (c *UserConnContext) Deadline() (deadline time.Time, ok bool) {
|
||||||
@@ -71,7 +57,7 @@ func (c *UserConnContext) Value(key any) any {
|
|||||||
case constant.ConnID:
|
case constant.ConnID:
|
||||||
return c.GetConnID()
|
return c.GetConnID()
|
||||||
case constant.OpUserPlatform:
|
case constant.OpUserPlatform:
|
||||||
return c.GetPlatformID()
|
return constant.PlatformIDToName(stringutil.StringToInt(c.GetPlatformID()))
|
||||||
case constant.RemoteAddr:
|
case constant.RemoteAddr:
|
||||||
return c.RemoteAddr
|
return c.RemoteAddr
|
||||||
default:
|
default:
|
||||||
@@ -96,91 +82,30 @@ func newContext(respWriter http.ResponseWriter, req *http.Request) *UserConnCont
|
|||||||
|
|
||||||
func newTempContext() *UserConnContext {
|
func newTempContext() *UserConnContext {
|
||||||
return &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),
|
|
||||||
}
|
|
||||||
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 {
|
func (c *UserConnContext) GetRemoteAddr() string {
|
||||||
return c.RemoteAddr
|
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) {
|
func (c *UserConnContext) SetHeader(key, value string) {
|
||||||
c.RespWriter.Header().Set(key, value)
|
c.RespWriter.Header().Set(key, value)
|
||||||
}
|
}
|
||||||
@@ -194,69 +119,93 @@ func (c *UserConnContext) GetConnID() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *UserConnContext) GetUserID() string {
|
func (c *UserConnContext) GetUserID() string {
|
||||||
if c == nil || c.info == nil {
|
return c.Req.URL.Query().Get(WsUserID)
|
||||||
return ""
|
|
||||||
}
|
|
||||||
return c.info.UserID
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *UserConnContext) GetPlatformID() int {
|
func (c *UserConnContext) GetPlatformID() string {
|
||||||
if c == nil || c.info == nil {
|
return c.Req.URL.Query().Get(PlatformID)
|
||||||
return 0
|
|
||||||
}
|
|
||||||
return c.info.PlatformID
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *UserConnContext) GetOperationID() string {
|
func (c *UserConnContext) GetOperationID() string {
|
||||||
if c == nil || c.info == nil {
|
return c.Req.URL.Query().Get(OperationID)
|
||||||
return ""
|
|
||||||
}
|
|
||||||
return c.info.OperationID
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *UserConnContext) SetOperationID(operationID string) {
|
func (c *UserConnContext) SetOperationID(operationID string) {
|
||||||
if c.info == nil {
|
values := c.Req.URL.Query()
|
||||||
c.info = &UserConnContextInfo{}
|
values.Set(OperationID, operationID)
|
||||||
}
|
c.Req.URL.RawQuery = values.Encode()
|
||||||
c.info.OperationID = operationID
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *UserConnContext) GetToken() string {
|
func (c *UserConnContext) GetToken() string {
|
||||||
if c == nil || c.info == nil {
|
return c.Req.URL.Query().Get(Token)
|
||||||
return ""
|
|
||||||
}
|
|
||||||
return c.info.Token
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *UserConnContext) GetCompression() bool {
|
func (c *UserConnContext) GetCompression() bool {
|
||||||
return c != nil && c.info != nil && c.info.Compression == GzipCompressionProtocol
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *UserConnContext) GetSDKType() string {
|
func (c *UserConnContext) GetSDKType() string {
|
||||||
if c == nil || c.info == nil {
|
sdkType := c.Req.URL.Query().Get(SDKType)
|
||||||
return GoSDK
|
if sdkType == "" {
|
||||||
}
|
sdkType = GoSDK
|
||||||
switch c.info.SDKType {
|
|
||||||
case "", GoSDK:
|
|
||||||
return GoSDK
|
|
||||||
case JsSDK:
|
|
||||||
return JsSDK
|
|
||||||
default:
|
|
||||||
return ""
|
|
||||||
}
|
}
|
||||||
|
return sdkType
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *UserConnContext) ShouldSendResp() bool {
|
func (c *UserConnContext) ShouldSendResp() bool {
|
||||||
return c != nil && c.info != nil && c.info.SendResponse
|
errResp, exists := c.Query(SendResponse)
|
||||||
|
if exists {
|
||||||
|
b, err := strconv.ParseBool(errResp)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *UserConnContext) SetToken(token string) {
|
func (c *UserConnContext) SetToken(token string) {
|
||||||
if c.info == nil {
|
c.Req.URL.RawQuery = Token + "=" + token
|
||||||
c.info = &UserConnContextInfo{}
|
|
||||||
}
|
|
||||||
c.info.Token = token
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *UserConnContext) GetBackground() bool {
|
func (c *UserConnContext) GetBackground() bool {
|
||||||
return c != nil && c.info != nil && c.info.Background
|
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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -244,7 +244,6 @@ func (s *Server) MultiTerminalLoginCheck(ctx context.Context, req *msggateway.Mu
|
|||||||
tempUserCtx.SetOperationID(mcontext.GetOperationID(ctx))
|
tempUserCtx.SetOperationID(mcontext.GetOperationID(ctx))
|
||||||
client := &Client{}
|
client := &Client{}
|
||||||
client.ctx = tempUserCtx
|
client.ctx = tempUserCtx
|
||||||
client.token = req.Token
|
|
||||||
client.UserID = req.UserID
|
client.UserID = req.UserID
|
||||||
client.PlatformID = int(req.PlatformID)
|
client.PlatformID = int(req.PlatformID)
|
||||||
i := &kickHandler{
|
i := &kickHandler{
|
||||||
|
|||||||
@@ -0,0 +1,179 @@
|
|||||||
|
// 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
|
||||||
|
}
|
||||||
@@ -2,16 +2,13 @@ package msggateway
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gorilla/websocket"
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
||||||
"github.com/openimsdk/tools/apiresp"
|
|
||||||
|
|
||||||
"github.com/go-playground/validator/v10"
|
"github.com/go-playground/validator/v10"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics"
|
||||||
@@ -29,8 +26,6 @@ import (
|
|||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
)
|
)
|
||||||
|
|
||||||
var wsSuccessResponse, _ = json.Marshal(&apiresp.ApiResponse{})
|
|
||||||
|
|
||||||
type LongConnServer interface {
|
type LongConnServer interface {
|
||||||
Run(done chan error) error
|
Run(done chan error) error
|
||||||
wsHandler(w http.ResponseWriter, r *http.Request)
|
wsHandler(w http.ResponseWriter, r *http.Request)
|
||||||
@@ -47,7 +42,6 @@ type LongConnServer interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type WsServer struct {
|
type WsServer struct {
|
||||||
websocket *websocket.Upgrader
|
|
||||||
msgGatewayConfig *Config
|
msgGatewayConfig *Config
|
||||||
port int
|
port int
|
||||||
wsMaxConnNum int64
|
wsMaxConnNum int64
|
||||||
@@ -137,13 +131,9 @@ func NewWsServer(msgGatewayConfig *Config, opts ...Option) *WsServer {
|
|||||||
o(&config)
|
o(&config)
|
||||||
}
|
}
|
||||||
//userRpcClient := rpcclient.NewUserRpcClient(client, config.Share.RpcRegisterName.User, config.Share.IMAdminUserID)
|
//userRpcClient := rpcclient.NewUserRpcClient(client, config.Share.RpcRegisterName.User, config.Share.IMAdminUserID)
|
||||||
upgrader := &websocket.Upgrader{
|
|
||||||
HandshakeTimeout: config.handshakeTimeout,
|
|
||||||
CheckOrigin: func(r *http.Request) bool { return true },
|
|
||||||
}
|
|
||||||
v := validator.New()
|
v := validator.New()
|
||||||
return &WsServer{
|
return &WsServer{
|
||||||
websocket: upgrader,
|
|
||||||
msgGatewayConfig: msgGatewayConfig,
|
msgGatewayConfig: msgGatewayConfig,
|
||||||
port: config.port,
|
port: config.port,
|
||||||
wsMaxConnNum: config.maxConnNum,
|
wsMaxConnNum: config.maxConnNum,
|
||||||
@@ -347,51 +337,17 @@ func (ws *WsServer) multiTerminalLoginChecker(clientOK bool, oldClients []*Clien
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If reconnect: When multiple msgGateway instances are deployed, a client may disconnect from instance A and reconnect to instance B.
|
|
||||||
// During this process, instance A might still be executing, resulting in two clients with the same token existing simultaneously.
|
|
||||||
// This situation needs to be filtered to prevent duplicate clients.
|
|
||||||
checkSameTokenFunc := func(oldClients []*Client) []*Client {
|
|
||||||
var clientsNeedToKick []*Client
|
|
||||||
|
|
||||||
for _, c := range oldClients {
|
|
||||||
if c.token == newClient.token {
|
|
||||||
log.ZDebug(newClient.ctx, "token is same, not kick",
|
|
||||||
"userID", newClient.UserID,
|
|
||||||
"platformID", newClient.PlatformID,
|
|
||||||
"token", newClient.token)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
clientsNeedToKick = append(clientsNeedToKick, c)
|
|
||||||
}
|
|
||||||
|
|
||||||
return clientsNeedToKick
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ws.msgGatewayConfig.Share.MultiLogin.Policy {
|
switch ws.msgGatewayConfig.Share.MultiLogin.Policy {
|
||||||
case constant.DefalutNotKick:
|
case constant.DefalutNotKick:
|
||||||
case constant.PCAndOther:
|
case constant.PCAndOther:
|
||||||
if constant.PlatformIDToClass(newClient.PlatformID) == constant.TerminalPC {
|
if constant.PlatformIDToClass(newClient.PlatformID) == constant.TerminalPC {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
clients, ok := ws.clients.GetAll(newClient.UserID)
|
|
||||||
clientOK = ok
|
|
||||||
oldClients = make([]*Client, 0, len(clients))
|
|
||||||
for _, c := range clients {
|
|
||||||
if constant.PlatformIDToClass(c.PlatformID) == constant.TerminalPC {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
oldClients = append(oldClients, c)
|
|
||||||
}
|
|
||||||
|
|
||||||
fallthrough
|
fallthrough
|
||||||
case constant.AllLoginButSameTermKick:
|
case constant.AllLoginButSameTermKick:
|
||||||
if !clientOK {
|
if !clientOK {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
oldClients = checkSameTokenFunc(oldClients)
|
|
||||||
|
|
||||||
ws.clients.DeleteClients(newClient.UserID, oldClients)
|
ws.clients.DeleteClients(newClient.UserID, oldClients)
|
||||||
for _, c := range oldClients {
|
for _, c := range oldClients {
|
||||||
err := c.KickOnlineMessage()
|
err := c.KickOnlineMessage()
|
||||||
@@ -417,15 +373,14 @@ func (ws *WsServer) multiTerminalLoginChecker(clientOK bool, oldClients []*Clien
|
|||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
var (
|
||||||
var kickClients []*Client
|
kickClients []*Client
|
||||||
|
)
|
||||||
for _, client := range clients {
|
for _, client := range clients {
|
||||||
if constant.PlatformIDToClass(client.PlatformID) == constant.PlatformIDToClass(newClient.PlatformID) {
|
if constant.PlatformIDToClass(client.PlatformID) == constant.PlatformIDToClass(newClient.PlatformID) {
|
||||||
kickClients = append(kickClients, client)
|
kickClients = append(kickClients, client)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
kickClients = checkSameTokenFunc(kickClients)
|
|
||||||
|
|
||||||
kickTokenFunc(kickClients)
|
kickTokenFunc(kickClients)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -449,39 +404,16 @@ func (ws *WsServer) unregisterClient(client *Client) {
|
|||||||
// validateRespWithRequest checks if the response matches the expected userID and platformID.
|
// validateRespWithRequest checks if the response matches the expected userID and platformID.
|
||||||
func (ws *WsServer) validateRespWithRequest(ctx *UserConnContext, resp *pbAuth.ParseTokenResp) error {
|
func (ws *WsServer) validateRespWithRequest(ctx *UserConnContext, resp *pbAuth.ParseTokenResp) error {
|
||||||
userID := ctx.GetUserID()
|
userID := ctx.GetUserID()
|
||||||
platformID := ctx.GetPlatformID()
|
platformID := stringutil.StringToInt32(ctx.GetPlatformID())
|
||||||
if resp.UserID != userID {
|
if resp.UserID != userID {
|
||||||
return servererrs.ErrTokenInvalid.WrapMsg(fmt.Sprintf("token uid %s != userID %s", resp.UserID, userID))
|
return servererrs.ErrTokenInvalid.WrapMsg(fmt.Sprintf("token uid %s != userID %s", resp.UserID, userID))
|
||||||
}
|
}
|
||||||
if int(resp.PlatformID) != platformID {
|
if resp.PlatformID != platformID {
|
||||||
return servererrs.ErrTokenInvalid.WrapMsg(fmt.Sprintf("token platform %d != platformID %d", resp.PlatformID, platformID))
|
return servererrs.ErrTokenInvalid.WrapMsg(fmt.Sprintf("token platform %d != platformID %d", resp.PlatformID, platformID))
|
||||||
}
|
}
|
||||||
return nil
|
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) {
|
func (ws *WsServer) wsHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
// Create a new connection context
|
// Create a new connection context
|
||||||
connContext := newContext(w, r)
|
connContext := newContext(w, r)
|
||||||
@@ -489,7 +421,7 @@ func (ws *WsServer) wsHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
// Check if the current number of online user connections exceeds the maximum limit
|
// Check if the current number of online user connections exceeds the maximum limit
|
||||||
if ws.onlineUserConnNum.Load() >= ws.wsMaxConnNum {
|
if ws.onlineUserConnNum.Load() >= ws.wsMaxConnNum {
|
||||||
// If it exceeds the maximum connection number, return an error via HTTP and stop processing
|
// If it exceeds the maximum connection number, return an error via HTTP and stop processing
|
||||||
ws.handlerError(connContext, w, r, servererrs.ErrConnOverMaxNumLimit.WrapMsg("over max conn num limit"))
|
httpError(connContext, servererrs.ErrConnOverMaxNumLimit.WrapMsg("over max conn num limit"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,14 +429,26 @@ func (ws *WsServer) wsHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
err := connContext.ParseEssentialArgs()
|
err := connContext.ParseEssentialArgs()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// If there's an error during parsing, return an error via HTTP and stop processing
|
// If there's an error during parsing, return an error via HTTP and stop processing
|
||||||
ws.handlerError(connContext, w, r, err)
|
|
||||||
|
httpError(connContext, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call the authentication client to parse the Token obtained from the context
|
// Call the authentication client to parse the Token obtained from the context
|
||||||
resp, err := ws.authClient.ParseToken(connContext, connContext.GetToken())
|
resp, err := ws.authClient.ParseToken(connContext, connContext.GetToken())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ws.handlerError(connContext, w, r, err)
|
// 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)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -512,30 +456,32 @@ func (ws *WsServer) wsHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
err = ws.validateRespWithRequest(connContext, resp)
|
err = ws.validateRespWithRequest(connContext, resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// If validation fails, return an error via HTTP and stop processing
|
// If validation fails, return an error via HTTP and stop processing
|
||||||
ws.handlerError(connContext, w, r, err)
|
httpError(connContext, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
conn, err := ws.websocket.Upgrade(w, r, nil)
|
|
||||||
if err != nil {
|
|
||||||
log.ZWarn(connContext, "websocket upgrade failed", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if connContext.ShouldSendResp() {
|
|
||||||
if err := conn.WriteMessage(websocket.TextMessage, wsSuccessResponse); err != nil {
|
|
||||||
log.ZWarn(connContext, "WriteMessage first response", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log.ZDebug(connContext, "new conn", "token", connContext.GetToken())
|
|
||||||
|
|
||||||
var pingInterval time.Duration
|
log.ZDebug(connContext, "new conn", "token", connContext.GetToken())
|
||||||
if connContext.GetPlatformID() == constant.WebPlatformID {
|
// Create a WebSocket long connection object
|
||||||
pingInterval = pingPeriod
|
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)
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve a client object from the client pool, reset its state, and associate it with the current WebSocket long connection
|
// 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 := ws.clientPool.Get().(*Client)
|
||||||
client.ResetClient(connContext, NewWebSocketClientConn(conn, maxMessageSize, pongWait, pingInterval), ws)
|
client.ResetClient(connContext, wsLongConn, ws)
|
||||||
|
|
||||||
// Register the client with the server and start message processing
|
// Register the client with the server and start message processing
|
||||||
ws.registerChan <- client
|
ws.registerChan <- client
|
||||||
|
|||||||
@@ -176,16 +176,9 @@ func (m *MsgTransfer) Start(index int, cfg *Config) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
etcdClient, ok := client.(*etcd.SvcDiscoveryRegistryImpl)
|
etcdClient := client.(*etcd.SvcDiscoveryRegistryImpl).GetClient()
|
||||||
if !ok {
|
|
||||||
return errs.New("only etcd support autoSetPorts").Wrap()
|
|
||||||
}
|
|
||||||
|
|
||||||
target, err := jsonutil.JsonMarshal(prommetrics.BuildDefaultTarget(registerIP, prometheusPort))
|
_, err = etcdClient.Put(context.TODO(), prommetrics.BuildDiscoveryKey(prommetrics.MessageTransferKeyName), jsonutil.StructToJsonString(prommetrics.BuildDefaultTarget(registerIP, prometheusPort)))
|
||||||
if err != nil {
|
|
||||||
return errs.Wrap(err)
|
|
||||||
}
|
|
||||||
err = etcdClient.SetWithLease(context.TODO(), prommetrics.BuildDiscoveryKey(prommetrics.MessageTransferKeyName, index), target, prommetrics.TTL)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errs.WrapMsg(err, "etcd put err")
|
return errs.WrapMsg(err, "etcd put err")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,20 +18,17 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
||||||
|
"github.com/openimsdk/tools/discovery"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
|
||||||
"github.com/openimsdk/tools/discovery"
|
|
||||||
|
|
||||||
"github.com/go-redis/redis"
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics"
|
||||||
|
|
||||||
"github.com/IBM/sarama"
|
"github.com/IBM/sarama"
|
||||||
|
"github.com/go-redis/redis"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/controller"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/controller"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/kafka"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/kafka"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/msgprocessor"
|
"github.com/openimsdk/open-im-server/v3/pkg/msgprocessor"
|
||||||
@@ -43,6 +40,7 @@ import (
|
|||||||
"github.com/openimsdk/tools/log"
|
"github.com/openimsdk/tools/log"
|
||||||
"github.com/openimsdk/tools/mcontext"
|
"github.com/openimsdk/tools/mcontext"
|
||||||
"github.com/openimsdk/tools/utils/stringutil"
|
"github.com/openimsdk/tools/utils/stringutil"
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -141,48 +139,53 @@ func (och *OnlineHistoryRedisConsumerHandler) do(ctx context.Context, channelID
|
|||||||
|
|
||||||
func (och *OnlineHistoryRedisConsumerHandler) doSetReadSeq(ctx context.Context, msgs []*ContextMsg) {
|
func (och *OnlineHistoryRedisConsumerHandler) doSetReadSeq(ctx context.Context, msgs []*ContextMsg) {
|
||||||
|
|
||||||
// Outer map: conversationID -> (userID -> maxHasReadSeq)
|
var conversationID string
|
||||||
conversationUserSeq := make(map[string]map[string]int64)
|
var userSeqMap map[string]int64
|
||||||
|
|
||||||
for _, msg := range msgs {
|
for _, msg := range msgs {
|
||||||
if msg.message.ContentType != constant.HasReadReceipt {
|
if msg.message.ContentType != constant.HasReadReceipt {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
var elem sdkws.NotificationElem
|
var elem sdkws.NotificationElem
|
||||||
if err := json.Unmarshal(msg.message.Content, &elem); err != nil {
|
if err := json.Unmarshal(msg.message.Content, &elem); err != nil {
|
||||||
log.ZWarn(ctx, "Unmarshal NotificationElem error", err, "msg", msg)
|
log.ZWarn(ctx, "handlerConversationRead Unmarshal NotificationElem msg err", err, "msg", msg)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
var tips sdkws.MarkAsReadTips
|
var tips sdkws.MarkAsReadTips
|
||||||
if err := json.Unmarshal([]byte(elem.Detail), &tips); err != nil {
|
if err := json.Unmarshal([]byte(elem.Detail), &tips); err != nil {
|
||||||
log.ZWarn(ctx, "Unmarshal MarkAsReadTips error", err, "msg", msg)
|
log.ZWarn(ctx, "handlerConversationRead Unmarshal MarkAsReadTips msg err", err, "msg", msg)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if len(tips.ConversationID) == 0 || tips.HasReadSeq < 0 {
|
//The conversation ID for each batch of messages processed by the batcher is the same.
|
||||||
continue
|
conversationID = tips.ConversationID
|
||||||
}
|
if len(tips.Seqs) > 0 {
|
||||||
|
for _, seq := range tips.Seqs {
|
||||||
// Calculate the max seq from tips.Seqs
|
if tips.HasReadSeq < seq {
|
||||||
for _, seq := range tips.Seqs {
|
tips.HasReadSeq = seq
|
||||||
if tips.HasReadSeq < seq {
|
}
|
||||||
tips.HasReadSeq = seq
|
|
||||||
}
|
}
|
||||||
|
clear(tips.Seqs)
|
||||||
|
tips.Seqs = nil
|
||||||
|
}
|
||||||
|
if tips.HasReadSeq < 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if userSeqMap == nil {
|
||||||
|
userSeqMap = make(map[string]int64)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := conversationUserSeq[tips.ConversationID]; !ok {
|
if userSeqMap[tips.MarkAsReadUserID] > tips.HasReadSeq {
|
||||||
conversationUserSeq[tips.ConversationID] = make(map[string]int64)
|
continue
|
||||||
}
|
|
||||||
if conversationUserSeq[tips.ConversationID][tips.MarkAsReadUserID] < tips.HasReadSeq {
|
|
||||||
conversationUserSeq[tips.ConversationID][tips.MarkAsReadUserID] = tips.HasReadSeq
|
|
||||||
}
|
}
|
||||||
|
userSeqMap[tips.MarkAsReadUserID] = tips.HasReadSeq
|
||||||
}
|
}
|
||||||
log.ZInfo(ctx, "doSetReadSeq", "conversationUserSeq", conversationUserSeq)
|
if userSeqMap == nil {
|
||||||
|
return
|
||||||
// persist to db
|
}
|
||||||
for convID, userSeqMap := range conversationUserSeq {
|
if len(conversationID) == 0 {
|
||||||
if err := och.msgTransferDatabase.SetHasReadSeqToDB(ctx, convID, userSeqMap); err != nil {
|
log.ZWarn(ctx, "conversation err", nil, "conversationID", conversationID)
|
||||||
log.ZWarn(ctx, "SetHasReadSeqToDB error", err, "conversationID", convID, "userSeqMap", userSeqMap)
|
}
|
||||||
}
|
if err := och.msgTransferDatabase.SetHasReadSeqToDB(ctx, conversationID, userSeqMap); err != nil {
|
||||||
|
log.ZWarn(ctx, "set read seq to db error", err, "conversationID", conversationID, "userSeqMap", userSeqMap)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -286,7 +289,6 @@ func (och *OnlineHistoryRedisConsumerHandler) handleMsg(ctx context.Context, key
|
|||||||
}
|
}
|
||||||
|
|
||||||
if isNewConversation {
|
if isNewConversation {
|
||||||
ctx := storageList[0].ctx
|
|
||||||
switch msg.SessionType {
|
switch msg.SessionType {
|
||||||
case constant.ReadGroupChatType:
|
case constant.ReadGroupChatType:
|
||||||
log.ZDebug(ctx, "group chat first create conversation", "conversationID",
|
log.ZDebug(ctx, "group chat first create conversation", "conversationID",
|
||||||
|
|||||||
@@ -73,14 +73,10 @@ func (mc *OnlineHistoryMongoConsumerHandler) handleChatWs2Mongo(ctx context.Cont
|
|||||||
} else {
|
} else {
|
||||||
prommetrics.MsgInsertMongoSuccessCounter.Inc()
|
prommetrics.MsgInsertMongoSuccessCounter.Inc()
|
||||||
}
|
}
|
||||||
//var seqs []int64
|
var seqs []int64
|
||||||
//for _, msg := range msgFromMQ.MsgData {
|
for _, msg := range msgFromMQ.MsgData {
|
||||||
// seqs = append(seqs, msg.Seq)
|
seqs = append(seqs, msg.Seq)
|
||||||
//}
|
}
|
||||||
//if err := mc.msgTransferDatabase.DeleteMessagesFromCache(ctx, msgFromMQ.ConversationID, seqs); err != nil {
|
|
||||||
// log.ZError(ctx, "remove cache msg from redis err", err, "msg",
|
|
||||||
// msgFromMQ.MsgData, "conversationID", msgFromMQ.ConversationID)
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*OnlineHistoryMongoConsumerHandler) Setup(_ sarama.ConsumerGroupSession) error { return nil }
|
func (*OnlineHistoryMongoConsumerHandler) Setup(_ sarama.ConsumerGroupSession) error { return nil }
|
||||||
|
|||||||
@@ -142,7 +142,6 @@ func (c *ConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupSession, claim s
|
|||||||
|
|
||||||
for msg := range claim.Messages() {
|
for msg := range claim.Messages() {
|
||||||
ctx := c.pushConsumerGroup.GetContextFromMsg(msg)
|
ctx := c.pushConsumerGroup.GetContextFromMsg(msg)
|
||||||
ctx = mcontext.WithOpUserIDContext(ctx, c.config.Share.IMAdminUserID[0])
|
|
||||||
c.handleMs2PsChat(ctx, msg.Value)
|
c.handleMs2PsChat(ctx, msg.Value)
|
||||||
sess.MarkMessage(msg, "")
|
sess.MarkMessage(msg, "")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,18 +168,7 @@ func (c *conversationServer) GetSortedConversationList(ctx context.Context, req
|
|||||||
conversation_notPinTime := make(map[int64]string)
|
conversation_notPinTime := make(map[int64]string)
|
||||||
for _, v := range conversations {
|
for _, v := range conversations {
|
||||||
conversationID := v.ConversationID
|
conversationID := v.ConversationID
|
||||||
var time int64
|
time := conversationMsg[conversationID].MsgInfo.LatestMsgRecvTime
|
||||||
if _, ok := conversationMsg[conversationID]; ok {
|
|
||||||
time = conversationMsg[conversationID].MsgInfo.LatestMsgRecvTime
|
|
||||||
} else {
|
|
||||||
conversationMsg[conversationID] = &pbconversation.ConversationElem{
|
|
||||||
ConversationID: conversationID,
|
|
||||||
IsPinned: v.IsPinned,
|
|
||||||
MsgInfo: nil,
|
|
||||||
}
|
|
||||||
time = v.CreateTime.UnixMilli()
|
|
||||||
}
|
|
||||||
|
|
||||||
conversationMsg[conversationID].RecvMsgOpt = v.RecvMsgOpt
|
conversationMsg[conversationID].RecvMsgOpt = v.RecvMsgOpt
|
||||||
if v.IsPinned {
|
if v.IsPinned {
|
||||||
conversationMsg[conversationID].IsPinned = v.IsPinned
|
conversationMsg[conversationID].IsPinned = v.IsPinned
|
||||||
@@ -231,7 +220,6 @@ func (c *conversationServer) getConversations(ctx context.Context, ownerUserID s
|
|||||||
return convert.ConversationsDB2Pb(conversations), nil
|
return convert.ConversationsDB2Pb(conversations), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated
|
|
||||||
func (c *conversationServer) SetConversation(ctx context.Context, req *pbconversation.SetConversationReq) (*pbconversation.SetConversationResp, error) {
|
func (c *conversationServer) SetConversation(ctx context.Context, req *pbconversation.SetConversationReq) (*pbconversation.SetConversationResp, error) {
|
||||||
var conversation dbModel.Conversation
|
var conversation dbModel.Conversation
|
||||||
if err := datautil.CopyStructFields(&conversation, req.Conversation); err != nil {
|
if err := datautil.CopyStructFields(&conversation, req.Conversation); err != nil {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ func (c *conversationServer) GetFullOwnerConversationIDs(ctx context.Context, re
|
|||||||
conversationIDs = nil
|
conversationIDs = nil
|
||||||
}
|
}
|
||||||
return &conversation.GetFullOwnerConversationIDsResp{
|
return &conversation.GetFullOwnerConversationIDsResp{
|
||||||
Version: uint64(vl.Version),
|
Version: idHash,
|
||||||
VersionID: vl.ID.Hex(),
|
VersionID: vl.ID.Hex(),
|
||||||
Equal: req.IdHash == idHash,
|
Equal: req.IdHash == idHash,
|
||||||
ConversationIDs: conversationIDs,
|
ConversationIDs: conversationIDs,
|
||||||
|
|||||||
@@ -33,9 +33,6 @@ func (s *groupServer) GetGroupInfoCache(ctx context.Context, req *pbgroup.GetGro
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetGroupMemberCache(ctx context.Context, req *pbgroup.GetGroupMemberCacheReq) (*pbgroup.GetGroupMemberCacheResp, error) {
|
func (s *groupServer) GetGroupMemberCache(ctx context.Context, req *pbgroup.GetGroupMemberCacheReq) (*pbgroup.GetGroupMemberCacheResp, error) {
|
||||||
if err := s.checkAdminOrInGroup(ctx, req.GroupID); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
members, err := s.db.TakeGroupMember(ctx, req.GroupID, req.GroupMemberID)
|
members, err := s.db.TakeGroupMember(ctx, req.GroupID, req.GroupMemberID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
+282
-367
File diff suppressed because it is too large
Load Diff
@@ -20,7 +20,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
|
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
|
||||||
@@ -284,8 +283,7 @@ func (g *NotificationSender) fillUserByUserID(ctx context.Context, userID string
|
|||||||
|
|
||||||
func (g *NotificationSender) setVersion(ctx context.Context, version *uint64, versionID *string, collName string, id string) {
|
func (g *NotificationSender) setVersion(ctx context.Context, version *uint64, versionID *string, collName string, id string) {
|
||||||
versions := versionctx.GetVersionLog(ctx).Get()
|
versions := versionctx.GetVersionLog(ctx).Get()
|
||||||
for i := len(versions) - 1; i >= 0; i-- {
|
for _, coll := range versions {
|
||||||
coll := versions[i]
|
|
||||||
if coll.Name == collName && coll.Doc.DID == id {
|
if coll.Name == collName && coll.Doc.DID == id {
|
||||||
*version = uint64(coll.Doc.Version)
|
*version = uint64(coll.Doc.Version)
|
||||||
*versionID = coll.Doc.ID.Hex()
|
*versionID = coll.Doc.ID.Hex()
|
||||||
@@ -365,46 +363,13 @@ func (g *NotificationSender) GroupInfoSetAnnouncementNotification(ctx context.Co
|
|||||||
g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetAnnouncementNotification, tips, notification.WithRpcGetUserName(), notification.WithSendMessage(sendMessage))
|
g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetAnnouncementNotification, tips, notification.WithRpcGetUserName(), notification.WithSendMessage(sendMessage))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *NotificationSender) uuid() string {
|
func (g *NotificationSender) JoinGroupApplicationNotification(ctx context.Context, req *pbgroup.JoinGroupReq) {
|
||||||
return uuid.New().String()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *NotificationSender) getGroupRequest(ctx context.Context, groupID string, userID string) (*sdkws.GroupRequest, error) {
|
|
||||||
request, err := g.db.TakeGroupRequest(ctx, groupID, userID)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
users, err := g.getUsersInfo(ctx, []string{userID})
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if len(users) == 0 {
|
|
||||||
return nil, servererrs.ErrUserIDNotFound.WrapMsg(fmt.Sprintf("user %s not found", userID))
|
|
||||||
}
|
|
||||||
info, ok := users[0].(*sdkws.UserInfo)
|
|
||||||
if !ok {
|
|
||||||
info = &sdkws.UserInfo{
|
|
||||||
UserID: users[0].GetUserID(),
|
|
||||||
Nickname: users[0].GetNickname(),
|
|
||||||
FaceURL: users[0].GetFaceURL(),
|
|
||||||
Ex: users[0].GetEx(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return convert.Db2PbGroupRequest(request, info, nil), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *NotificationSender) JoinGroupApplicationNotification(ctx context.Context, req *pbgroup.JoinGroupReq, dbReq *model.GroupRequest) {
|
|
||||||
var err error
|
var err error
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(ctx, stringutil.GetFuncName(1)+" failed", err)
|
log.ZError(ctx, stringutil.GetFuncName(1)+" failed", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
request, err := g.getGroupRequest(ctx, dbReq.GroupID, dbReq.UserID)
|
|
||||||
if err != nil {
|
|
||||||
log.ZError(ctx, "JoinGroupApplicationNotification getGroupRequest", err, "dbReq", dbReq)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
var group *sdkws.GroupInfo
|
var group *sdkws.GroupInfo
|
||||||
group, err = g.getGroupInfo(ctx, req.GroupID)
|
group, err = g.getGroupInfo(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -420,13 +385,7 @@ func (g *NotificationSender) JoinGroupApplicationNotification(ctx context.Contex
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
userIDs = append(userIDs, req.InviterUserID, mcontext.GetOpUserID(ctx))
|
userIDs = append(userIDs, req.InviterUserID, mcontext.GetOpUserID(ctx))
|
||||||
tips := &sdkws.JoinGroupApplicationTips{
|
tips := &sdkws.JoinGroupApplicationTips{Group: group, Applicant: user, ReqMsg: req.ReqMessage}
|
||||||
Group: group,
|
|
||||||
Applicant: user,
|
|
||||||
ReqMsg: req.ReqMessage,
|
|
||||||
Uuid: g.uuid(),
|
|
||||||
Request: request,
|
|
||||||
}
|
|
||||||
for _, userID := range datautil.Distinct(userIDs) {
|
for _, userID := range datautil.Distinct(userIDs) {
|
||||||
g.Notification(ctx, mcontext.GetOpUserID(ctx), userID, constant.JoinGroupApplicationNotification, tips)
|
g.Notification(ctx, mcontext.GetOpUserID(ctx), userID, constant.JoinGroupApplicationNotification, tips)
|
||||||
}
|
}
|
||||||
@@ -456,11 +415,6 @@ func (g *NotificationSender) GroupApplicationAcceptedNotification(ctx context.Co
|
|||||||
log.ZError(ctx, stringutil.GetFuncName(1)+" failed", err)
|
log.ZError(ctx, stringutil.GetFuncName(1)+" failed", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
request, err := g.getGroupRequest(ctx, req.GroupID, req.FromUserID)
|
|
||||||
if err != nil {
|
|
||||||
log.ZError(ctx, "GroupApplicationAcceptedNotification getGroupRequest", err, "req", req)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
var group *sdkws.GroupInfo
|
var group *sdkws.GroupInfo
|
||||||
group, err = g.getGroupInfo(ctx, req.GroupID)
|
group, err = g.getGroupInfo(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -476,15 +430,8 @@ func (g *NotificationSender) GroupApplicationAcceptedNotification(ctx context.Co
|
|||||||
if err = g.fillOpUser(ctx, &opUser, group.GroupID); err != nil {
|
if err = g.fillOpUser(ctx, &opUser, group.GroupID); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
uid := g.uuid()
|
|
||||||
for _, userID := range append(userIDs, req.FromUserID) {
|
for _, userID := range append(userIDs, req.FromUserID) {
|
||||||
tips := &sdkws.GroupApplicationAcceptedTips{
|
tips := &sdkws.GroupApplicationAcceptedTips{Group: group, OpUser: opUser, HandleMsg: req.HandledMsg}
|
||||||
Group: group,
|
|
||||||
OpUser: opUser,
|
|
||||||
HandleMsg: req.HandledMsg,
|
|
||||||
Uuid: uid,
|
|
||||||
Request: request,
|
|
||||||
}
|
|
||||||
if userID == req.FromUserID {
|
if userID == req.FromUserID {
|
||||||
tips.ReceiverAs = applicantReceiver
|
tips.ReceiverAs = applicantReceiver
|
||||||
} else {
|
} else {
|
||||||
@@ -501,11 +448,6 @@ func (g *NotificationSender) GroupApplicationRejectedNotification(ctx context.Co
|
|||||||
log.ZError(ctx, stringutil.GetFuncName(1)+" failed", err)
|
log.ZError(ctx, stringutil.GetFuncName(1)+" failed", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
request, err := g.getGroupRequest(ctx, req.GroupID, req.FromUserID)
|
|
||||||
if err != nil {
|
|
||||||
log.ZError(ctx, "GroupApplicationAcceptedNotification getGroupRequest", err, "req", req)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
var group *sdkws.GroupInfo
|
var group *sdkws.GroupInfo
|
||||||
group, err = g.getGroupInfo(ctx, req.GroupID)
|
group, err = g.getGroupInfo(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -521,15 +463,8 @@ func (g *NotificationSender) GroupApplicationRejectedNotification(ctx context.Co
|
|||||||
if err = g.fillOpUser(ctx, &opUser, group.GroupID); err != nil {
|
if err = g.fillOpUser(ctx, &opUser, group.GroupID); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
uid := g.uuid()
|
|
||||||
for _, userID := range append(userIDs, req.FromUserID) {
|
for _, userID := range append(userIDs, req.FromUserID) {
|
||||||
tips := &sdkws.GroupApplicationRejectedTips{
|
tips := &sdkws.GroupApplicationAcceptedTips{Group: group, OpUser: opUser, HandleMsg: req.HandledMsg}
|
||||||
Group: group,
|
|
||||||
OpUser: opUser,
|
|
||||||
HandleMsg: req.HandledMsg,
|
|
||||||
Uuid: uid,
|
|
||||||
Request: request,
|
|
||||||
}
|
|
||||||
if userID == req.FromUserID {
|
if userID == req.FromUserID {
|
||||||
tips.ReceiverAs = applicantReceiver
|
tips.ReceiverAs = applicantReceiver
|
||||||
} else {
|
} else {
|
||||||
@@ -585,10 +520,6 @@ func (g *NotificationSender) MemberKickedNotification(ctx context.Context, tips
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *NotificationSender) GroupApplicationAgreeMemberEnterNotification(ctx context.Context, groupID string, SendMessage *bool, invitedOpUserID string, entrantUserID ...string) error {
|
func (g *NotificationSender) GroupApplicationAgreeMemberEnterNotification(ctx context.Context, groupID string, SendMessage *bool, invitedOpUserID string, entrantUserID ...string) error {
|
||||||
return g.groupApplicationAgreeMemberEnterNotification(ctx, groupID, SendMessage, invitedOpUserID, entrantUserID...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *NotificationSender) groupApplicationAgreeMemberEnterNotification(ctx context.Context, groupID string, SendMessage *bool, invitedOpUserID string, entrantUserID ...string) error {
|
|
||||||
var err error
|
var err error
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
|
|
||||||
"github.com/openimsdk/protocol/group"
|
"github.com/openimsdk/protocol/group"
|
||||||
"github.com/openimsdk/tools/errs"
|
"github.com/openimsdk/tools/errs"
|
||||||
)
|
)
|
||||||
@@ -27,9 +26,6 @@ func (s *groupServer) GroupCreateCount(ctx context.Context, req *group.GroupCrea
|
|||||||
if req.Start > req.End {
|
if req.Start > req.End {
|
||||||
return nil, errs.ErrArgs.WrapMsg("start > end: %d > %d", req.Start, req.End)
|
return nil, errs.ErrArgs.WrapMsg("start > end: %d > %d", req.Start, req.End)
|
||||||
}
|
}
|
||||||
if err := authverify.CheckAdmin(ctx, s.config.Share.IMAdminUserID); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
total, err := s.db.CountTotal(ctx, nil)
|
total, err := s.db.CountTotal(ctx, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
+12
-35
@@ -2,7 +2,6 @@ package group
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/internal/rpc/incrversion"
|
"github.com/openimsdk/open-im-server/v3/internal/rpc/incrversion"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
|
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
|
||||||
@@ -12,25 +11,16 @@ import (
|
|||||||
"github.com/openimsdk/protocol/constant"
|
"github.com/openimsdk/protocol/constant"
|
||||||
pbgroup "github.com/openimsdk/protocol/group"
|
pbgroup "github.com/openimsdk/protocol/group"
|
||||||
"github.com/openimsdk/protocol/sdkws"
|
"github.com/openimsdk/protocol/sdkws"
|
||||||
"github.com/openimsdk/tools/errs"
|
|
||||||
"github.com/openimsdk/tools/log"
|
|
||||||
"github.com/openimsdk/tools/mcontext"
|
|
||||||
"github.com/openimsdk/tools/utils/datautil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const versionSyncLimit = 500
|
const versionSyncLimit = 500
|
||||||
|
|
||||||
func (s *groupServer) GetFullGroupMemberUserIDs(ctx context.Context, req *pbgroup.GetFullGroupMemberUserIDsReq) (*pbgroup.GetFullGroupMemberUserIDsResp, error) {
|
func (g *groupServer) GetFullGroupMemberUserIDs(ctx context.Context, req *pbgroup.GetFullGroupMemberUserIDsReq) (*pbgroup.GetFullGroupMemberUserIDsResp, error) {
|
||||||
userIDs, err := s.db.FindGroupMemberUserID(ctx, req.GroupID)
|
vl, err := g.db.FindMaxGroupMemberVersionCache(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if !authverify.IsAppManagerUid(ctx, s.config.Share.IMAdminUserID) {
|
userIDs, err := g.db.FindGroupMemberUserID(ctx, req.GroupID)
|
||||||
if !datautil.Contain(mcontext.GetOpUserID(ctx), userIDs...) {
|
|
||||||
return nil, errs.ErrNoPermission.WrapMsg("op user not in group")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
vl, err := s.db.FindMaxGroupMemberVersionCache(ctx, req.GroupID)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -39,7 +29,7 @@ func (s *groupServer) GetFullGroupMemberUserIDs(ctx context.Context, req *pbgrou
|
|||||||
userIDs = nil
|
userIDs = nil
|
||||||
}
|
}
|
||||||
return &pbgroup.GetFullGroupMemberUserIDsResp{
|
return &pbgroup.GetFullGroupMemberUserIDsResp{
|
||||||
Version: uint64(vl.Version),
|
Version: idHash,
|
||||||
VersionID: vl.ID.Hex(),
|
VersionID: vl.ID.Hex(),
|
||||||
Equal: req.IdHash == idHash,
|
Equal: req.IdHash == idHash,
|
||||||
UserIDs: userIDs,
|
UserIDs: userIDs,
|
||||||
@@ -47,9 +37,6 @@ func (s *groupServer) GetFullGroupMemberUserIDs(ctx context.Context, req *pbgrou
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetFullJoinGroupIDs(ctx context.Context, req *pbgroup.GetFullJoinGroupIDsReq) (*pbgroup.GetFullJoinGroupIDsResp, error) {
|
func (s *groupServer) GetFullJoinGroupIDs(ctx context.Context, req *pbgroup.GetFullJoinGroupIDsReq) (*pbgroup.GetFullJoinGroupIDsResp, error) {
|
||||||
if err := authverify.CheckAccessV3(ctx, req.UserID, s.config.Share.IMAdminUserID); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
vl, err := s.db.FindMaxJoinGroupVersionCache(ctx, req.UserID)
|
vl, err := s.db.FindMaxJoinGroupVersionCache(ctx, req.UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -63,7 +50,7 @@ func (s *groupServer) GetFullJoinGroupIDs(ctx context.Context, req *pbgroup.GetF
|
|||||||
groupIDs = nil
|
groupIDs = nil
|
||||||
}
|
}
|
||||||
return &pbgroup.GetFullJoinGroupIDsResp{
|
return &pbgroup.GetFullJoinGroupIDsResp{
|
||||||
Version: uint64(vl.Version),
|
Version: idHash,
|
||||||
VersionID: vl.ID.Hex(),
|
VersionID: vl.ID.Hex(),
|
||||||
Equal: req.IdHash == idHash,
|
Equal: req.IdHash == idHash,
|
||||||
GroupIDs: groupIDs,
|
GroupIDs: groupIDs,
|
||||||
@@ -71,9 +58,6 @@ func (s *groupServer) GetFullJoinGroupIDs(ctx context.Context, req *pbgroup.GetF
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetIncrementalGroupMember(ctx context.Context, req *pbgroup.GetIncrementalGroupMemberReq) (*pbgroup.GetIncrementalGroupMemberResp, error) {
|
func (s *groupServer) GetIncrementalGroupMember(ctx context.Context, req *pbgroup.GetIncrementalGroupMemberReq) (*pbgroup.GetIncrementalGroupMemberResp, error) {
|
||||||
if err := s.checkAdminOrInGroup(ctx, req.GroupID); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
group, err := s.db.TakeGroup(ctx, req.GroupID)
|
group, err := s.db.TakeGroup(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -148,8 +132,8 @@ func (s *groupServer) GetIncrementalGroupMember(ctx context.Context, req *pbgrou
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetIncrementalJoinGroup(ctx context.Context, req *pbgroup.GetIncrementalJoinGroupReq) (*pbgroup.GetIncrementalJoinGroupResp, error) {
|
func (g *groupServer) GetIncrementalJoinGroup(ctx context.Context, req *pbgroup.GetIncrementalJoinGroupReq) (*pbgroup.GetIncrementalJoinGroupResp, error) {
|
||||||
if err := authverify.CheckAccessV3(ctx, req.UserID, s.config.Share.IMAdminUserID); err != nil {
|
if err := authverify.CheckAccessV3(ctx, req.UserID, g.config.Share.IMAdminUserID); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
opt := incrversion.Option[*sdkws.GroupInfo, pbgroup.GetIncrementalJoinGroupResp]{
|
opt := incrversion.Option[*sdkws.GroupInfo, pbgroup.GetIncrementalJoinGroupResp]{
|
||||||
@@ -157,9 +141,9 @@ func (s *groupServer) GetIncrementalJoinGroup(ctx context.Context, req *pbgroup.
|
|||||||
VersionKey: req.UserID,
|
VersionKey: req.UserID,
|
||||||
VersionID: req.VersionID,
|
VersionID: req.VersionID,
|
||||||
VersionNumber: req.Version,
|
VersionNumber: req.Version,
|
||||||
Version: s.db.FindJoinIncrVersion,
|
Version: g.db.FindJoinIncrVersion,
|
||||||
CacheMaxVersion: s.db.FindMaxJoinGroupVersionCache,
|
CacheMaxVersion: g.db.FindMaxJoinGroupVersionCache,
|
||||||
Find: s.getGroupsInfo,
|
Find: g.getGroupsInfo,
|
||||||
Resp: func(version *model.VersionLog, delIDs []string, insertList, updateList []*sdkws.GroupInfo, full bool) *pbgroup.GetIncrementalJoinGroupResp {
|
Resp: func(version *model.VersionLog, delIDs []string, insertList, updateList []*sdkws.GroupInfo, full bool) *pbgroup.GetIncrementalJoinGroupResp {
|
||||||
return &pbgroup.GetIncrementalJoinGroupResp{
|
return &pbgroup.GetIncrementalJoinGroupResp{
|
||||||
VersionID: version.ID.Hex(),
|
VersionID: version.ID.Hex(),
|
||||||
@@ -174,29 +158,22 @@ func (s *groupServer) GetIncrementalJoinGroup(ctx context.Context, req *pbgroup.
|
|||||||
return opt.Build()
|
return opt.Build()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) BatchGetIncrementalGroupMember(ctx context.Context, req *pbgroup.BatchGetIncrementalGroupMemberReq) (*pbgroup.BatchGetIncrementalGroupMemberResp, error) {
|
func (g *groupServer) BatchGetIncrementalGroupMember(ctx context.Context, req *pbgroup.BatchGetIncrementalGroupMemberReq) (*pbgroup.BatchGetIncrementalGroupMemberResp, error) {
|
||||||
var num int
|
var num int
|
||||||
resp := make(map[string]*pbgroup.GetIncrementalGroupMemberResp)
|
resp := make(map[string]*pbgroup.GetIncrementalGroupMemberResp)
|
||||||
|
|
||||||
for _, memberReq := range req.ReqList {
|
for _, memberReq := range req.ReqList {
|
||||||
if _, ok := resp[memberReq.GroupID]; ok {
|
if _, ok := resp[memberReq.GroupID]; ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
memberResp, err := s.GetIncrementalGroupMember(ctx, memberReq)
|
memberResp, err := g.GetIncrementalGroupMember(ctx, memberReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, servererrs.ErrDismissedAlready) {
|
|
||||||
log.ZWarn(ctx, "Failed to get incremental group member", err, "groupID", memberReq.GroupID, "request", memberReq)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp[memberReq.GroupID] = memberResp
|
resp[memberReq.GroupID] = memberResp
|
||||||
num += len(memberResp.Insert) + len(memberResp.Update) + len(memberResp.Delete)
|
num += len(memberResp.Insert) + len(memberResp.Update) + len(memberResp.Delete)
|
||||||
if num >= versionSyncLimit {
|
if num >= versionSyncLimit {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pbgroup.BatchGetIncrementalGroupMemberResp{RespList: resp}, nil
|
return &pbgroup.BatchGetIncrementalGroupMemberResp{RespList: resp}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,3 +48,7 @@ func (m *MsgNotificationSender) MarkAsReadNotification(ctx context.Context, conv
|
|||||||
}
|
}
|
||||||
m.NotificationWithSessionType(ctx, sendID, recvID, constant.HasReadReceipt, sessionType, tips)
|
m.NotificationWithSessionType(ctx, sendID, recvID, constant.HasReadReceipt, sessionType, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *MsgNotificationSender) StreamMsgNotification(ctx context.Context, sendID string, recvID string, sessionType int32, tips *sdkws.StreamMsgTips) {
|
||||||
|
m.NotificationWithSessionType(ctx, sendID, recvID, constant.StreamMsgNotification, sessionType, tips)
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ package relation
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/notification/common_user"
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
||||||
|
|
||||||
"github.com/openimsdk/tools/mq/memamq"
|
"github.com/openimsdk/tools/mq/memamq"
|
||||||
@@ -103,24 +101,22 @@ func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryReg
|
|||||||
}
|
}
|
||||||
userClient := rpcli.NewUserClient(userConn)
|
userClient := rpcli.NewUserClient(userConn)
|
||||||
|
|
||||||
database := controller.NewFriendDatabase(
|
|
||||||
friendMongoDB,
|
|
||||||
friendRequestMongoDB,
|
|
||||||
redis.NewFriendCacheRedis(rdb, &config.LocalCacheConfig, friendMongoDB, redis.GetRocksCacheOptions()),
|
|
||||||
mgocli.GetTx(),
|
|
||||||
)
|
|
||||||
// Initialize notification sender
|
// Initialize notification sender
|
||||||
notificationSender := NewFriendNotificationSender(
|
notificationSender := NewFriendNotificationSender(
|
||||||
&config.NotificationConfig,
|
&config.NotificationConfig,
|
||||||
rpcli.NewMsgClient(msgConn),
|
rpcli.NewMsgClient(msgConn),
|
||||||
WithRpcFunc(userClient.GetUsersInfo),
|
WithRpcFunc(userClient.GetUsersInfo),
|
||||||
WithFriendDB(database),
|
|
||||||
)
|
)
|
||||||
localcache.InitLocalCache(&config.LocalCacheConfig)
|
localcache.InitLocalCache(&config.LocalCacheConfig)
|
||||||
|
|
||||||
// Register Friend server with refactored MongoDB and Redis integrations
|
// Register Friend server with refactored MongoDB and Redis integrations
|
||||||
relation.RegisterFriendServer(server, &friendServer{
|
relation.RegisterFriendServer(server, &friendServer{
|
||||||
db: database,
|
db: controller.NewFriendDatabase(
|
||||||
|
friendMongoDB,
|
||||||
|
friendRequestMongoDB,
|
||||||
|
redis.NewFriendCacheRedis(rdb, &config.LocalCacheConfig, friendMongoDB, redis.GetRocksCacheOptions()),
|
||||||
|
mgocli.GetTx(),
|
||||||
|
),
|
||||||
blackDatabase: controller.NewBlackDatabase(
|
blackDatabase: controller.NewBlackDatabase(
|
||||||
blackMongoDB,
|
blackMongoDB,
|
||||||
redis.NewBlackCacheRedis(rdb, &config.LocalCacheConfig, blackMongoDB, redis.GetRocksCacheOptions()),
|
redis.NewBlackCacheRedis(rdb, &config.LocalCacheConfig, blackMongoDB, redis.GetRocksCacheOptions()),
|
||||||
@@ -194,7 +190,7 @@ func (s *friendServer) ImportFriends(ctx context.Context, req *relation.ImportFr
|
|||||||
FromUserID: req.OwnerUserID,
|
FromUserID: req.OwnerUserID,
|
||||||
ToUserID: userID,
|
ToUserID: userID,
|
||||||
HandleResult: constant.FriendResponseAgree,
|
HandleResult: constant.FriendResponseAgree,
|
||||||
}, false)
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
s.webhookAfterImportFriends(ctx, &s.config.WebhooksConfig.AfterImportFriends, req)
|
s.webhookAfterImportFriends(ctx, &s.config.WebhooksConfig.AfterImportFriends, req)
|
||||||
@@ -223,7 +219,7 @@ func (s *friendServer) RespondFriendApply(ctx context.Context, req *relation.Res
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
s.webhookAfterAddFriendAgree(ctx, &s.config.WebhooksConfig.AfterAddFriendAgree, req)
|
s.webhookAfterAddFriendAgree(ctx, &s.config.WebhooksConfig.AfterAddFriendAgree, req)
|
||||||
s.notificationSender.FriendApplicationAgreedNotification(ctx, req, true)
|
s.notificationSender.FriendApplicationAgreedNotification(ctx, req)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
if req.HandleResult == constant.FriendResponseRefuse {
|
if req.HandleResult == constant.FriendResponseRefuse {
|
||||||
@@ -284,9 +280,6 @@ func (s *friendServer) SetFriendRemark(ctx context.Context, req *relation.SetFri
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *friendServer) GetFriendInfo(ctx context.Context, req *relation.GetFriendInfoReq) (*relation.GetFriendInfoResp, error) {
|
func (s *friendServer) GetFriendInfo(ctx context.Context, req *relation.GetFriendInfoReq) (*relation.GetFriendInfoResp, error) {
|
||||||
if err := authverify.CheckAccessV3(ctx, req.OwnerUserID, s.config.Share.IMAdminUserID); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
friends, err := s.db.FindFriendsWithError(ctx, req.OwnerUserID, req.FriendUserIDs)
|
friends, err := s.db.FindFriendsWithError(ctx, req.OwnerUserID, req.FriendUserIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -299,9 +292,6 @@ func (s *friendServer) GetDesignatedFriends(ctx context.Context, req *relation.G
|
|||||||
if datautil.Duplicate(req.FriendUserIDs) {
|
if datautil.Duplicate(req.FriendUserIDs) {
|
||||||
return nil, errs.ErrArgs.WrapMsg("friend userID repeated")
|
return nil, errs.ErrArgs.WrapMsg("friend userID repeated")
|
||||||
}
|
}
|
||||||
if err := authverify.CheckAccessV3(ctx, req.OwnerUserID, s.config.Share.IMAdminUserID); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
friends, err := s.getFriend(ctx, req.OwnerUserID, req.FriendUserIDs)
|
friends, err := s.getFriend(ctx, req.OwnerUserID, req.FriendUserIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -331,7 +321,7 @@ func (s *friendServer) GetDesignatedFriendsApply(ctx context.Context,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp = &relation.GetDesignatedFriendsApplyResp{}
|
resp = &relation.GetDesignatedFriendsApplyResp{}
|
||||||
resp.FriendRequests, err = convert.FriendRequestDB2Pb(ctx, friendRequests, s.getCommonUserMap)
|
resp.FriendRequests, err = convert.FriendRequestDB2Pb(ctx, friendRequests, s.userClient.GetUsersInfoMap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -344,16 +334,13 @@ func (s *friendServer) GetPaginationFriendsApplyTo(ctx context.Context, req *rel
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
handleResults := datautil.Slice(req.HandleResults, func(e int32) int {
|
total, friendRequests, err := s.db.PageFriendRequestToMe(ctx, req.UserID, req.Pagination)
|
||||||
return int(e)
|
|
||||||
})
|
|
||||||
total, friendRequests, err := s.db.PageFriendRequestToMe(ctx, req.UserID, handleResults, req.Pagination)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp = &relation.GetPaginationFriendsApplyToResp{}
|
resp = &relation.GetPaginationFriendsApplyToResp{}
|
||||||
resp.FriendRequests, err = convert.FriendRequestDB2Pb(ctx, friendRequests, s.getCommonUserMap)
|
resp.FriendRequests, err = convert.FriendRequestDB2Pb(ctx, friendRequests, s.userClient.GetUsersInfoMap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -370,15 +357,12 @@ func (s *friendServer) GetPaginationFriendsApplyFrom(ctx context.Context, req *r
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
handleResults := datautil.Slice(req.HandleResults, func(e int32) int {
|
total, friendRequests, err := s.db.PageFriendRequestFromMe(ctx, req.UserID, req.Pagination)
|
||||||
return int(e)
|
|
||||||
})
|
|
||||||
total, friendRequests, err := s.db.PageFriendRequestFromMe(ctx, req.UserID, handleResults, req.Pagination)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp.FriendRequests, err = convert.FriendRequestDB2Pb(ctx, friendRequests, s.getCommonUserMap)
|
resp.FriendRequests, err = convert.FriendRequestDB2Pb(ctx, friendRequests, s.userClient.GetUsersInfoMap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -442,10 +426,6 @@ func (s *friendServer) GetSpecifiedFriendsInfo(ctx context.Context, req *relatio
|
|||||||
return nil, errs.ErrArgs.WrapMsg("userIDList repeated")
|
return nil, errs.ErrArgs.WrapMsg("userIDList repeated")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := authverify.CheckAccessV3(ctx, req.OwnerUserID, s.config.Share.IMAdminUserID); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
userMap, err := s.userClient.GetUsersInfoMap(ctx, req.UserIDList)
|
userMap, err := s.userClient.GetUsersInfoMap(ctx, req.UserIDList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -525,10 +505,6 @@ func (s *friendServer) UpdateFriends(
|
|||||||
return nil, errs.ErrArgs.WrapMsg("friendIDList repeated")
|
return nil, errs.ErrArgs.WrapMsg("friendIDList repeated")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := authverify.CheckAccessV3(ctx, req.OwnerUserID, s.config.Share.IMAdminUserID); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err := s.db.FindFriendsWithError(ctx, req.OwnerUserID, req.FriendUserIDs)
|
_, err := s.db.FindFriendsWithError(ctx, req.OwnerUserID, req.FriendUserIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -554,28 +530,3 @@ func (s *friendServer) UpdateFriends(
|
|||||||
s.notificationSender.FriendsInfoUpdateNotification(ctx, req.OwnerUserID, req.FriendUserIDs)
|
s.notificationSender.FriendsInfoUpdateNotification(ctx, req.OwnerUserID, req.FriendUserIDs)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *friendServer) GetSelfUnhandledApplyCount(ctx context.Context, req *relation.GetSelfUnhandledApplyCountReq) (*relation.GetSelfUnhandledApplyCountResp, error) {
|
|
||||||
if err := authverify.CheckAccessV3(ctx, req.UserID, s.config.Share.IMAdminUserID); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
count, err := s.db.GetUnhandledCount(ctx, req.UserID, req.Time)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &relation.GetSelfUnhandledApplyCountResp{
|
|
||||||
Count: count,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *friendServer) getCommonUserMap(ctx context.Context, userIDs []string) (map[string]common_user.CommonUser, error) {
|
|
||||||
users, err := s.userClient.GetUsersInfo(ctx, userIDs)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return datautil.SliceToMapAny(users, func(e *sdkws.UserInfo) (string, common_user.CommonUser) {
|
|
||||||
return e.UserID, e
|
|
||||||
}), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -19,9 +19,6 @@ import (
|
|||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
||||||
"github.com/openimsdk/protocol/msg"
|
"github.com/openimsdk/protocol/msg"
|
||||||
"github.com/openimsdk/tools/errs"
|
|
||||||
"github.com/openimsdk/tools/log"
|
|
||||||
"github.com/openimsdk/tools/utils/datautil"
|
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/versionctx"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/versionctx"
|
||||||
@@ -55,7 +52,9 @@ func WithFriendDB(db controller.FriendDatabase) friendNotificationSenderOptions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithDBFunc(fn func(ctx context.Context, userIDs []string) (users []*relationtb.User, err error)) friendNotificationSenderOptions {
|
func WithDBFunc(
|
||||||
|
fn func(ctx context.Context, userIDs []string) (users []*relationtb.User, err error),
|
||||||
|
) friendNotificationSenderOptions {
|
||||||
return func(s *FriendNotificationSender) {
|
return func(s *FriendNotificationSender) {
|
||||||
f := func(ctx context.Context, userIDs []string) (result []common_user.CommonUser, err error) {
|
f := func(ctx context.Context, userIDs []string) (result []common_user.CommonUser, err error) {
|
||||||
users, err := fn(ctx, userIDs)
|
users, err := fn(ctx, userIDs)
|
||||||
@@ -71,7 +70,9 @@ func WithDBFunc(fn func(ctx context.Context, userIDs []string) (users []*relatio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithRpcFunc(fn func(ctx context.Context, userIDs []string) ([]*sdkws.UserInfo, error)) friendNotificationSenderOptions {
|
func WithRpcFunc(
|
||||||
|
fn func(ctx context.Context, userIDs []string) ([]*sdkws.UserInfo, error),
|
||||||
|
) friendNotificationSenderOptions {
|
||||||
return func(s *FriendNotificationSender) {
|
return func(s *FriendNotificationSender) {
|
||||||
f := func(ctx context.Context, userIDs []string) (result []common_user.CommonUser, err error) {
|
f := func(ctx context.Context, userIDs []string) (result []common_user.CommonUser, err error) {
|
||||||
users, err := fn(ctx, userIDs)
|
users, err := fn(ctx, userIDs)
|
||||||
@@ -99,7 +100,10 @@ func NewFriendNotificationSender(conf *config.Notification, msgClient *rpcli.Msg
|
|||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FriendNotificationSender) getUsersInfoMap(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error) {
|
func (f *FriendNotificationSender) getUsersInfoMap(
|
||||||
|
ctx context.Context,
|
||||||
|
userIDs []string,
|
||||||
|
) (map[string]*sdkws.UserInfo, error) {
|
||||||
users, err := f.getUsersInfo(ctx, userIDs)
|
users, err := f.getUsersInfo(ctx, userIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -112,7 +116,10 @@ func (f *FriendNotificationSender) getUsersInfoMap(ctx context.Context, userIDs
|
|||||||
}
|
}
|
||||||
|
|
||||||
//nolint:unused
|
//nolint:unused
|
||||||
func (f *FriendNotificationSender) getFromToUserNickname(ctx context.Context, fromUserID, toUserID string) (string, string, error) {
|
func (f *FriendNotificationSender) getFromToUserNickname(
|
||||||
|
ctx context.Context,
|
||||||
|
fromUserID, toUserID string,
|
||||||
|
) (string, string, error) {
|
||||||
users, err := f.getUsersInfoMap(ctx, []string{fromUserID, toUserID})
|
users, err := f.getUsersInfoMap(ctx, []string{fromUserID, toUserID})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", nil
|
return "", "", nil
|
||||||
@@ -125,113 +132,60 @@ func (f *FriendNotificationSender) UserInfoUpdatedNotification(ctx context.Conte
|
|||||||
f.Notification(ctx, mcontext.GetOpUserID(ctx), changedUserID, constant.UserInfoUpdatedNotification, &tips)
|
f.Notification(ctx, mcontext.GetOpUserID(ctx), changedUserID, constant.UserInfoUpdatedNotification, &tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FriendNotificationSender) getCommonUserMap(ctx context.Context, userIDs []string) (map[string]common_user.CommonUser, error) {
|
|
||||||
users, err := f.getUsersInfo(ctx, userIDs)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return datautil.SliceToMap(users, func(e common_user.CommonUser) string {
|
|
||||||
return e.GetUserID()
|
|
||||||
}), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *FriendNotificationSender) getFriendRequests(ctx context.Context, fromUserID, toUserID string) (*sdkws.FriendRequest, error) {
|
|
||||||
if f.db == nil {
|
|
||||||
return nil, errs.ErrInternalServer.WithDetail("db is nil")
|
|
||||||
}
|
|
||||||
friendRequests, err := f.db.FindBothFriendRequests(ctx, fromUserID, toUserID)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
requests, err := convert.FriendRequestDB2Pb(ctx, friendRequests, f.getCommonUserMap)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
for _, request := range requests {
|
|
||||||
if request.FromUserID == fromUserID && request.ToUserID == toUserID {
|
|
||||||
return request, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil, errs.ErrRecordNotFound.WrapMsg("friend request not found", "fromUserID", fromUserID, "toUserID", toUserID)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *FriendNotificationSender) FriendApplicationAddNotification(ctx context.Context, req *relation.ApplyToAddFriendReq) {
|
func (f *FriendNotificationSender) FriendApplicationAddNotification(ctx context.Context, req *relation.ApplyToAddFriendReq) {
|
||||||
request, err := f.getFriendRequests(ctx, req.FromUserID, req.ToUserID)
|
tips := sdkws.FriendApplicationTips{FromToUserID: &sdkws.FromToUserID{
|
||||||
if err != nil {
|
FromUserID: req.FromUserID,
|
||||||
log.ZError(ctx, "FriendApplicationAddNotification get friend request", err, "fromUserID", req.FromUserID, "toUserID", req.ToUserID)
|
ToUserID: req.ToUserID,
|
||||||
return
|
}}
|
||||||
}
|
|
||||||
tips := sdkws.FriendApplicationTips{
|
|
||||||
FromToUserID: &sdkws.FromToUserID{
|
|
||||||
FromUserID: req.FromUserID,
|
|
||||||
ToUserID: req.ToUserID,
|
|
||||||
},
|
|
||||||
Request: request,
|
|
||||||
}
|
|
||||||
f.Notification(ctx, req.FromUserID, req.ToUserID, constant.FriendApplicationNotification, &tips)
|
f.Notification(ctx, req.FromUserID, req.ToUserID, constant.FriendApplicationNotification, &tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FriendNotificationSender) FriendApplicationAgreedNotification(ctx context.Context, req *relation.RespondFriendApplyReq, checkReq bool) {
|
func (f *FriendNotificationSender) FriendApplicationAgreedNotification(
|
||||||
var (
|
ctx context.Context,
|
||||||
request *sdkws.FriendRequest
|
req *relation.RespondFriendApplyReq,
|
||||||
err error
|
) {
|
||||||
)
|
tips := sdkws.FriendApplicationApprovedTips{FromToUserID: &sdkws.FromToUserID{
|
||||||
if checkReq {
|
FromUserID: req.FromUserID,
|
||||||
request, err = f.getFriendRequests(ctx, req.FromUserID, req.ToUserID)
|
ToUserID: req.ToUserID,
|
||||||
if err != nil {
|
}, HandleMsg: req.HandleMsg}
|
||||||
log.ZError(ctx, "FriendApplicationAgreedNotification get friend request", err, "fromUserID", req.FromUserID, "toUserID", req.ToUserID)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tips := sdkws.FriendApplicationApprovedTips{
|
|
||||||
FromToUserID: &sdkws.FromToUserID{
|
|
||||||
FromUserID: req.FromUserID,
|
|
||||||
ToUserID: req.ToUserID,
|
|
||||||
},
|
|
||||||
HandleMsg: req.HandleMsg,
|
|
||||||
Request: request,
|
|
||||||
}
|
|
||||||
f.Notification(ctx, req.ToUserID, req.FromUserID, constant.FriendApplicationApprovedNotification, &tips)
|
f.Notification(ctx, req.ToUserID, req.FromUserID, constant.FriendApplicationApprovedNotification, &tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FriendNotificationSender) FriendApplicationRefusedNotification(ctx context.Context, req *relation.RespondFriendApplyReq) {
|
func (f *FriendNotificationSender) FriendApplicationRefusedNotification(
|
||||||
request, err := f.getFriendRequests(ctx, req.FromUserID, req.ToUserID)
|
ctx context.Context,
|
||||||
if err != nil {
|
req *relation.RespondFriendApplyReq,
|
||||||
log.ZError(ctx, "FriendApplicationRefusedNotification get friend request", err, "fromUserID", req.FromUserID, "toUserID", req.ToUserID)
|
) {
|
||||||
return
|
tips := sdkws.FriendApplicationApprovedTips{FromToUserID: &sdkws.FromToUserID{
|
||||||
}
|
FromUserID: req.FromUserID,
|
||||||
tips := sdkws.FriendApplicationRejectedTips{
|
ToUserID: req.ToUserID,
|
||||||
FromToUserID: &sdkws.FromToUserID{
|
}, HandleMsg: req.HandleMsg}
|
||||||
FromUserID: req.FromUserID,
|
|
||||||
ToUserID: req.ToUserID,
|
|
||||||
},
|
|
||||||
HandleMsg: req.HandleMsg,
|
|
||||||
Request: request,
|
|
||||||
}
|
|
||||||
f.Notification(ctx, req.ToUserID, req.FromUserID, constant.FriendApplicationRejectedNotification, &tips)
|
f.Notification(ctx, req.ToUserID, req.FromUserID, constant.FriendApplicationRejectedNotification, &tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
//func (f *FriendNotificationSender) FriendAddedNotification(ctx context.Context, operationID, opUserID, fromUserID, toUserID string) error {
|
func (f *FriendNotificationSender) FriendAddedNotification(
|
||||||
// tips := sdkws.FriendAddedTips{Friend: &sdkws.FriendInfo{}, OpUser: &sdkws.PublicUserInfo{}}
|
ctx context.Context,
|
||||||
// user, err := f.getUsersInfo(ctx, []string{opUserID})
|
operationID, opUserID, fromUserID, toUserID string,
|
||||||
// if err != nil {
|
) error {
|
||||||
// return err
|
tips := sdkws.FriendAddedTips{Friend: &sdkws.FriendInfo{}, OpUser: &sdkws.PublicUserInfo{}}
|
||||||
// }
|
user, err := f.getUsersInfo(ctx, []string{opUserID})
|
||||||
// tips.OpUser.UserID = user[0].GetUserID()
|
if err != nil {
|
||||||
// tips.OpUser.Ex = user[0].GetEx()
|
return err
|
||||||
// tips.OpUser.Nickname = user[0].GetNickname()
|
}
|
||||||
// tips.OpUser.FaceURL = user[0].GetFaceURL()
|
tips.OpUser.UserID = user[0].GetUserID()
|
||||||
// friends, err := f.db.FindFriendsWithError(ctx, fromUserID, []string{toUserID})
|
tips.OpUser.Ex = user[0].GetEx()
|
||||||
// if err != nil {
|
tips.OpUser.Nickname = user[0].GetNickname()
|
||||||
// return err
|
tips.OpUser.FaceURL = user[0].GetFaceURL()
|
||||||
// }
|
friends, err := f.db.FindFriendsWithError(ctx, fromUserID, []string{toUserID})
|
||||||
// tips.Friend, err = convert.FriendDB2Pb(ctx, friends[0], f.getUsersInfoMap)
|
if err != nil {
|
||||||
// if err != nil {
|
return err
|
||||||
// return err
|
}
|
||||||
// }
|
tips.Friend, err = convert.FriendDB2Pb(ctx, friends[0], f.getUsersInfoMap)
|
||||||
// f.Notification(ctx, fromUserID, toUserID, constant.FriendAddedNotification, &tips)
|
if err != nil {
|
||||||
// return nil
|
return err
|
||||||
//}
|
}
|
||||||
|
f.Notification(ctx, fromUserID, toUserID, constant.FriendAddedNotification, &tips)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (f *FriendNotificationSender) FriendDeletedNotification(ctx context.Context, req *relation.DeleteFriendReq) {
|
func (f *FriendNotificationSender) FriendDeletedNotification(ctx context.Context, req *relation.DeleteFriendReq) {
|
||||||
tips := sdkws.FriendDeletedTips{FromToUserID: &sdkws.FromToUserID{
|
tips := sdkws.FriendDeletedTips{FromToUserID: &sdkws.FromToUserID{
|
||||||
|
|||||||
@@ -2,11 +2,10 @@ package relation
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"slices"
|
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/util/hashutil"
|
"github.com/openimsdk/open-im-server/v3/pkg/util/hashutil"
|
||||||
"github.com/openimsdk/protocol/sdkws"
|
"github.com/openimsdk/protocol/sdkws"
|
||||||
"github.com/openimsdk/tools/log"
|
"github.com/openimsdk/tools/log"
|
||||||
|
"slices"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/internal/rpc/incrversion"
|
"github.com/openimsdk/open-im-server/v3/internal/rpc/incrversion"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
|
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
|
||||||
@@ -40,9 +39,6 @@ func (s *friendServer) NotificationUserInfoUpdate(ctx context.Context, req *rela
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *friendServer) GetFullFriendUserIDs(ctx context.Context, req *relation.GetFullFriendUserIDsReq) (*relation.GetFullFriendUserIDsResp, error) {
|
func (s *friendServer) GetFullFriendUserIDs(ctx context.Context, req *relation.GetFullFriendUserIDsReq) (*relation.GetFullFriendUserIDsResp, error) {
|
||||||
if err := authverify.CheckAccessV3(ctx, req.UserID, s.config.Share.IMAdminUserID); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
vl, err := s.db.FindMaxFriendVersionCache(ctx, req.UserID)
|
vl, err := s.db.FindMaxFriendVersionCache(ctx, req.UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -56,7 +52,7 @@ func (s *friendServer) GetFullFriendUserIDs(ctx context.Context, req *relation.G
|
|||||||
userIDs = nil
|
userIDs = nil
|
||||||
}
|
}
|
||||||
return &relation.GetFullFriendUserIDsResp{
|
return &relation.GetFullFriendUserIDsResp{
|
||||||
Version: uint64(vl.Version),
|
Version: idHash,
|
||||||
VersionID: vl.ID.Hex(),
|
VersionID: vl.ID.Hex(),
|
||||||
Equal: req.IdHash == idHash,
|
Equal: req.IdHash == idHash,
|
||||||
UserIDs: userIDs,
|
UserIDs: userIDs,
|
||||||
|
|||||||
@@ -17,13 +17,8 @@ package third
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
||||||
"github.com/openimsdk/tools/s3/aws"
|
"time"
|
||||||
"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/config"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/redis"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/redis"
|
||||||
@@ -39,6 +34,7 @@ import (
|
|||||||
"github.com/openimsdk/tools/s3/kodo"
|
"github.com/openimsdk/tools/s3/kodo"
|
||||||
"github.com/openimsdk/tools/s3/minio"
|
"github.com/openimsdk/tools/s3/minio"
|
||||||
"github.com/openimsdk/tools/s3/oss"
|
"github.com/openimsdk/tools/s3/oss"
|
||||||
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
type thirdServer struct {
|
type thirdServer struct {
|
||||||
@@ -94,10 +90,6 @@ func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryReg
|
|||||||
o, err = oss.NewOSS(*config.RpcConfig.Object.Oss.Build())
|
o, err = oss.NewOSS(*config.RpcConfig.Object.Oss.Build())
|
||||||
case "kodo":
|
case "kodo":
|
||||||
o, err = kodo.NewKodo(*config.RpcConfig.Object.Kodo.Build())
|
o, err = kodo.NewKodo(*config.RpcConfig.Object.Kodo.Build())
|
||||||
case "aws":
|
|
||||||
o, err = aws.NewAws(*config.RpcConfig.Object.Aws.Build())
|
|
||||||
case "":
|
|
||||||
o = disable.NewDisable()
|
|
||||||
default:
|
default:
|
||||||
err = fmt.Errorf("invalid object enable: %s", enable)
|
err = fmt.Errorf("invalid object enable: %s", enable)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-11
@@ -4,23 +4,14 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/openimsdk/gomake/mageutil"
|
"github.com/openimsdk/gomake/mageutil"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Default = Build
|
var Default = Build
|
||||||
|
|
||||||
func Build() {
|
func Build() {
|
||||||
flag.Parse()
|
mageutil.Build()
|
||||||
|
|
||||||
bin := flag.Args()
|
|
||||||
if len(bin) != 0 {
|
|
||||||
bin = bin[1:]
|
|
||||||
}
|
|
||||||
|
|
||||||
mageutil.Build(bin)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func Start() {
|
func Start() {
|
||||||
|
|||||||
+14
-20
@@ -354,13 +354,13 @@ type User struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Redis struct {
|
type Redis struct {
|
||||||
Address []string `mapstructure:"address"`
|
Address []string `mapstructure:"address"`
|
||||||
Username string `mapstructure:"username"`
|
Username string `mapstructure:"username"`
|
||||||
Password string `mapstructure:"password"`
|
Password string `mapstructure:"password"`
|
||||||
RedisMode string `mapstructure:"redisMode"`
|
ClusterMode bool `mapstructure:"clusterMode"`
|
||||||
DB int `mapstructure:"db"`
|
DB int `mapstructure:"storage"`
|
||||||
MaxRetry int `mapstructure:"maxRetry"`
|
MaxRetry int `mapstructure:"maxRetry"`
|
||||||
PoolSize int `mapstructure:"poolSize"`
|
PoolSize int `mapstructure:"poolSize"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type BeforeConfig struct {
|
type BeforeConfig struct {
|
||||||
@@ -384,12 +384,6 @@ type Share struct {
|
|||||||
RpcRegisterName RpcRegisterName `mapstructure:"rpcRegisterName"`
|
RpcRegisterName RpcRegisterName `mapstructure:"rpcRegisterName"`
|
||||||
IMAdminUserID []string `mapstructure:"imAdminUserID"`
|
IMAdminUserID []string `mapstructure:"imAdminUserID"`
|
||||||
MultiLogin MultiLogin `mapstructure:"multiLogin"`
|
MultiLogin MultiLogin `mapstructure:"multiLogin"`
|
||||||
RPCMaxBodySize MaxRequestBody `mapstructure:"rpcMaxBodySize"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type MaxRequestBody struct {
|
|
||||||
RequestMaxBodySize int `mapstructure:"requestMaxBodySize"`
|
|
||||||
ResponseMaxBodySize int `mapstructure:"responseMaxBodySize"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type MultiLogin struct {
|
type MultiLogin struct {
|
||||||
@@ -511,13 +505,13 @@ func (m *Mongo) Build() *mongoutil.Config {
|
|||||||
|
|
||||||
func (r *Redis) Build() *redisutil.Config {
|
func (r *Redis) Build() *redisutil.Config {
|
||||||
return &redisutil.Config{
|
return &redisutil.Config{
|
||||||
RedisMode: r.RedisMode,
|
ClusterMode: r.ClusterMode,
|
||||||
Address: r.Address,
|
Address: r.Address,
|
||||||
Username: r.Username,
|
Username: r.Username,
|
||||||
Password: r.Password,
|
Password: r.Password,
|
||||||
DB: r.DB,
|
DB: r.DB,
|
||||||
MaxRetry: r.MaxRetry,
|
MaxRetry: r.MaxRetry,
|
||||||
PoolSize: r.PoolSize,
|
PoolSize: r.PoolSize,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,9 +17,7 @@ package convert
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/notification/common_user"
|
|
||||||
"github.com/openimsdk/protocol/relation"
|
"github.com/openimsdk/protocol/relation"
|
||||||
|
|
||||||
"github.com/openimsdk/protocol/sdkws"
|
"github.com/openimsdk/protocol/sdkws"
|
||||||
@@ -100,7 +98,7 @@ func FriendOnlyDB2PbOnly(friendsDB []*model.Friend) []*relation.FriendInfoOnly {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func FriendRequestDB2Pb(ctx context.Context, friendRequests []*model.FriendRequest, getUsers func(ctx context.Context, userIDs []string) (map[string]common_user.CommonUser, error)) ([]*sdkws.FriendRequest, error) {
|
func FriendRequestDB2Pb(ctx context.Context, friendRequests []*model.FriendRequest, getUsers func(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error)) ([]*sdkws.FriendRequest, error) {
|
||||||
if len(friendRequests) == 0 {
|
if len(friendRequests) == 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
@@ -119,11 +117,11 @@ func FriendRequestDB2Pb(ctx context.Context, friendRequests []*model.FriendReque
|
|||||||
fromUser := users[friendRequest.FromUserID]
|
fromUser := users[friendRequest.FromUserID]
|
||||||
res = append(res, &sdkws.FriendRequest{
|
res = append(res, &sdkws.FriendRequest{
|
||||||
FromUserID: friendRequest.FromUserID,
|
FromUserID: friendRequest.FromUserID,
|
||||||
FromNickname: fromUser.GetNickname(),
|
FromNickname: fromUser.Nickname,
|
||||||
FromFaceURL: fromUser.GetFaceURL(),
|
FromFaceURL: fromUser.FaceURL,
|
||||||
ToUserID: friendRequest.ToUserID,
|
ToUserID: friendRequest.ToUserID,
|
||||||
ToNickname: toUser.GetNickname(),
|
ToNickname: toUser.Nickname,
|
||||||
ToFaceURL: toUser.GetFaceURL(),
|
ToFaceURL: toUser.FaceURL,
|
||||||
HandleResult: friendRequest.HandleResult,
|
HandleResult: friendRequest.HandleResult,
|
||||||
ReqMsg: friendRequest.ReqMsg,
|
ReqMsg: friendRequest.ReqMsg,
|
||||||
CreateTime: friendRequest.CreateTime.UnixMilli(),
|
CreateTime: friendRequest.CreateTime.UnixMilli(),
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import (
|
|||||||
func NewDiscoveryRegister(discovery *config.Discovery, share *config.Share, watchNames []string) (discovery.SvcDiscoveryRegistry, error) {
|
func NewDiscoveryRegister(discovery *config.Discovery, share *config.Share, watchNames []string) (discovery.SvcDiscoveryRegistry, error) {
|
||||||
switch discovery.Enable {
|
switch discovery.Enable {
|
||||||
case "k8s":
|
case "k8s":
|
||||||
return kubernetes.NewConnManager("default", watchNames,
|
return kubernetes.NewKubernetesConnManager("default",
|
||||||
grpc.WithDefaultCallOptions(
|
grpc.WithDefaultCallOptions(
|
||||||
grpc.MaxCallSendMsgSize(1024*1024*20),
|
grpc.MaxCallSendMsgSize(1024*1024*20),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import "fmt"
|
|||||||
const (
|
const (
|
||||||
APIKeyName = "api"
|
APIKeyName = "api"
|
||||||
MessageTransferKeyName = "message-transfer"
|
MessageTransferKeyName = "message-transfer"
|
||||||
TTL = 300
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Target struct {
|
type Target struct {
|
||||||
@@ -18,14 +17,10 @@ type RespTarget struct {
|
|||||||
Labels map[string]string `json:"labels"`
|
Labels map[string]string `json:"labels"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func BuildDiscoveryKeyPrefix(name string) string {
|
func BuildDiscoveryKey(name string) string {
|
||||||
return fmt.Sprintf("%s/%s/%s", "openim", "prometheus_discovery", name)
|
return fmt.Sprintf("%s/%s/%s", "openim", "prometheus_discovery", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func BuildDiscoveryKey(name string, index int) string {
|
|
||||||
return fmt.Sprintf("%s/%s/%s/%d", "openim", "prometheus_discovery", name, index)
|
|
||||||
}
|
|
||||||
|
|
||||||
func BuildDefaultTarget(host string, ip int) Target {
|
func BuildDefaultTarget(host string, ip int) Target {
|
||||||
return Target{
|
return Target{
|
||||||
Target: fmt.Sprintf("%s:%d", host, ip),
|
Target: fmt.Sprintf("%s:%d", host, ip),
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"reflect"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
@@ -44,36 +43,6 @@ import (
|
|||||||
"google.golang.org/grpc/credentials/insecure"
|
"google.golang.org/grpc/credentials/insecure"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getConfigRpcMaxRequestBody(value reflect.Value) *conf.MaxRequestBody {
|
|
||||||
for value.Kind() == reflect.Pointer {
|
|
||||||
value = value.Elem()
|
|
||||||
}
|
|
||||||
if value.Kind() == reflect.Struct {
|
|
||||||
num := value.NumField()
|
|
||||||
for i := 0; i < num; i++ {
|
|
||||||
field := value.Field(i)
|
|
||||||
if !field.CanInterface() {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
for field.Kind() == reflect.Pointer {
|
|
||||||
field = field.Elem()
|
|
||||||
}
|
|
||||||
switch elem := field.Interface().(type) {
|
|
||||||
case conf.Share:
|
|
||||||
return &elem.RPCMaxBodySize
|
|
||||||
case conf.MaxRequestBody:
|
|
||||||
return &elem
|
|
||||||
}
|
|
||||||
if field.Kind() == reflect.Struct {
|
|
||||||
if elem := getConfigRpcMaxRequestBody(field); elem != nil {
|
|
||||||
return elem
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start rpc server.
|
// Start rpc server.
|
||||||
func Start[T any](ctx context.Context, discovery *conf.Discovery, prometheusConfig *conf.Prometheus, listenIP,
|
func Start[T any](ctx context.Context, discovery *conf.Discovery, prometheusConfig *conf.Prometheus, listenIP,
|
||||||
registerIP string, autoSetPorts bool, rpcPorts []int, index int, rpcRegisterName string, share *conf.Share, config T,
|
registerIP string, autoSetPorts bool, rpcPorts []int, index int, rpcRegisterName string, share *conf.Share, config T,
|
||||||
@@ -81,19 +50,6 @@ func Start[T any](ctx context.Context, discovery *conf.Discovery, prometheusConf
|
|||||||
rpcFn func(ctx context.Context, config T, client discovery.SvcDiscoveryRegistry, server *grpc.Server) error,
|
rpcFn func(ctx context.Context, config T, client discovery.SvcDiscoveryRegistry, server *grpc.Server) error,
|
||||||
options ...grpc.ServerOption) error {
|
options ...grpc.ServerOption) error {
|
||||||
|
|
||||||
maxRequestBody := &share.RPCMaxBodySize
|
|
||||||
var clientOptions []grpc.DialOption
|
|
||||||
if maxRequestBody != nil {
|
|
||||||
if maxRequestBody.RequestMaxBodySize > 0 {
|
|
||||||
options = append(options, grpc.MaxRecvMsgSize(maxRequestBody.RequestMaxBodySize))
|
|
||||||
clientOptions = append(clientOptions, grpc.WithDefaultCallOptions(grpc.MaxCallSendMsgSize(maxRequestBody.RequestMaxBodySize)))
|
|
||||||
}
|
|
||||||
if maxRequestBody.ResponseMaxBodySize > 0 {
|
|
||||||
options = append(options, grpc.MaxSendMsgSize(maxRequestBody.ResponseMaxBodySize))
|
|
||||||
clientOptions = append(clientOptions, grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxRequestBody.ResponseMaxBodySize)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
rpcTcpAddr string
|
rpcTcpAddr string
|
||||||
netDone = make(chan struct{}, 2)
|
netDone = make(chan struct{}, 2)
|
||||||
@@ -137,10 +93,6 @@ func Start[T any](ctx context.Context, discovery *conf.Discovery, prometheusConf
|
|||||||
defer client.Close()
|
defer client.Close()
|
||||||
client.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, "round_robin")))
|
client.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, "round_robin")))
|
||||||
|
|
||||||
if len(clientOptions) > 0 {
|
|
||||||
client.AddOption(clientOptions...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// var reg *prometheus.Registry
|
// var reg *prometheus.Registry
|
||||||
// var metric *grpcprometheus.ServerMetrics
|
// var metric *grpcprometheus.ServerMetrics
|
||||||
if prometheusConfig.Enable {
|
if prometheusConfig.Enable {
|
||||||
@@ -164,16 +116,9 @@ func Start[T any](ctx context.Context, discovery *conf.Discovery, prometheusConf
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
etcdClient, ok := client.(*etcd.SvcDiscoveryRegistryImpl)
|
etcdClient := client.(*etcd.SvcDiscoveryRegistryImpl).GetClient()
|
||||||
if !ok {
|
|
||||||
return errs.New("only etcd support autoSetPorts").Wrap()
|
|
||||||
}
|
|
||||||
|
|
||||||
target, err := jsonutil.JsonMarshal(prommetrics.BuildDefaultTarget(registerIP, prometheusPort))
|
_, err = etcdClient.Put(ctx, prommetrics.BuildDiscoveryKey(rpcRegisterName), jsonutil.StructToJsonString(prommetrics.BuildDefaultTarget(registerIP, prometheusPort)))
|
||||||
if err != nil {
|
|
||||||
return errs.Wrap(err)
|
|
||||||
}
|
|
||||||
err = etcdClient.SetWithLease(ctx, prommetrics.BuildDiscoveryKey(rpcRegisterName, index), target, prommetrics.TTL)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errs.WrapMsg(err, "etcd put err")
|
return errs.WrapMsg(err, "etcd put err")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,11 +17,10 @@ package controller
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database/mgo"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database/mgo"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache"
|
||||||
"github.com/openimsdk/protocol/constant"
|
"github.com/openimsdk/protocol/constant"
|
||||||
@@ -62,10 +61,10 @@ type FriendDatabase interface {
|
|||||||
PageInWhoseFriends(ctx context.Context, friendUserID string, pagination pagination.Pagination) (total int64, friends []*model.Friend, err error)
|
PageInWhoseFriends(ctx context.Context, friendUserID string, pagination pagination.Pagination) (total int64, friends []*model.Friend, err error)
|
||||||
|
|
||||||
// PageFriendRequestFromMe retrieves the friend requests sent by the user with pagination
|
// PageFriendRequestFromMe retrieves the friend requests sent by the user with pagination
|
||||||
PageFriendRequestFromMe(ctx context.Context, userID string, handleResults []int, pagination pagination.Pagination) (total int64, friends []*model.FriendRequest, err error)
|
PageFriendRequestFromMe(ctx context.Context, userID string, pagination pagination.Pagination) (total int64, friends []*model.FriendRequest, err error)
|
||||||
|
|
||||||
// PageFriendRequestToMe retrieves the friend requests received by the user with pagination
|
// PageFriendRequestToMe retrieves the friend requests received by the user with pagination
|
||||||
PageFriendRequestToMe(ctx context.Context, userID string, handleResults []int, pagination pagination.Pagination) (total int64, friends []*model.FriendRequest, err error)
|
PageFriendRequestToMe(ctx context.Context, userID string, pagination pagination.Pagination) (total int64, friends []*model.FriendRequest, err error)
|
||||||
|
|
||||||
// FindFriendsWithError fetches specified friends of a user and returns an error if any do not exist
|
// FindFriendsWithError fetches specified friends of a user and returns an error if any do not exist
|
||||||
FindFriendsWithError(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*model.Friend, err error)
|
FindFriendsWithError(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*model.Friend, err error)
|
||||||
@@ -88,8 +87,6 @@ type FriendDatabase interface {
|
|||||||
FindFriendUserID(ctx context.Context, friendUserID string) ([]string, error)
|
FindFriendUserID(ctx context.Context, friendUserID string) ([]string, error)
|
||||||
|
|
||||||
OwnerIncrVersion(ctx context.Context, ownerUserID string, friendUserIDs []string, state int32) error
|
OwnerIncrVersion(ctx context.Context, ownerUserID string, friendUserIDs []string, state int32) error
|
||||||
|
|
||||||
GetUnhandledCount(ctx context.Context, userID string, ts int64) (int64, error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type friendDatabase struct {
|
type friendDatabase struct {
|
||||||
@@ -337,13 +334,13 @@ func (f *friendDatabase) PageInWhoseFriends(ctx context.Context, friendUserID st
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PageFriendRequestFromMe retrieves friend requests sent by me. It does not return an error if the result is empty.
|
// PageFriendRequestFromMe retrieves friend requests sent by me. It does not return an error if the result is empty.
|
||||||
func (f *friendDatabase) PageFriendRequestFromMe(ctx context.Context, userID string, handleResults []int, pagination pagination.Pagination) (total int64, friends []*model.FriendRequest, err error) {
|
func (f *friendDatabase) PageFriendRequestFromMe(ctx context.Context, userID string, pagination pagination.Pagination) (total int64, friends []*model.FriendRequest, err error) {
|
||||||
return f.friendRequest.FindFromUserID(ctx, userID, handleResults, pagination)
|
return f.friendRequest.FindFromUserID(ctx, userID, pagination)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PageFriendRequestToMe retrieves friend requests received by me. It does not return an error if the result is empty.
|
// PageFriendRequestToMe retrieves friend requests received by me. It does not return an error if the result is empty.
|
||||||
func (f *friendDatabase) PageFriendRequestToMe(ctx context.Context, userID string, handleResults []int, pagination pagination.Pagination) (total int64, friends []*model.FriendRequest, err error) {
|
func (f *friendDatabase) PageFriendRequestToMe(ctx context.Context, userID string, pagination pagination.Pagination) (total int64, friends []*model.FriendRequest, err error) {
|
||||||
return f.friendRequest.FindToUserID(ctx, userID, handleResults, pagination)
|
return f.friendRequest.FindToUserID(ctx, userID, pagination)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindFriendsWithError retrieves specified friends' information for ownerUserID. Returns an error if any friend does not exist.
|
// FindFriendsWithError retrieves specified friends' information for ownerUserID. Returns an error if any friend does not exist.
|
||||||
@@ -400,7 +397,3 @@ func (f *friendDatabase) OwnerIncrVersion(ctx context.Context, ownerUserID strin
|
|||||||
}
|
}
|
||||||
return f.cache.DelMaxFriendVersion(ownerUserID).ChainExecDel(ctx)
|
return f.cache.DelMaxFriendVersion(ownerUserID).ChainExecDel(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *friendDatabase) GetUnhandledCount(ctx context.Context, userID string, ts int64) (int64, error) {
|
|
||||||
return f.friendRequest.GetUnhandledCount(ctx, userID, ts)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ type GroupDatabase interface {
|
|||||||
// FindUserManagedGroupID retrieves group IDs managed by a user.
|
// FindUserManagedGroupID retrieves group IDs managed by a user.
|
||||||
FindUserManagedGroupID(ctx context.Context, userID string) (groupIDs []string, err error)
|
FindUserManagedGroupID(ctx context.Context, userID string) (groupIDs []string, err error)
|
||||||
// PageGroupRequest paginates through group requests for specified groups.
|
// PageGroupRequest paginates through group requests for specified groups.
|
||||||
PageGroupRequest(ctx context.Context, groupIDs []string, handleResults []int, pagination pagination.Pagination) (int64, []*model.GroupRequest, error)
|
PageGroupRequest(ctx context.Context, groupIDs []string, pagination pagination.Pagination) (int64, []*model.GroupRequest, error)
|
||||||
// GetGroupRoleLevelMemberIDs retrieves user IDs of group members with a specific role level.
|
// GetGroupRoleLevelMemberIDs retrieves user IDs of group members with a specific role level.
|
||||||
GetGroupRoleLevelMemberIDs(ctx context.Context, groupID string, roleLevel int32) ([]string, error)
|
GetGroupRoleLevelMemberIDs(ctx context.Context, groupID string, roleLevel int32) ([]string, error)
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ type GroupDatabase interface {
|
|||||||
// FindGroupRequests retrieves multiple group join requests.
|
// FindGroupRequests retrieves multiple group join requests.
|
||||||
FindGroupRequests(ctx context.Context, groupID string, userIDs []string) ([]*model.GroupRequest, error)
|
FindGroupRequests(ctx context.Context, groupID string, userIDs []string) ([]*model.GroupRequest, error)
|
||||||
// PageGroupRequestUser paginates through group join requests made by a user.
|
// PageGroupRequestUser paginates through group join requests made by a user.
|
||||||
PageGroupRequestUser(ctx context.Context, userID string, groupIDs []string, handleResults []int, pagination pagination.Pagination) (int64, []*model.GroupRequest, error)
|
PageGroupRequestUser(ctx context.Context, userID string, pagination pagination.Pagination) (int64, []*model.GroupRequest, error)
|
||||||
|
|
||||||
// CountTotal counts the total number of groups as of a certain date.
|
// CountTotal counts the total number of groups as of a certain date.
|
||||||
CountTotal(ctx context.Context, before *time.Time) (count int64, err error)
|
CountTotal(ctx context.Context, before *time.Time) (count int64, err error)
|
||||||
@@ -124,8 +124,6 @@ type GroupDatabase interface {
|
|||||||
SearchJoinGroup(ctx context.Context, userID string, keyword string, pagination pagination.Pagination) (int64, []*model.Group, error)
|
SearchJoinGroup(ctx context.Context, userID string, keyword string, pagination pagination.Pagination) (int64, []*model.Group, error)
|
||||||
|
|
||||||
FindJoinGroupID(ctx context.Context, userID string) ([]string, error)
|
FindJoinGroupID(ctx context.Context, userID string) ([]string, error)
|
||||||
|
|
||||||
GetGroupApplicationUnhandledCount(ctx context.Context, groupIDs []string, ts int64) (int64, error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGroupDatabase(
|
func NewGroupDatabase(
|
||||||
@@ -306,8 +304,8 @@ func (g *groupDatabase) FindUserManagedGroupID(ctx context.Context, userID strin
|
|||||||
return g.groupMemberDB.FindUserManagedGroupID(ctx, userID)
|
return g.groupMemberDB.FindUserManagedGroupID(ctx, userID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *groupDatabase) PageGroupRequest(ctx context.Context, groupIDs []string, handleResults []int, pagination pagination.Pagination) (int64, []*model.GroupRequest, error) {
|
func (g *groupDatabase) PageGroupRequest(ctx context.Context, groupIDs []string, pagination pagination.Pagination) (int64, []*model.GroupRequest, error) {
|
||||||
return g.groupRequestDB.PageGroup(ctx, groupIDs, handleResults, pagination)
|
return g.groupRequestDB.PageGroup(ctx, groupIDs, pagination)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *groupDatabase) PageGetJoinGroup(ctx context.Context, userID string, pagination pagination.Pagination) (total int64, totalGroupMembers []*model.GroupMember, err error) {
|
func (g *groupDatabase) PageGetJoinGroup(ctx context.Context, userID string, pagination pagination.Pagination) (total int64, totalGroupMembers []*model.GroupMember, err error) {
|
||||||
@@ -465,12 +463,16 @@ func (g *groupDatabase) CreateGroupRequest(ctx context.Context, requests []*mode
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *groupDatabase) TakeGroupRequest(ctx context.Context, groupID string, userID string) (*model.GroupRequest, error) {
|
func (g *groupDatabase) TakeGroupRequest(
|
||||||
|
ctx context.Context,
|
||||||
|
groupID string,
|
||||||
|
userID string,
|
||||||
|
) (*model.GroupRequest, error) {
|
||||||
return g.groupRequestDB.Take(ctx, groupID, userID)
|
return g.groupRequestDB.Take(ctx, groupID, userID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *groupDatabase) PageGroupRequestUser(ctx context.Context, userID string, groupIDs []string, handleResults []int, pagination pagination.Pagination) (int64, []*model.GroupRequest, error) {
|
func (g *groupDatabase) PageGroupRequestUser(ctx context.Context, userID string, pagination pagination.Pagination) (int64, []*model.GroupRequest, error) {
|
||||||
return g.groupRequestDB.Page(ctx, userID, groupIDs, handleResults, pagination)
|
return g.groupRequestDB.Page(ctx, userID, pagination)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *groupDatabase) CountTotal(ctx context.Context, before *time.Time) (count int64, err error) {
|
func (g *groupDatabase) CountTotal(ctx context.Context, before *time.Time) (count int64, err error) {
|
||||||
@@ -563,7 +565,3 @@ func (g *groupDatabase) MemberGroupIncrVersion(ctx context.Context, groupID stri
|
|||||||
}
|
}
|
||||||
return g.cache.DelMaxGroupMemberVersion(groupID).ChainExecDel(ctx)
|
return g.cache.DelMaxGroupMemberVersion(groupID).ChainExecDel(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *groupDatabase) GetGroupApplicationUnhandledCount(ctx context.Context, groupIDs []string, ts int64) (int64, error) {
|
|
||||||
return g.groupRequestDB.GetUnhandledCount(ctx, groupIDs, ts)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -310,7 +310,7 @@ func (db *commonMsgDatabase) handlerDBMsg(ctx context.Context, cache map[int64][
|
|||||||
log.ZError(ctx, "json.Unmarshal", err)
|
log.ZError(ctx, "json.Unmarshal", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if quoteMsg.QuoteMessage == nil {
|
if quoteMsg.QuoteMessage == nil || quoteMsg.QuoteMessage.Content == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if quoteMsg.QuoteMessage.Content == "e30=" {
|
if quoteMsg.QuoteMessage.Content == "e30=" {
|
||||||
@@ -675,19 +675,12 @@ func (db *commonMsgDatabase) SearchMessage(ctx context.Context, req *pbmsg.Searc
|
|||||||
func (db *commonMsgDatabase) FindOneByDocIDs(ctx context.Context, conversationIDs []string, seqs map[string]int64) (map[string]*sdkws.MsgData, error) {
|
func (db *commonMsgDatabase) FindOneByDocIDs(ctx context.Context, conversationIDs []string, seqs map[string]int64) (map[string]*sdkws.MsgData, error) {
|
||||||
totalMsgs := make(map[string]*sdkws.MsgData)
|
totalMsgs := make(map[string]*sdkws.MsgData)
|
||||||
for _, conversationID := range conversationIDs {
|
for _, conversationID := range conversationIDs {
|
||||||
seq, ok := seqs[conversationID]
|
seq := seqs[conversationID]
|
||||||
if !ok {
|
|
||||||
log.ZWarn(ctx, "seq not found for conversationID", errs.New("seq not found for conversation"), "conversationID", conversationID)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
docID := db.msgTable.GetDocID(conversationID, seq)
|
docID := db.msgTable.GetDocID(conversationID, seq)
|
||||||
msgs, err := db.msgDocDatabase.FindOneByDocID(ctx, docID)
|
msgs, err := db.msgDocDatabase.FindOneByDocID(ctx, docID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZWarn(ctx, "FindOneByDocID failed", err, "conversationID", conversationID, "docID", docID, "seq", seq)
|
return nil, err
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
index := db.msgTable.GetMsgIndex(seq)
|
index := db.msgTable.GetMsgIndex(seq)
|
||||||
totalMsgs[conversationID] = convert.MsgDB2Pb(msgs.Msg[index].Msg)
|
totalMsgs[conversationID] = convert.MsgDB2Pb(msgs.Msg[index].Msg)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ package database
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
|
||||||
"github.com/openimsdk/tools/db/pagination"
|
"github.com/openimsdk/tools/db/pagination"
|
||||||
)
|
)
|
||||||
@@ -34,9 +33,8 @@ type FriendRequest interface {
|
|||||||
Find(ctx context.Context, fromUserID, toUserID string) (friendRequest *model.FriendRequest, err error)
|
Find(ctx context.Context, fromUserID, toUserID string) (friendRequest *model.FriendRequest, err error)
|
||||||
Take(ctx context.Context, fromUserID, toUserID string) (friendRequest *model.FriendRequest, err error)
|
Take(ctx context.Context, fromUserID, toUserID string) (friendRequest *model.FriendRequest, err error)
|
||||||
// Get list of friend requests received by toUserID
|
// Get list of friend requests received by toUserID
|
||||||
FindToUserID(ctx context.Context, toUserID string, handleResults []int, pagination pagination.Pagination) (total int64, friendRequests []*model.FriendRequest, err error)
|
FindToUserID(ctx context.Context, toUserID string, pagination pagination.Pagination) (total int64, friendRequests []*model.FriendRequest, err error)
|
||||||
// Get list of friend requests sent by fromUserID
|
// Get list of friend requests sent by fromUserID
|
||||||
FindFromUserID(ctx context.Context, fromUserID string, handleResults []int, pagination pagination.Pagination) (total int64, friendRequests []*model.FriendRequest, err error)
|
FindFromUserID(ctx context.Context, fromUserID string, pagination pagination.Pagination) (total int64, friendRequests []*model.FriendRequest, err error)
|
||||||
FindBothFriendRequests(ctx context.Context, fromUserID, toUserID string) (friends []*model.FriendRequest, err error)
|
FindBothFriendRequests(ctx context.Context, fromUserID, toUserID string) (friends []*model.FriendRequest, err error)
|
||||||
GetUnhandledCount(ctx context.Context, userID string, ts int64) (int64, error)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ package database
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
|
||||||
"github.com/openimsdk/tools/db/pagination"
|
"github.com/openimsdk/tools/db/pagination"
|
||||||
)
|
)
|
||||||
@@ -27,7 +26,6 @@ type GroupRequest interface {
|
|||||||
UpdateHandler(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32) (err error)
|
UpdateHandler(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32) (err error)
|
||||||
Take(ctx context.Context, groupID string, userID string) (groupRequest *model.GroupRequest, err error)
|
Take(ctx context.Context, groupID string, userID string) (groupRequest *model.GroupRequest, err error)
|
||||||
FindGroupRequests(ctx context.Context, groupID string, userIDs []string) ([]*model.GroupRequest, error)
|
FindGroupRequests(ctx context.Context, groupID string, userIDs []string) ([]*model.GroupRequest, error)
|
||||||
Page(ctx context.Context, userID string, groupIDs []string, handleResults []int, pagination pagination.Pagination) (total int64, groups []*model.GroupRequest, err error)
|
Page(ctx context.Context, userID string, pagination pagination.Pagination) (total int64, groups []*model.GroupRequest, err error)
|
||||||
PageGroup(ctx context.Context, groupIDs []string, handleResults []int, pagination pagination.Pagination) (total int64, groups []*model.GroupRequest, err error)
|
PageGroup(ctx context.Context, groupIDs []string, pagination pagination.Pagination) (total int64, groups []*model.GroupRequest, err error)
|
||||||
GetUnhandledCount(ctx context.Context, groupIDs []string, ts int64) (int64, error)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,35 +16,24 @@ package mgo
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"time"
|
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/mongo/options"
|
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
|
||||||
|
|
||||||
"github.com/openimsdk/tools/db/mongoutil"
|
"github.com/openimsdk/tools/db/mongoutil"
|
||||||
"github.com/openimsdk/tools/db/pagination"
|
"github.com/openimsdk/tools/db/pagination"
|
||||||
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
|
"go.mongodb.org/mongo-driver/mongo/options"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewFriendRequestMongo(db *mongo.Database) (database.FriendRequest, error) {
|
func NewFriendRequestMongo(db *mongo.Database) (database.FriendRequest, error) {
|
||||||
coll := db.Collection(database.FriendRequestName)
|
coll := db.Collection(database.FriendRequestName)
|
||||||
_, err := coll.Indexes().CreateMany(context.Background(), []mongo.IndexModel{
|
_, err := coll.Indexes().CreateOne(context.Background(), mongo.IndexModel{
|
||||||
{
|
Keys: bson.D{
|
||||||
Keys: bson.D{
|
{Key: "from_user_id", Value: 1},
|
||||||
{Key: "from_user_id", Value: 1},
|
{Key: "to_user_id", Value: 1},
|
||||||
{Key: "to_user_id", Value: 1},
|
|
||||||
},
|
|
||||||
Options: options.Index().SetUnique(true),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Keys: bson.D{
|
|
||||||
{Key: "create_time", Value: -1},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
Options: options.Index().SetUnique(true),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -56,24 +45,12 @@ type FriendRequestMgo struct {
|
|||||||
coll *mongo.Collection
|
coll *mongo.Collection
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FriendRequestMgo) sort() any {
|
func (f *FriendRequestMgo) FindToUserID(ctx context.Context, toUserID string, pagination pagination.Pagination) (total int64, friendRequests []*model.FriendRequest, err error) {
|
||||||
return bson.D{{Key: "create_time", Value: -1}}
|
return mongoutil.FindPage[*model.FriendRequest](ctx, f.coll, bson.M{"to_user_id": toUserID}, pagination)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FriendRequestMgo) FindToUserID(ctx context.Context, toUserID string, handleResults []int, pagination pagination.Pagination) (total int64, friendRequests []*model.FriendRequest, err error) {
|
func (f *FriendRequestMgo) FindFromUserID(ctx context.Context, fromUserID string, pagination pagination.Pagination) (total int64, friendRequests []*model.FriendRequest, err error) {
|
||||||
filter := bson.M{"to_user_id": toUserID}
|
return mongoutil.FindPage[*model.FriendRequest](ctx, f.coll, bson.M{"from_user_id": fromUserID}, pagination)
|
||||||
if len(handleResults) > 0 {
|
|
||||||
filter["handle_result"] = bson.M{"$in": handleResults}
|
|
||||||
}
|
|
||||||
return mongoutil.FindPage[*model.FriendRequest](ctx, f.coll, filter, pagination, options.Find().SetSort(f.sort()))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *FriendRequestMgo) FindFromUserID(ctx context.Context, fromUserID string, handleResults []int, pagination pagination.Pagination) (total int64, friendRequests []*model.FriendRequest, err error) {
|
|
||||||
filter := bson.M{"from_user_id": fromUserID}
|
|
||||||
if len(handleResults) > 0 {
|
|
||||||
filter["handle_result"] = bson.M{"$in": handleResults}
|
|
||||||
}
|
|
||||||
return mongoutil.FindPage[*model.FriendRequest](ctx, f.coll, filter, pagination, options.Find().SetSort(f.sort()))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FriendRequestMgo) FindBothFriendRequests(ctx context.Context, fromUserID, toUserID string) (friends []*model.FriendRequest, err error) {
|
func (f *FriendRequestMgo) FindBothFriendRequests(ctx context.Context, fromUserID, toUserID string) (friends []*model.FriendRequest, err error) {
|
||||||
@@ -133,11 +110,3 @@ func (f *FriendRequestMgo) Find(ctx context.Context, fromUserID, toUserID string
|
|||||||
func (f *FriendRequestMgo) Take(ctx context.Context, fromUserID, toUserID string) (friendRequest *model.FriendRequest, err error) {
|
func (f *FriendRequestMgo) Take(ctx context.Context, fromUserID, toUserID string) (friendRequest *model.FriendRequest, err error) {
|
||||||
return f.Find(ctx, fromUserID, toUserID)
|
return f.Find(ctx, fromUserID, toUserID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FriendRequestMgo) GetUnhandledCount(ctx context.Context, userID string, ts int64) (int64, error) {
|
|
||||||
filter := bson.M{"to_user_id": userID, "handle_result": 0}
|
|
||||||
if ts != 0 {
|
|
||||||
filter["create_time"] = bson.M{"$gt": time.UnixMilli(ts)}
|
|
||||||
}
|
|
||||||
return mongoutil.Count(ctx, f.coll, filter)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -16,36 +16,25 @@ package mgo
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
|
||||||
"github.com/openimsdk/tools/utils/datautil"
|
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
|
||||||
"go.mongodb.org/mongo-driver/mongo/options"
|
|
||||||
|
|
||||||
"github.com/openimsdk/tools/db/mongoutil"
|
"github.com/openimsdk/tools/db/mongoutil"
|
||||||
"github.com/openimsdk/tools/db/pagination"
|
"github.com/openimsdk/tools/db/pagination"
|
||||||
"github.com/openimsdk/tools/errs"
|
"github.com/openimsdk/tools/errs"
|
||||||
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
|
"go.mongodb.org/mongo-driver/mongo/options"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewGroupRequestMgo(db *mongo.Database) (database.GroupRequest, error) {
|
func NewGroupRequestMgo(db *mongo.Database) (database.GroupRequest, error) {
|
||||||
coll := db.Collection(database.GroupRequestName)
|
coll := db.Collection(database.GroupRequestName)
|
||||||
_, err := coll.Indexes().CreateMany(context.Background(), []mongo.IndexModel{
|
_, err := coll.Indexes().CreateOne(context.Background(), mongo.IndexModel{
|
||||||
{
|
Keys: bson.D{
|
||||||
Keys: bson.D{
|
{Key: "group_id", Value: 1},
|
||||||
{Key: "group_id", Value: 1},
|
{Key: "user_id", Value: 1},
|
||||||
{Key: "user_id", Value: 1},
|
|
||||||
},
|
|
||||||
Options: options.Index().SetUnique(true),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Keys: bson.D{
|
|
||||||
{Key: "req_time", Value: -1},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
Options: options.Index().SetUnique(true),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errs.Wrap(err)
|
return nil, errs.Wrap(err)
|
||||||
@@ -77,39 +66,10 @@ func (g *GroupRequestMgo) FindGroupRequests(ctx context.Context, groupID string,
|
|||||||
return mongoutil.Find[*model.GroupRequest](ctx, g.coll, bson.M{"group_id": groupID, "user_id": bson.M{"$in": userIDs}})
|
return mongoutil.Find[*model.GroupRequest](ctx, g.coll, bson.M{"group_id": groupID, "user_id": bson.M{"$in": userIDs}})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupRequestMgo) sort() any {
|
func (g *GroupRequestMgo) Page(ctx context.Context, userID string, pagination pagination.Pagination) (total int64, groups []*model.GroupRequest, err error) {
|
||||||
return bson.D{{Key: "req_time", Value: -1}}
|
return mongoutil.FindPage[*model.GroupRequest](ctx, g.coll, bson.M{"user_id": userID}, pagination)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupRequestMgo) Page(ctx context.Context, userID string, groupIDs []string, handleResults []int, pagination pagination.Pagination) (total int64, groups []*model.GroupRequest, err error) {
|
func (g *GroupRequestMgo) PageGroup(ctx context.Context, groupIDs []string, pagination pagination.Pagination) (total int64, groups []*model.GroupRequest, err error) {
|
||||||
filter := bson.M{"user_id": userID}
|
return mongoutil.FindPage[*model.GroupRequest](ctx, g.coll, bson.M{"group_id": bson.M{"$in": groupIDs}}, pagination)
|
||||||
if len(groupIDs) > 0 {
|
|
||||||
filter["group_id"] = bson.M{"$in": datautil.Distinct(groupIDs)}
|
|
||||||
}
|
|
||||||
if len(handleResults) > 0 {
|
|
||||||
filter["handle_result"] = bson.M{"$in": handleResults}
|
|
||||||
}
|
|
||||||
return mongoutil.FindPage[*model.GroupRequest](ctx, g.coll, filter, pagination, options.Find().SetSort(g.sort()))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *GroupRequestMgo) PageGroup(ctx context.Context, groupIDs []string, handleResults []int, pagination pagination.Pagination) (total int64, groups []*model.GroupRequest, err error) {
|
|
||||||
if len(groupIDs) == 0 {
|
|
||||||
return 0, nil, nil
|
|
||||||
}
|
|
||||||
filter := bson.M{"group_id": bson.M{"$in": groupIDs}}
|
|
||||||
if len(handleResults) > 0 {
|
|
||||||
filter["handle_result"] = bson.M{"$in": handleResults}
|
|
||||||
}
|
|
||||||
return mongoutil.FindPage[*model.GroupRequest](ctx, g.coll, filter, pagination, options.Find().SetSort(g.sort()))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *GroupRequestMgo) GetUnhandledCount(ctx context.Context, groupIDs []string, ts int64) (int64, error) {
|
|
||||||
if len(groupIDs) == 0 {
|
|
||||||
return 0, nil
|
|
||||||
}
|
|
||||||
filter := bson.M{"group_id": bson.M{"$in": groupIDs}, "handle_result": 0}
|
|
||||||
if ts != 0 {
|
|
||||||
filter["req_time"] = bson.M{"$gt": time.UnixMilli(ts)}
|
|
||||||
}
|
|
||||||
return mongoutil.Count(ctx, g.coll, filter)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
|
||||||
"go.mongodb.org/mongo-driver/mongo/options"
|
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
|
||||||
"github.com/openimsdk/protocol/constant"
|
"github.com/openimsdk/protocol/constant"
|
||||||
@@ -19,6 +14,10 @@ import (
|
|||||||
"github.com/openimsdk/tools/errs"
|
"github.com/openimsdk/tools/errs"
|
||||||
"github.com/openimsdk/tools/utils/datautil"
|
"github.com/openimsdk/tools/utils/datautil"
|
||||||
"github.com/openimsdk/tools/utils/jsonutil"
|
"github.com/openimsdk/tools/utils/jsonutil"
|
||||||
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
|
"go.mongodb.org/mongo-driver/mongo/options"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewMsgMongo(db *mongo.Database) (database.Msg, error) {
|
func NewMsgMongo(db *mongo.Database) (database.Msg, error) {
|
||||||
@@ -1150,7 +1149,7 @@ func (m *MsgMgo) findBeforeDocSendTime(ctx context.Context, docID string, limit
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, 0, err
|
return 0, 0, err
|
||||||
}
|
}
|
||||||
for i := len(res) - 1; i >= 0; i-- {
|
for i := len(res) - 1; i > 0; i-- {
|
||||||
v := res[i]
|
v := res[i]
|
||||||
if v.Msgs != nil && v.Msgs.Msg != nil && v.Msgs.Msg.SendTime > 0 {
|
if v.Msgs != nil && v.Msgs.Msg != nil && v.Msgs.Msg.SendTime > 0 {
|
||||||
return v.Msgs.Msg.Seq, v.Msgs.Msg.SendTime, nil
|
return v.Msgs.Msg.Seq, v.Msgs.Msg.SendTime, nil
|
||||||
@@ -1165,7 +1164,7 @@ func (m *MsgMgo) findBeforeSendTime(ctx context.Context, conversationID string,
|
|||||||
limit := int64(-1)
|
limit := int64(-1)
|
||||||
if first {
|
if first {
|
||||||
first = false
|
first = false
|
||||||
limit = m.model.GetLimitForSingleDoc(seq)
|
limit = m.model.GetMsgIndex(seq)
|
||||||
}
|
}
|
||||||
docID := m.model.BuildDocIDByIndex(conversationID, i)
|
docID := m.model.BuildDocIDByIndex(conversationID, i)
|
||||||
msgSeq, msgSendTime, err := m.findBeforeDocSendTime(ctx, docID, limit)
|
msgSeq, msgSendTime, err := m.findBeforeDocSendTime(ctx, docID, limit)
|
||||||
|
|||||||
@@ -120,11 +120,15 @@ func (m *MsgDocModel) GetDocID(conversationID string, seq int64) string {
|
|||||||
|
|
||||||
func (m *MsgDocModel) GetDocIDSeqsMap(conversationID string, seqs []int64) map[string][]int64 {
|
func (m *MsgDocModel) GetDocIDSeqsMap(conversationID string, seqs []int64) map[string][]int64 {
|
||||||
t := make(map[string][]int64)
|
t := make(map[string][]int64)
|
||||||
for _, seq := range seqs {
|
for i := 0; i < len(seqs); i++ {
|
||||||
docID := m.GetDocID(conversationID, seq)
|
docID := m.GetDocID(conversationID, seqs[i])
|
||||||
t[docID] = append(t[docID], seq)
|
if value, ok := t[docID]; !ok {
|
||||||
|
var temp []int64
|
||||||
|
t[docID] = append(temp, seqs[i])
|
||||||
|
} else {
|
||||||
|
t[docID] = append(value, seqs[i])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,10 +136,6 @@ func (*MsgDocModel) GetMsgIndex(seq int64) int64 {
|
|||||||
return (seq - 1) % singleGocMsgNum
|
return (seq - 1) % singleGocMsgNum
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*MsgDocModel) GetLimitForSingleDoc(seq int64) int64 {
|
|
||||||
return seq % singleGocMsgNum
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*MsgDocModel) indexGen(conversationID string, seqSuffix int64) string {
|
func (*MsgDocModel) indexGen(conversationID string, seqSuffix int64) string {
|
||||||
return conversationID + ":" + strconv.FormatInt(seqSuffix, 10)
|
return conversationID + ":" + strconv.FormatInt(seqSuffix, 10)
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-14
@@ -49,7 +49,7 @@ func New[V any](opts ...Option) Cache[V] {
|
|||||||
if opt.expirationEvict {
|
if opt.expirationEvict {
|
||||||
return lru.NewExpirationLRU[string, V](opt.localSlotSize, opt.localSuccessTTL, opt.localFailedTTL, opt.target, c.onEvict)
|
return lru.NewExpirationLRU[string, V](opt.localSlotSize, opt.localSuccessTTL, opt.localFailedTTL, opt.target, c.onEvict)
|
||||||
} else {
|
} else {
|
||||||
return lru.NewLazyLRU[string, V](opt.localSlotSize, opt.localSuccessTTL, opt.localFailedTTL, opt.target, c.onEvict)
|
return lru.NewLayLRU[string, V](opt.localSlotSize, opt.localSuccessTTL, opt.localFailedTTL, opt.target, c.onEvict)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if opt.localSlotNum == 1 {
|
if opt.localSlotNum == 1 {
|
||||||
@@ -72,18 +72,11 @@ type cache[V any] struct {
|
|||||||
|
|
||||||
func (c *cache[V]) onEvict(key string, value V) {
|
func (c *cache[V]) onEvict(key string, value V) {
|
||||||
if c.link != nil {
|
if c.link != nil {
|
||||||
// Do not delete other keys while the underlying LRU still holds its lock;
|
lks := c.link.Del(key)
|
||||||
// defer linked deletions to avoid re-entering the same slot and deadlocking.
|
for k := range lks {
|
||||||
if lks := c.link.Del(key); len(lks) > 0 {
|
if key != k { // prevent deadlock
|
||||||
go c.delLinked(key, lks)
|
c.local.Del(k)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *cache[V]) delLinked(src string, keys map[string]struct{}) {
|
|
||||||
for k := range keys {
|
|
||||||
if src != k {
|
|
||||||
c.local.Del(k)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,7 +103,7 @@ func (c *cache[V]) Get(ctx context.Context, key string, fetch func(ctx context.C
|
|||||||
func (c *cache[V]) GetLink(ctx context.Context, key string, fetch func(ctx context.Context) (V, error), link ...string) (V, error) {
|
func (c *cache[V]) GetLink(ctx context.Context, key string, fetch func(ctx context.Context) (V, error), link ...string) (V, error) {
|
||||||
if c.local != nil {
|
if c.local != nil {
|
||||||
return c.local.Get(key, func() (V, error) {
|
return c.local.Get(key, func() (V, error) {
|
||||||
if len(link) > 0 && c.link != nil {
|
if len(link) > 0 {
|
||||||
c.link.Link(key, link...)
|
c.link.Link(key, link...)
|
||||||
}
|
}
|
||||||
return fetch(ctx)
|
return fetch(ctx)
|
||||||
|
|||||||
@@ -22,8 +22,6 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/localcache/lru"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestName(t *testing.T) {
|
func TestName(t *testing.T) {
|
||||||
@@ -93,68 +91,3 @@ func TestName(t *testing.T) {
|
|||||||
t.Log("del", del.Load())
|
t.Log("del", del.Load())
|
||||||
// 137.35s
|
// 137.35s
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test deadlock scenario when eviction callback deletes a linked key that hashes to the same slot.
|
|
||||||
func TestCacheEvictDeadlock(t *testing.T) {
|
|
||||||
ctx := context.Background()
|
|
||||||
c := New[string](WithLocalSlotNum(1), WithLocalSlotSize(1), WithLazy())
|
|
||||||
|
|
||||||
if _, err := c.GetLink(ctx, "k1", func(ctx context.Context) (string, error) {
|
|
||||||
return "v1", nil
|
|
||||||
}, "k2"); err != nil {
|
|
||||||
t.Fatalf("seed cache failed: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
done := make(chan struct{})
|
|
||||||
go func() {
|
|
||||||
defer close(done)
|
|
||||||
_, _ = c.GetLink(ctx, "k2", func(ctx context.Context) (string, error) {
|
|
||||||
return "v2", nil
|
|
||||||
}, "k1")
|
|
||||||
}()
|
|
||||||
|
|
||||||
select {
|
|
||||||
case <-done:
|
|
||||||
// expected to finish quickly; current implementation deadlocks here.
|
|
||||||
case <-time.After(time.Second):
|
|
||||||
t.Fatal("GetLink deadlocked during eviction of linked key")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestExpirationLRUGetBatch(t *testing.T) {
|
|
||||||
l := lru.NewExpirationLRU[string, string](2, time.Minute, time.Second*5, EmptyTarget{}, nil)
|
|
||||||
|
|
||||||
keys := []string{"a", "b"}
|
|
||||||
values, err := l.GetBatch(keys, func(keys []string) (map[string]string, error) {
|
|
||||||
res := make(map[string]string)
|
|
||||||
for _, k := range keys {
|
|
||||||
res[k] = k + "_v"
|
|
||||||
}
|
|
||||||
return res, nil
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unexpected error: %v", err)
|
|
||||||
}
|
|
||||||
if len(values) != len(keys) {
|
|
||||||
t.Fatalf("expected %d values, got %d", len(keys), len(values))
|
|
||||||
}
|
|
||||||
for _, k := range keys {
|
|
||||||
if v, ok := values[k]; !ok || v != k+"_v" {
|
|
||||||
t.Fatalf("unexpected value for %s: %q, ok=%v", k, v, ok)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// second batch should hit cache
|
|
||||||
values, err = l.GetBatch(keys, func(keys []string) (map[string]string, error) {
|
|
||||||
t.Fatalf("should not fetch on cache hit")
|
|
||||||
return nil, nil
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unexpected error on cache hit: %v", err)
|
|
||||||
}
|
|
||||||
for _, k := range keys {
|
|
||||||
if v, ok := values[k]; !ok || v != k+"_v" {
|
|
||||||
t.Fatalf("unexpected cached value for %s: %q, ok=%v", k, v, ok)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -52,53 +52,8 @@ type ExpirationLRU[K comparable, V any] struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (x *ExpirationLRU[K, V]) GetBatch(keys []K, fetch func(keys []K) (map[K]V, error)) (map[K]V, error) {
|
func (x *ExpirationLRU[K, V]) GetBatch(keys []K, fetch func(keys []K) (map[K]V, error)) (map[K]V, error) {
|
||||||
var (
|
//TODO implement me
|
||||||
err error
|
panic("implement me")
|
||||||
results = make(map[K]V)
|
|
||||||
misses = make([]K, 0, len(keys))
|
|
||||||
)
|
|
||||||
|
|
||||||
for _, key := range keys {
|
|
||||||
x.lock.Lock()
|
|
||||||
v, ok := x.core.Get(key)
|
|
||||||
x.lock.Unlock()
|
|
||||||
if ok {
|
|
||||||
x.target.IncrGetHit()
|
|
||||||
v.lock.RLock()
|
|
||||||
results[key] = v.value
|
|
||||||
if v.err != nil && err == nil {
|
|
||||||
err = v.err
|
|
||||||
}
|
|
||||||
v.lock.RUnlock()
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
misses = append(misses, key)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(misses) == 0 {
|
|
||||||
return results, err
|
|
||||||
}
|
|
||||||
|
|
||||||
fetchValues, fetchErr := fetch(misses)
|
|
||||||
if fetchErr != nil && err == nil {
|
|
||||||
err = fetchErr
|
|
||||||
}
|
|
||||||
|
|
||||||
for key, val := range fetchValues {
|
|
||||||
results[key] = val
|
|
||||||
if fetchErr != nil {
|
|
||||||
x.target.IncrGetFailed()
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
x.target.IncrGetSuccess()
|
|
||||||
item := &expirationLruItem[V]{value: val}
|
|
||||||
x.lock.Lock()
|
|
||||||
x.core.Add(key, item)
|
|
||||||
x.lock.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
// any keys not returned from fetch remain absent (no cache write)
|
|
||||||
return results, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *ExpirationLRU[K, V]) Get(key K, fetch func() (V, error)) (V, error) {
|
func (x *ExpirationLRU[K, V]) Get(key K, fetch func() (V, error)) (V, error) {
|
||||||
|
|||||||
@@ -21,25 +21,25 @@ import (
|
|||||||
"github.com/hashicorp/golang-lru/v2/simplelru"
|
"github.com/hashicorp/golang-lru/v2/simplelru"
|
||||||
)
|
)
|
||||||
|
|
||||||
type lazyLruItem[V any] struct {
|
type layLruItem[V any] struct {
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
expires int64
|
expires int64
|
||||||
err error
|
err error
|
||||||
value V
|
value V
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLazyLRU[K comparable, V any](size int, successTTL, failedTTL time.Duration, target Target, onEvict EvictCallback[K, V]) *LazyLRU[K, V] {
|
func NewLayLRU[K comparable, V any](size int, successTTL, failedTTL time.Duration, target Target, onEvict EvictCallback[K, V]) *LayLRU[K, V] {
|
||||||
var cb simplelru.EvictCallback[K, *lazyLruItem[V]]
|
var cb simplelru.EvictCallback[K, *layLruItem[V]]
|
||||||
if onEvict != nil {
|
if onEvict != nil {
|
||||||
cb = func(key K, value *lazyLruItem[V]) {
|
cb = func(key K, value *layLruItem[V]) {
|
||||||
onEvict(key, value.value)
|
onEvict(key, value.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
core, err := simplelru.NewLRU[K, *lazyLruItem[V]](size, cb)
|
core, err := simplelru.NewLRU[K, *layLruItem[V]](size, cb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
return &LazyLRU[K, V]{
|
return &LayLRU[K, V]{
|
||||||
core: core,
|
core: core,
|
||||||
successTTL: successTTL,
|
successTTL: successTTL,
|
||||||
failedTTL: failedTTL,
|
failedTTL: failedTTL,
|
||||||
@@ -47,15 +47,15 @@ func NewLazyLRU[K comparable, V any](size int, successTTL, failedTTL time.Durati
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type LazyLRU[K comparable, V any] struct {
|
type LayLRU[K comparable, V any] struct {
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
core *simplelru.LRU[K, *lazyLruItem[V]]
|
core *simplelru.LRU[K, *layLruItem[V]]
|
||||||
successTTL time.Duration
|
successTTL time.Duration
|
||||||
failedTTL time.Duration
|
failedTTL time.Duration
|
||||||
target Target
|
target Target
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *LazyLRU[K, V]) Get(key K, fetch func() (V, error)) (V, error) {
|
func (x *LayLRU[K, V]) Get(key K, fetch func() (V, error)) (V, error) {
|
||||||
x.lock.Lock()
|
x.lock.Lock()
|
||||||
v, ok := x.core.Get(key)
|
v, ok := x.core.Get(key)
|
||||||
if ok {
|
if ok {
|
||||||
@@ -68,7 +68,7 @@ func (x *LazyLRU[K, V]) Get(key K, fetch func() (V, error)) (V, error) {
|
|||||||
return value, err
|
return value, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
v = &lazyLruItem[V]{}
|
v = &layLruItem[V]{}
|
||||||
x.core.Add(key, v)
|
x.core.Add(key, v)
|
||||||
v.lock.Lock()
|
v.lock.Lock()
|
||||||
x.lock.Unlock()
|
x.lock.Unlock()
|
||||||
@@ -88,15 +88,15 @@ func (x *LazyLRU[K, V]) Get(key K, fetch func() (V, error)) (V, error) {
|
|||||||
return v.value, v.err
|
return v.value, v.err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *LazyLRU[K, V]) GetBatch(keys []K, fetch func(keys []K) (map[K]V, error)) (map[K]V, error) {
|
func (x *LayLRU[K, V]) GetBatch(keys []K, fetch func(keys []K) (map[K]V, error)) (map[K]V, error) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
once sync.Once
|
once sync.Once
|
||||||
)
|
)
|
||||||
|
|
||||||
res := make(map[K]V)
|
res := make(map[K]V)
|
||||||
queries := make([]K, 0, len(keys))
|
queries := make([]K, 0)
|
||||||
|
setVs := make(map[K]*layLruItem[V])
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
x.lock.Lock()
|
x.lock.Lock()
|
||||||
v, ok := x.core.Get(key)
|
v, ok := x.core.Get(key)
|
||||||
@@ -118,20 +118,14 @@ func (x *LazyLRU[K, V]) GetBatch(keys []K, fetch func(keys []K) (map[K]V, error)
|
|||||||
}
|
}
|
||||||
queries = append(queries, key)
|
queries = append(queries, key)
|
||||||
}
|
}
|
||||||
|
values, err1 := fetch(queries)
|
||||||
if len(queries) == 0 {
|
if err1 != nil {
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|
||||||
values, fetchErr := fetch(queries)
|
|
||||||
if fetchErr != nil {
|
|
||||||
once.Do(func() {
|
once.Do(func() {
|
||||||
err = fetchErr
|
err = err1
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, val := range values {
|
for key, val := range values {
|
||||||
v := &lazyLruItem[V]{}
|
v := &layLruItem[V]{}
|
||||||
v.value = val
|
v.value = val
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -141,7 +135,7 @@ func (x *LazyLRU[K, V]) GetBatch(keys []K, fetch func(keys []K) (map[K]V, error)
|
|||||||
v.expires = time.Now().Add(x.failedTTL).UnixMilli()
|
v.expires = time.Now().Add(x.failedTTL).UnixMilli()
|
||||||
x.target.IncrGetFailed()
|
x.target.IncrGetFailed()
|
||||||
}
|
}
|
||||||
|
setVs[key] = v
|
||||||
x.lock.Lock()
|
x.lock.Lock()
|
||||||
x.core.Add(key, v)
|
x.core.Add(key, v)
|
||||||
x.lock.Unlock()
|
x.lock.Unlock()
|
||||||
@@ -151,29 +145,29 @@ func (x *LazyLRU[K, V]) GetBatch(keys []K, fetch func(keys []K) (map[K]V, error)
|
|||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
//func (x *LazyLRU[K, V]) Has(key K) bool {
|
//func (x *LayLRU[K, V]) Has(key K) bool {
|
||||||
// x.lock.Lock()
|
// x.lock.Lock()
|
||||||
// defer x.lock.Unlock()
|
// defer x.lock.Unlock()
|
||||||
// return x.core.Contains(key)
|
// return x.core.Contains(key)
|
||||||
//}
|
//}
|
||||||
|
|
||||||
func (x *LazyLRU[K, V]) Set(key K, value V) {
|
func (x *LayLRU[K, V]) Set(key K, value V) {
|
||||||
x.lock.Lock()
|
x.lock.Lock()
|
||||||
defer x.lock.Unlock()
|
defer x.lock.Unlock()
|
||||||
x.core.Add(key, &lazyLruItem[V]{value: value, expires: time.Now().Add(x.successTTL).UnixMilli()})
|
x.core.Add(key, &layLruItem[V]{value: value, expires: time.Now().Add(x.successTTL).UnixMilli()})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *LazyLRU[K, V]) SetHas(key K, value V) bool {
|
func (x *LayLRU[K, V]) SetHas(key K, value V) bool {
|
||||||
x.lock.Lock()
|
x.lock.Lock()
|
||||||
defer x.lock.Unlock()
|
defer x.lock.Unlock()
|
||||||
if x.core.Contains(key) {
|
if x.core.Contains(key) {
|
||||||
x.core.Add(key, &lazyLruItem[V]{value: value, expires: time.Now().Add(x.successTTL).UnixMilli()})
|
x.core.Add(key, &layLruItem[V]{value: value, expires: time.Now().Add(x.successTTL).UnixMilli()})
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *LazyLRU[K, V]) Del(key K) bool {
|
func (x *LayLRU[K, V]) Del(key K) bool {
|
||||||
x.lock.Lock()
|
x.lock.Lock()
|
||||||
ok := x.core.Remove(key)
|
ok := x.core.Remove(key)
|
||||||
x.lock.Unlock()
|
x.lock.Unlock()
|
||||||
@@ -185,6 +179,6 @@ func (x *LazyLRU[K, V]) Del(key K) bool {
|
|||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *LazyLRU[K, V]) Stop() {
|
func (x *LayLRU[K, V]) Stop() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ func GetConversationIDBySessionType(sessionType int, ids ...string) string {
|
|||||||
case constant.ReadGroupChatType:
|
case constant.ReadGroupChatType:
|
||||||
return "sg_" + ids[0] // super group chat
|
return "sg_" + ids[0] // super group chat
|
||||||
case constant.NotificationChatType:
|
case constant.NotificationChatType:
|
||||||
return "sn_" + strings.Join(ids, "_") // server notification chat
|
return "sn_" + ids[0] // server notification chat
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,16 +3,15 @@ package rpccache
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
||||||
|
"github.com/openimsdk/protocol/constant"
|
||||||
|
"github.com/openimsdk/protocol/user"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
|
||||||
"github.com/openimsdk/protocol/constant"
|
|
||||||
"github.com/openimsdk/protocol/user"
|
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/cachekey"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/cachekey"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/localcache"
|
"github.com/openimsdk/open-im-server/v3/pkg/localcache"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/localcache/lru"
|
"github.com/openimsdk/open-im-server/v3/pkg/localcache/lru"
|
||||||
@@ -47,7 +46,7 @@ func NewOnlineCache(client *rpcli.UserClient, group *GroupLocalCache, rdb redis.
|
|||||||
case false:
|
case false:
|
||||||
log.ZDebug(ctx, "fullUserCache is false")
|
log.ZDebug(ctx, "fullUserCache is false")
|
||||||
x.lruCache = lru.NewSlotLRU(1024, localcache.LRUStringHash, func() lru.LRU[string, []int32] {
|
x.lruCache = lru.NewSlotLRU(1024, localcache.LRUStringHash, func() lru.LRU[string, []int32] {
|
||||||
return lru.NewLazyLRU[string, []int32](2048, cachekey.OnlineExpire/2, time.Second*3, localcache.EmptyTarget{}, func(key string, value []int32) {})
|
return lru.NewLayLRU[string, []int32](2048, cachekey.OnlineExpire/2, time.Second*3, localcache.EmptyTarget{}, func(key string, value []int32) {})
|
||||||
})
|
})
|
||||||
x.CurrentPhase.Store(DoSubscribeOver)
|
x.CurrentPhase.Store(DoSubscribeOver)
|
||||||
x.Cond.Broadcast()
|
x.Cond.Broadcast()
|
||||||
|
|||||||
+1
-3
@@ -2,11 +2,9 @@ package rpcli
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
|
|
||||||
"github.com/openimsdk/protocol/msg"
|
"github.com/openimsdk/protocol/msg"
|
||||||
"github.com/openimsdk/protocol/sdkws"
|
"github.com/openimsdk/protocol/sdkws"
|
||||||
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewMsgClient(cc grpc.ClientConnInterface) *MsgClient {
|
func NewMsgClient(cc grpc.ClientConnInterface) *MsgClient {
|
||||||
|
|||||||
@@ -4,11 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
"path/filepath"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/redis"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/redis"
|
||||||
@@ -24,6 +19,10 @@ import (
|
|||||||
"github.com/openimsdk/tools/s3/oss"
|
"github.com/openimsdk/tools/s3/oss"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"path/filepath"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const defaultTimeout = time.Second * 10
|
const defaultTimeout = time.Second * 10
|
||||||
@@ -160,7 +159,7 @@ func doObject(db database.ObjectInfo, newS3, oldS3 s3.Interface, skip int) (*Res
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
putURL, err := newS3.PresignedPutObject(ctx, obj.Key, time.Hour, &s3.PutOption{ContentType: obj.ContentType})
|
putURL, err := newS3.PresignedPutObject(ctx, obj.Key, time.Hour)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -177,7 +176,7 @@ func doObject(db database.ObjectInfo, newS3, oldS3 s3.Interface, skip int) (*Res
|
|||||||
return nil, fmt.Errorf("download object failed %s", downloadResp.Status)
|
return nil, fmt.Errorf("download object failed %s", downloadResp.Status)
|
||||||
}
|
}
|
||||||
log.Printf("file size %d", obj.Size)
|
log.Printf("file size %d", obj.Size)
|
||||||
request, err := http.NewRequest(http.MethodPut, putURL.URL, downloadResp.Body)
|
request, err := http.NewRequest(http.MethodPut, putURL, downloadResp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
v3.8.3-patch.15
|
v3.8.3-patch.4
|
||||||
|
|||||||
+1
-9
@@ -1,14 +1,6 @@
|
|||||||
package version
|
package version
|
||||||
|
|
||||||
import (
|
import _ "embed"
|
||||||
_ "embed"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
//go:embed version
|
//go:embed version
|
||||||
var Version string
|
var Version string
|
||||||
|
|
||||||
func init() {
|
|
||||||
Version = strings.Trim(Version, "\n")
|
|
||||||
Version = strings.TrimSpace(Version)
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user