question-explorer-api / services /processingState.js
Eric Gardner
Initial deployment
cdc50ff
import { normalizeTitle } from '../utils/normalize.js';
// In-memory map for processing status
// In production, this would be Redis or similar
const processingState = new Map();
// States: 'processing' | 'ready' | 'error'
export function setProcessing( title, state, error = null ) {
processingState.set( normalizeTitle( title ), { state, error, timestamp: Date.now() } );
}
export function getProcessingState( title ) {
return processingState.get( normalizeTitle( title ) ) || { state: 'unknown' };
}
export function clearProcessing( title ) {
processingState.delete( normalizeTitle( title ) );
}