update
This commit is contained in:
@ -5,6 +5,7 @@ import * as paths from './paths.js';
|
||||
|
||||
// Import the consolidated email config
|
||||
import type { IEmailConfig, IDomainRule } from './mail/routing/classes.email.config.js';
|
||||
import type { EmailProcessingMode } from './mail/delivery/interfaces.js';
|
||||
import { DomainRouter } from './mail/routing/classes.domain.router.js';
|
||||
import { UnifiedEmailServer } from './mail/routing/classes.unified.email.server.js';
|
||||
import { UnifiedDeliveryQueue, type IQueueOptions } from './mail/delivery/classes.delivery.queue.js';
|
||||
@ -726,4 +727,7 @@ export class DcRouter {
|
||||
}
|
||||
}
|
||||
|
||||
// Re-export types for convenience
|
||||
export type { IEmailConfig, IDomainRule, EmailProcessingMode };
|
||||
|
||||
export default DcRouter;
|
||||
|
@ -613,6 +613,12 @@ export class UnifiedDeliveryQueue extends EventEmitter {
|
||||
// Stop processing
|
||||
this.stopProcessing();
|
||||
|
||||
// Clear the check timer to prevent memory leaks
|
||||
if (this.checkTimer) {
|
||||
clearInterval(this.checkTimer);
|
||||
this.checkTimer = undefined;
|
||||
}
|
||||
|
||||
// If using disk storage, make sure all items are persisted
|
||||
if (this.options.storageType === 'disk') {
|
||||
const pendingWrites: Promise<void>[] = [];
|
||||
|
@ -146,6 +146,35 @@ export class UnifiedRateLimiter extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the rate limiter and clean up all resources
|
||||
*/
|
||||
public destroy(): void {
|
||||
// Stop the cleanup interval
|
||||
this.stop();
|
||||
|
||||
// Clear all maps to free memory
|
||||
this.counters.clear();
|
||||
this.ipCounters.clear();
|
||||
this.patternCounters.clear();
|
||||
|
||||
// Clear blocks
|
||||
if (this.config.blocks) {
|
||||
this.config.blocks = {};
|
||||
}
|
||||
|
||||
// Clear statistics
|
||||
this.stats = {
|
||||
activeCounters: 0,
|
||||
totalBlocked: 0,
|
||||
currentlyBlocked: 0,
|
||||
byPattern: {},
|
||||
byIp: {}
|
||||
};
|
||||
|
||||
logger.log('info', 'UnifiedRateLimiter destroyed');
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up expired counters and blocks
|
||||
*/
|
||||
|
Reference in New Issue
Block a user