feat: 2 seconds distance between requests

This commit is contained in:
Nevo David 2025-08-04 18:33:13 +07:00
parent 4978d6b975
commit 2163b59c07
1 changed files with 4 additions and 1 deletions

View File

@ -1,5 +1,6 @@
import { ioRedis } from '@gitroom/nestjs-libraries/redis/redis.service';
import Bottleneck from 'bottleneck';
import { timer } from '@gitroom/helpers/utils/timer';
const connection = new Bottleneck.IORedisConnection({
client: ioRedis,
@ -20,7 +21,9 @@ export async function concurrencyService<T>(
load = await bottleneck
.key(identifier.split('-')[0])
.schedule<T>({ expiration: 120_000 }, async () => {
return await func();
const res = await func();
await timer(2000);
return res;
});
} catch (err) {}