Job Registry and Progress
Use these steps to keep processing safe and observable.
Required Steps
- •Register every long-running job with
JobRegistry; do not bypass it. - •Offload CPU-bound encoding work with
tokio::task::spawn_blockingorblock_in_place. - •Wire cancellation via
CancellationChecker(per-job) or the global signal. - •Emit progress using
ProgressEmitterand theprocessing-progressevent.
Minimal Pattern
rust
#[tauri::command]
pub async fn process_job(
window: tauri::Window,
registry: tauri::State<'_, crate::ManagedJobRegistry>,
) -> crate::errors::Result<()> {
let (_job_id, _permit) = registry.register_job().await?;
let emitter = crate::audio::progress::ProgressEmitter::new(window);
tokio::task::spawn_blocking(move || {
// CPU-bound work here.
})
.await?;
emitter.emit_converting_progress(100.0, "completed", None, None);
Ok(())
}
Guardrails
- •Keep progress stages aligned with
ProgressEventexpectations (analyzing,converting,writing,completed,failed,cancelled). - •Ensure cancellation checks happen inside long loops to avoid delayed stop.
Codebase Pointers
- •
src-tauri/src/audio/progress/emitter.rs - •
src-tauri/src/audio/processor(encoding pipeline) - •
src-tauri/src/commands/audio.rs