test
This commit is contained in:
parent
a86367bec5
commit
00b21a57d7
4 changed files with 31 additions and 21 deletions
|
|
@ -115,7 +115,16 @@ async function initializeSharedResources() {
|
||||||
ttl: PROXY_CONFIG.CACHE_TTL,
|
ttl: PROXY_CONFIG.CACHE_TTL,
|
||||||
enableMetrics: true
|
enableMetrics: true
|
||||||
});
|
});
|
||||||
await cache.waitForReady();
|
|
||||||
|
try {
|
||||||
|
// Use longer timeout for cache connection
|
||||||
|
await cache.waitForReady(30000); // 30 seconds
|
||||||
|
logger.info('Cache connection established');
|
||||||
|
} catch (error) {
|
||||||
|
logger.error('Cache connection failed, continuing with degraded functionality:', error);
|
||||||
|
// Don't throw - allow the service to continue with cache fallbacks
|
||||||
|
}
|
||||||
|
|
||||||
httpClient = new HttpClient({ timeout: 10000 }, logger);
|
httpClient = new HttpClient({ timeout: 10000 }, logger);
|
||||||
concurrencyLimit = pLimit(PROXY_CONFIG.CONCURRENCY_LIMIT);
|
concurrencyLimit = pLimit(PROXY_CONFIG.CONCURRENCY_LIMIT);
|
||||||
logger.info('Proxy tasks initialized');
|
logger.info('Proxy tasks initialized');
|
||||||
|
|
|
||||||
|
|
@ -324,7 +324,7 @@ export class BatchProcessor {
|
||||||
operation: `process-${jobNamePrefix}-batch`,
|
operation: `process-${jobNamePrefix}-batch`,
|
||||||
payload: {
|
payload: {
|
||||||
// Optimized: only store reference and metadata
|
// Optimized: only store reference and metadata
|
||||||
payloadKey: payloadKey,
|
payloadKey: this.keyPrefix + payloadKey,
|
||||||
batchIndex,
|
batchIndex,
|
||||||
total: totalBatches,
|
total: totalBatches,
|
||||||
itemCount: batchItems.length,
|
itemCount: batchItems.length,
|
||||||
|
|
|
||||||
2
libs/cache/src/connection-manager.ts
vendored
2
libs/cache/src/connection-manager.ts
vendored
|
|
@ -67,7 +67,7 @@ export class RedisConnectionManager {
|
||||||
commandTimeout: dragonflyConfig.DRAGONFLY_COMMAND_TIMEOUT,
|
commandTimeout: dragonflyConfig.DRAGONFLY_COMMAND_TIMEOUT,
|
||||||
keepAlive: dragonflyConfig.DRAGONFLY_ENABLE_KEEPALIVE ? dragonflyConfig.DRAGONFLY_KEEPALIVE_INTERVAL * 1000 : 0,
|
keepAlive: dragonflyConfig.DRAGONFLY_ENABLE_KEEPALIVE ? dragonflyConfig.DRAGONFLY_KEEPALIVE_INTERVAL * 1000 : 0,
|
||||||
connectionName: name,
|
connectionName: name,
|
||||||
lazyConnect: true,
|
lazyConnect: false, // Connect immediately instead of waiting for first command
|
||||||
...(dragonflyConfig.DRAGONFLY_TLS && {
|
...(dragonflyConfig.DRAGONFLY_TLS && {
|
||||||
tls: {
|
tls: {
|
||||||
cert: dragonflyConfig.DRAGONFLY_TLS_CERT_FILE || undefined,
|
cert: dragonflyConfig.DRAGONFLY_TLS_CERT_FILE || undefined,
|
||||||
|
|
|
||||||
37
libs/cache/src/redis-cache.ts
vendored
37
libs/cache/src/redis-cache.ts
vendored
|
|
@ -46,31 +46,32 @@ export class RedisCache implements CacheProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
private setupEventHandlers(): void {
|
private setupEventHandlers(): void {
|
||||||
this.redis.on('connect', () => {
|
// this.redis.on('connect', () => {
|
||||||
this.logger.info('Redis cache connected');
|
// this.logger.info('Redis cache connected');
|
||||||
});
|
// });
|
||||||
|
|
||||||
this.redis.on('ready', () => {
|
// this.redis.on('ready', () => {
|
||||||
this.isConnected = true;
|
// this.isConnected = true;
|
||||||
this.logger.info('Redis cache ready');
|
// this.logger.info('Redis cache ready');
|
||||||
});
|
// });
|
||||||
|
|
||||||
this.redis.on('error', (error: any) => {
|
// this.redis.on('error', (error: any) => {
|
||||||
this.isConnected = false;
|
// this.isConnected = false;
|
||||||
this.logger.error('Redis cache connection error', { error: error.message });
|
// this.logger.error('Redis cache connection error', { error: error.message });
|
||||||
});
|
// });
|
||||||
|
|
||||||
this.redis.on('close', () => {
|
// this.redis.on('close', () => {
|
||||||
this.isConnected = false;
|
// this.isConnected = false;
|
||||||
this.logger.warn('Redis cache connection closed');
|
// this.logger.warn('Redis cache connection closed');
|
||||||
});
|
// });
|
||||||
|
|
||||||
this.redis.on('reconnecting', () => {
|
// this.redis.on('reconnecting', () => {
|
||||||
this.logger.info('Redis cache reconnecting...');
|
// this.logger.info('Redis cache reconnecting...');
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
private getKey(key: string): string {
|
private getKey(key: string): string {
|
||||||
|
console.log(`Using key prefix: ${this.keyPrefix}`);
|
||||||
return `${this.keyPrefix}${key}`;
|
return `${this.keyPrefix}${key}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue