Add lock to enqueue workflow job (#16314)

- Add lock to run one enqueue job at a time. It will avoid race
conditions
- Enqueue manual workflows directly, without waiting for the job
This commit is contained in:
Thomas Trompette
2025-12-04 14:27:22 +01:00
committed by GitHub
parent 8716cb25e9
commit 4a94ad1003
7 changed files with 125 additions and 57 deletions
@@ -208,6 +208,22 @@ export class CacheStorageService {
await this.del(key);
}
async incrBy(key: string, increment: number): Promise<number> {
if (this.isRedisCache()) {
return (this.cache as RedisCache).store.client.incrBy(
this.getKey(key),
increment,
);
}
const current = (await this.get<number>(key)) ?? 0;
const newValue = current + increment;
await this.set(key, newValue);
return newValue;
}
private isRedisCache() {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return (this.cache.store as any)?.name === 'redis';