added a smart queue manager and moved proxy logic to proxy manager to make handler just schedule a call to it

This commit is contained in:
Boki 2025-06-23 10:45:06 -04:00
parent da1c52a841
commit e7c0fe2798
19 changed files with 903 additions and 231 deletions

View file

@ -40,6 +40,7 @@ export abstract class BaseHandler implements IHandler {
// Direct service properties - flattened for cleaner access
readonly logger;
readonly cache;
readonly globalCache;
readonly queue;
readonly proxy;
readonly browser;
@ -53,6 +54,7 @@ export abstract class BaseHandler implements IHandler {
// Flatten all services onto the handler instance
this.logger = getLogger(this.constructor.name);
this.cache = services.cache;
this.globalCache = services.globalCache;
this.queue = services.queue;
this.proxy = services.proxy;
this.browser = services.browser;
@ -191,7 +193,36 @@ export abstract class BaseHandler implements IHandler {
}
return this.cache.del(`cache:${this.handlerName}:${key}`);
}
/**
* Set global cache with key
*/
protected async globalCacheSet(key: string, value: any, ttl?: number): Promise<void> {
if (!this.globalCache) {
return;
}
return this.globalCache.set(key, value, ttl);
}
/**
* Get global cache with key
*/
protected async globalCacheGet<T = any>(key: string): Promise<T | null> {
if (!this.globalCache) {
return null;
}
return this.globalCache.get(key);
}
/**
* Delete global cache with key
*/
protected async globalCacheDel(key: string): Promise<void> {
if (!this.globalCache) {
return;
}
return this.globalCache.del(key);
}
/**
* Schedule operation with delay in seconds
*/