seperating batch payload from job queue
This commit is contained in:
parent
c57733ebca
commit
b974753d8b
5 changed files with 360 additions and 25 deletions
38
libs/cache/src/providers/redis-cache.ts
vendored
38
libs/cache/src/providers/redis-cache.ts
vendored
|
|
@ -253,6 +253,44 @@ export class RedisCache implements CacheProvider {
|
|||
return this.get<number[]>(key);
|
||||
}
|
||||
|
||||
async waitForReady(timeout: number = 5000): Promise<void> {
|
||||
if (this.isConnected) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const timeoutId = setTimeout(() => {
|
||||
reject(new Error(`Redis cache connection timeout after ${timeout}ms`));
|
||||
}, timeout);
|
||||
|
||||
const onReady = () => {
|
||||
clearTimeout(timeoutId);
|
||||
this.redis.off('ready', onReady);
|
||||
this.redis.off('error', onError);
|
||||
resolve();
|
||||
};
|
||||
|
||||
const onError = (error: Error) => {
|
||||
clearTimeout(timeoutId);
|
||||
this.redis.off('ready', onReady);
|
||||
this.redis.off('error', onError);
|
||||
reject(new Error(`Redis cache connection failed: ${error.message}`));
|
||||
};
|
||||
|
||||
if (this.redis.status === 'ready') {
|
||||
clearTimeout(timeoutId);
|
||||
resolve();
|
||||
} else {
|
||||
this.redis.once('ready', onReady);
|
||||
this.redis.once('error', onError);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
isReady(): boolean {
|
||||
return this.isConnected && this.redis.status === 'ready';
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the Redis connection
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue