fase(8): sqlite job queue system

This commit is contained in:
debian
2026-03-05 09:44:06 -05:00
parent f01acfe985
commit 39a5e41f75
17 changed files with 819 additions and 22 deletions

View File

@@ -0,0 +1,40 @@
/**
* ReportWorker — handles 'report:generate' jobs.
* Generates reports in the background (full implementation in Phase 15).
*/
import { JobHandler } from '../JobQueue';
import { Logger } from '../../shared/infrastructure/Logger';
export const REPORT_JOB_TYPE = 'report:generate';
export interface ReportJobPayload {
reportId: string;
format: 'html' | 'pdf' | 'json';
filters?: {
sessionId?: string;
severity?: string;
fromDate?: string;
toDate?: string;
};
}
export interface ReportJobResult {
reportId: string;
filePath: string;
}
export function createReportJobHandler(deps: {
logger: Logger;
}): JobHandler<ReportJobPayload, ReportJobResult> {
return async (payload: ReportJobPayload): Promise<ReportJobResult> => {
const log = deps.logger.child({ jobType: REPORT_JOB_TYPE, reportId: payload.reportId });
log.info({ format: payload.format }, 'Report generation job executing');
// Full implementation in Phase 15 (Reporting Module)
// For now, return a placeholder result
const filePath = `./reports/${payload.reportId}.${payload.format}`;
log.info({ filePath }, 'Report job complete');
return { reportId: payload.reportId, filePath };
};
}