feat: add image derivative worker lifecycle

Add worker-owned image derivative job execution with explicit PROCESSING, COMPLETED, and FAILED outcomes, plus tests and documentation. Verification: npm test passed 70 tests, worker tests passed 2 tests, and integration passed 14 tests. No build script is configured.
This commit is contained in:
2026-09-08 17:41:27 -04:00
parent 961ed44055
commit f1e5c98013
4 changed files with 73 additions and 2 deletions
@@ -0,0 +1,26 @@
export async function runImageDerivativeJob({ job, loadSource, processor }) {
if (!job || job.type !== 'IMAGE_DERIVATIVES') {
throw new Error('Unsupported image derivative job.');
}
const processingJob = { ...job, status: 'PROCESSING', error: null };
try {
const source = await loadSource(job.sourceKey);
const derivatives = await processor.process(source);
return {
...processingJob,
status: 'COMPLETED',
derivatives,
completedAt: new Date(),
};
} catch (error) {
return {
...processingJob,
status: 'FAILED',
error: error instanceof Error ? error.message : 'Image derivative processing failed.',
failedAt: new Date(),
};
}
}