logstack-zee
Version:
Complete Node.js logging solution with 6 integration methods, S3 bidirectional operations, advanced analytics, and multi-cloud storage support for enterprise-scale applications.
98 lines (97 loc) โข 2.41 kB
TypeScript
/**
* ๐๏ธ Log Retention Service
*
* Handles automatic cleanup of database logs and cloud storage files
* based on configured retention policies.
*/
import { Db } from 'mongodb';
import { Config } from '../types/config';
export declare class RetentionService {
private config;
private db;
private s3?;
constructor(config: Config, db: Db);
/**
* ๐งน Start automatic retention cleanup
*/
startAutomaticCleanup(): void;
/**
* ๐๏ธ Clean up database collections based on retention policy
*/
cleanupDatabase(): Promise<{
apiLogs: number;
jobs: number;
logs: number;
}>;
/**
* โ๏ธ Clean up cloud storage files based on retention policy
*/
cleanupStorage(): Promise<{
deletedFiles: number;
deletedSize: number;
}>;
/**
* ๐ฉ๏ธ Clean up S3 storage files
*/
private cleanupS3Storage;
/**
* ๐ Clean up local storage files
*/
private cleanupLocalStorage;
/**
* ๐๏ธ Setup S3 lifecycle policies for automatic archival and deletion
*/
setupS3LifecyclePolicies(): Promise<void>;
/**
* ๐ Get retention statistics
*/
getRetentionStats(): Promise<{
database: {
apiLogs: {
total: number;
oldRecords: number;
};
jobs: {
total: number;
oldRecords: number;
};
logs: {
total: number;
oldRecords: number;
};
};
storage: {
totalFiles: number;
totalSize: number;
oldFiles: number;
oldSize: number;
};
}>;
/**
* ๐ง Manual cleanup trigger
*/
runManualCleanup(options?: {
database?: boolean;
storage?: boolean;
dryRun?: boolean;
}): Promise<{
database?: {
apiLogs: number;
jobs: number;
logs: number;
};
storage?: {
deletedFiles: number;
deletedSize: number;
};
}>;
/**
* ๐ง Helper: Format bytes to human readable
*/
private formatBytes;
}
/**
* ๐ Initialize retention service
*/
export declare function initRetention(config: Config, db: Db): Promise<RetentionService>;
export default RetentionService;