1
0
mirror of https://github.com/MisskeyIO/misskey synced 2024-11-27 06:18:40 +09:00

テストなどにKeyDBを使うように (MisskeyIO#195)

This commit is contained in:
まっちゃとーにゅ 2023-10-30 00:27:20 +09:00 committed by GitHub
parent 42bc2817be
commit db7a17d396
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 37 additions and 34 deletions

View File

@ -72,7 +72,7 @@ dbReplications: false
#───┘ Redis configuration └─────────────────────────────────────
redis:
host: redis
host: keydb
port: 6379
#family: 0 # 0=Both, 4=IPv4, 6=IPv6
#pass: example-pass
@ -80,7 +80,7 @@ redis:
#db: 1
#redisForPubsub:
# host: redis
# host: keydb
# port: 6379
# #family: 0 # 0=Both, 4=IPv4, 6=IPv6
# #pass: example-pass
@ -88,7 +88,7 @@ redis:
# #db: 1
#redisForJobQueue:
# host: redis
# host: keydb
# port: 6379
# #family: 0 # 0=Both, 4=IPv4, 6=IPv6
# #pass: example-pass

View File

@ -72,7 +72,7 @@ dbReplications: false
#───┘ Redis configuration └─────────────────────────────────────
redis:
host: redis
host: keydb
port: 6379
#family: 0 # 0=Both, 4=IPv4, 6=IPv6
#pass: example-pass
@ -80,7 +80,7 @@ redis:
#db: 1
#redisForPubsub:
# host: redis
# host: keydb
# port: 6379
# #family: 0 # 0=Both, 4=IPv4, 6=IPv6
# #pass: example-pass
@ -88,7 +88,7 @@ redis:
# #db: 1
#redisForJobQueue:
# host: redis
# host: keydb
# port: 6379
# #family: 0 # 0=Both, 4=IPv4, 6=IPv6
# #pass: example-pass

View File

@ -15,15 +15,15 @@ services:
- internal_network
- external_network
redis:
keydb:
restart: unless-stopped
image: redis:7-alpine
image: eqalpha/keydb:latest
networks:
- internal_network
volumes:
- redis-data:/data
- keydb-data:/data
healthcheck:
test: "redis-cli ping"
test: "keydb-cli ping"
interval: 5s
retries: 20
@ -45,7 +45,7 @@ services:
volumes:
postgres-data:
redis-data:
keydb-data:
networks:
internal_network:

View File

@ -11,6 +11,7 @@ docker-compose.yml
node_modules/
packages/*/node_modules
redis/
keydb/
files/
misskey-assets/
fluent-emojis/

View File

@ -17,14 +17,14 @@ jobs:
services:
postgres:
image: postgres:13
image: postgres:15
ports:
- 54312:5432
env:
POSTGRES_DB: test-misskey
POSTGRES_HOST_AUTH_METHOD: trust
redis:
image: redis:7
keydb:
image: eqalpha/keydb:latest
ports:
- 56312:6379

View File

@ -56,14 +56,14 @@ jobs:
services:
postgres:
image: postgres:13
image: postgres:15
ports:
- 54312:5432
env:
POSTGRES_DB: test-misskey
POSTGRES_HOST_AUTH_METHOD: trust
redis:
image: redis:7
keydb:
image: eqalpha/keydb:latest
ports:
- 56312:6379

2
.gitignore vendored
View File

@ -37,6 +37,7 @@ coverage
!/.config/docker_example.env
docker-compose.yml
!/.devcontainer/docker-compose.yml
!/packages/backend/test/docker-compose.yml
# misskey
/build
@ -51,6 +52,7 @@ run.bat
api-docs.json
*.log
/redis
/keydb
*.code-workspace
.DS_Store
/files

View File

@ -27,7 +27,7 @@ spec:
ports:
- containerPort: 3000
- name: postgres
image: postgres:14-alpine
image: postgres:15-alpine
env:
- name: POSTGRES_USER
value: "example-misskey-user"
@ -37,8 +37,8 @@ spec:
value: "misskey"
ports:
- containerPort: 5432
- name: redis
image: redis:alpine
- name: keydb
image: eqalpha/keydb:latest
ports:
- containerPort: 6379
volumes:

View File

@ -6,12 +6,12 @@ services:
restart: always
links:
- db
- redis
- keydb
# - meilisearch
depends_on:
db:
condition: service_healthy
redis:
keydb:
condition: service_healthy
ports:
- "3000:3000"
@ -22,15 +22,15 @@ services:
- ./files:/misskey/files
- ./.config:/misskey/.config:ro
redis:
keydb:
restart: always
image: redis:7-alpine
image: eqalpha/keydb:latest
networks:
- internal_network
volumes:
- ./redis:/data
- ./keydb:/data
healthcheck:
test: "redis-cli ping"
test: "keydb-cli ping"
interval: 5s
retries: 20

View File

@ -38,7 +38,7 @@ export class FeaturedService {
redisTransaction.expire(
`${name}:${currentWindow}`,
(windowRange * 3) / 1000,
'NX'); // "NX -- Set expiry only when the key has no expiry" = 有効期限がないときだけ設定
);
await redisTransaction.exec();
}
@ -48,10 +48,10 @@ export class FeaturedService {
const previousWindow = currentWindow - 1;
const redisPipeline = this.redisClient.pipeline();
redisPipeline.zrange(
`${name}:${currentWindow}`, 0, threshold, 'REV', 'WITHSCORES');
redisPipeline.zrange(
`${name}:${previousWindow}`, 0, threshold, 'REV', 'WITHSCORES');
redisPipeline.zrevrange(
`${name}:${currentWindow}`, 0, threshold, 'WITHSCORES');
redisPipeline.zrevrange(
`${name}:${previousWindow}`, 0, threshold, 'WITHSCORES');
const [currentRankingResult, previousRankingResult] = await redisPipeline.exec().then(result => result ? result.map(r => r[1] as string[]) : [[], []]);
const ranking = new Map<string, number>();

View File

@ -1,13 +1,13 @@
version: "3"
services:
redistest:
image: redis:7
keydbtest:
image: eqalpha/keydb:latest
ports:
- "127.0.0.1:56312:6379"
dbtest:
image: postgres:13
image: postgres:15
ports:
- "127.0.0.1:54312:5432"
environment: