- Remove legacy compute-worker monolith under `src/compute/`, including PDF and Whisper inference, control-plane, and runtime orchestration - Move PDF and Whisper inference logic to new `src/inference/` module - Move control-plane, orchestrator, and state machine logic to `src/operations/` - Move NATS/JetStream adapters to `src/infrastructure/` - Move job orchestration, progress, and artifact persistence to `src/jobs/` - Update imports throughout tests and main app to reference new module structure - Update Dockerfile and scripts to use new asset paths - Add new entrypoints: `src/api/app.ts` and `src/api/contracts.ts` - Remove obsolete files and update `.gitignore` for new dev artifacts This refactor modularizes the compute-worker, improving maintainability and separation of concerns. No functional changes to inference or orchestration logic. BREAKING CHANGE: compute-worker internal APIs, directory structure, and imports have changed; downstream code must update imports and integration points.
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import { describe, expect, test } from 'vitest';
|
|
import { encodeSseFrame, parseSseEventId, parseSsePayload } from '../../../src/operations/sse';
|
|
|
|
describe('sse codec', () => {
|
|
test('encodes event id and payload and decodes both reliably', () => {
|
|
const frame = encodeSseFrame({
|
|
id: 42,
|
|
event: 'snapshot',
|
|
data: { ok: true, opId: 'op-1' },
|
|
});
|
|
|
|
expect(frame).toContain('event: snapshot');
|
|
expect(parseSseEventId(frame)).toBe(42);
|
|
expect(parseSsePayload(frame)).toBe('{"ok":true,"opId":"op-1"}');
|
|
});
|
|
|
|
test('supports multiline data payload', () => {
|
|
const frame = encodeSseFrame({
|
|
id: 5,
|
|
data: 'line1\nline2',
|
|
});
|
|
|
|
expect(parseSseEventId(frame)).toBe(5);
|
|
expect(parseSsePayload(frame)).toBe('line1\nline2');
|
|
});
|
|
|
|
test('emits a retry directive when provided', () => {
|
|
const frame = encodeSseFrame({ retry: 120_000 });
|
|
expect(frame).toContain('retry: 120000');
|
|
});
|
|
|
|
test('omits retry when not finite and floors fractional values', () => {
|
|
expect(encodeSseFrame({ retry: Number.NaN })).not.toContain('retry:');
|
|
expect(encodeSseFrame({ retry: 1500.9 })).toContain('retry: 1500');
|
|
});
|
|
});
|