diff --git a/apps/api/package.json b/apps/api/package.json index e4dd7160..0ae93359 100644 --- a/apps/api/package.json +++ b/apps/api/package.json @@ -38,7 +38,7 @@ "fastify": "^5.2.1", "fastify-metrics": "^12.1.0", "fastify-raw-body": "^5.0.0", - "groupmq": "1.0.0-next.15", + "groupmq": "1.0.0-next.16", "ico-to-png": "^0.2.2", "jsonwebtoken": "^9.0.2", "ramda": "^0.29.1", diff --git a/apps/worker/package.json b/apps/worker/package.json index 46a5f787..38812947 100644 --- a/apps/worker/package.json +++ b/apps/worker/package.json @@ -23,7 +23,7 @@ "@openpanel/redis": "workspace:*", "bullmq": "^5.8.7", "express": "^4.18.2", - "groupmq": "1.0.0-next.15", + "groupmq": "1.0.0-next.16", "prom-client": "^15.1.3", "ramda": "^0.29.1", "source-map-support": "^0.5.21", diff --git a/packages/queue/package.json b/packages/queue/package.json index 9ed5f45a..8f8a5f48 100644 --- a/packages/queue/package.json +++ b/packages/queue/package.json @@ -10,7 +10,7 @@ "@openpanel/logger": "workspace:*", "@openpanel/redis": "workspace:*", "bullmq": "^5.8.7", - "groupmq": "1.0.0-next.15" + "groupmq": "1.0.0-next.16" }, "devDependencies": { "@openpanel/sdk": "workspace:*", diff --git a/packages/queue/src/queues.ts b/packages/queue/src/queues.ts index 1f4cc43f..14f74871 100644 --- a/packages/queue/src/queues.ts +++ b/packages/queue/src/queues.ts @@ -107,6 +107,18 @@ export const eventsQueue = new Queue('events', { }, }); +const orderingWindowMs = Number.parseInt( + process.env.ORDERING_WINDOW_MS || '50', + 10, +); +const orderingGracePeriodDecay = Number.parseFloat( + process.env.ORDERING_GRACE_PERIOD_DECAY || '0.9', +); +const orderingMaxWaitMultiplier = Number.parseInt( + process.env.ORDERING_MAX_WAIT_MULTIPLIER || '8', + 10, +); + export const eventsGroupQueue = new GroupQueue< EventsQueuePayloadIncomingEvent['payload'] >({ @@ -114,7 +126,9 @@ export const eventsGroupQueue = new GroupQueue< namespace: 'group_events', redis: getRedisGroupQueue(), orderingMethod: 'in-memory', - orderingWindowMs: 50, + orderingWindowMs, + orderingGracePeriodDecay, + orderingMaxWaitMultiplier, keepCompleted: 10, keepFailed: 10_000, }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4b612f35..d652967b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -127,8 +127,8 @@ importers: specifier: ^5.0.0 version: 5.0.0 groupmq: - specifier: 1.0.0-next.15 - version: 1.0.0-next.15(ioredis@5.4.1) + specifier: 1.0.0-next.16 + version: 1.0.0-next.16(ioredis@5.4.1) ico-to-png: specifier: ^0.2.2 version: 0.2.2 @@ -760,8 +760,8 @@ importers: specifier: ^4.18.2 version: 4.18.2 groupmq: - specifier: 1.0.0-next.15 - version: 1.0.0-next.15(ioredis@5.4.1) + specifier: 1.0.0-next.16 + version: 1.0.0-next.16(ioredis@5.4.1) prom-client: specifier: ^15.1.3 version: 15.1.3 @@ -1224,8 +1224,8 @@ importers: specifier: ^5.8.7 version: 5.8.7 groupmq: - specifier: 1.0.0-next.15 - version: 1.0.0-next.15(ioredis@5.4.1) + specifier: 1.0.0-next.16 + version: 1.0.0-next.16(ioredis@5.4.1) devDependencies: '@openpanel/sdk': specifier: workspace:* @@ -8837,8 +8837,8 @@ packages: resolution: {integrity: sha512-5v6yZd4JK3eMI3FqqCouswVqwugaA9r4dNZB1wwcmrD02QkV5H0y7XBQW8QwQqEaZY1pM9aqORSORhJRdNK44Q==} engines: {node: '>=6.0'} - groupmq@1.0.0-next.15: - resolution: {integrity: sha512-iYOctW9kqhJroupw3tRtgfIsc0Jd4e36E7FsMHmOV35VygIDmrGi/3wZ1TCFIkxJjeaizQ6/GsNojqoBqEzFSg==} + groupmq@1.0.0-next.16: + resolution: {integrity: sha512-gcaNO0tKnHfcxMUaMh0Wk2Ljn7+VFJT8Trjyp4lrYCHDnWJDMFLOGTvd44Ar7mlzdoXDrrbPHUKs80yZqJ6Zzw==} engines: {node: '>=18'} peerDependencies: ioredis: '>=5' @@ -22060,7 +22060,7 @@ snapshots: section-matter: 1.0.0 strip-bom-string: 1.0.0 - groupmq@1.0.0-next.15(ioredis@5.4.1): + groupmq@1.0.0-next.16(ioredis@5.4.1): dependencies: cron-parser: 4.9.0 ioredis: 5.4.1