Refactor: Track analysis jobs via InFlight struct
This commit replaces the disk-based `analysis_input.json` marker for in-progress analysis jobs with an in-memory `Arc<RwLock<HashSet<PathBuf>>>`. Previously, the existence of `analysis_input.json` was used as a signal that a case was queued or being analyzed. This led to stale "Queued" states after server restarts, as the disk file would persist while the server process tracking it had vanished. The new `InFlight` struct, held in `AppState`, provides a process-local marker. This ensures that: - Server restarts correctly reset the state, as the `HashSet` is cleared. - Race conditions for triggering analysis are handled by the `try_claim` method, replacing the previous reliance on file system `O_EXCL` flags. - The `AnalyzeJob` payload now travels with the job over the channel, eliminating the need for workers to re-read `analysis_input.json` from disk. This change simplifies state management and improves the reliability of analysis job tracking.
This commit is contained in:
@@ -11,9 +11,16 @@
|
||||
use std::path::Path;
|
||||
|
||||
pub use doctate_common::ONELINER_FILENAME;
|
||||
pub use doctate_server::analyze::{ANALYSIS_INPUT_FILE, DOCUMENT_FILE, Document};
|
||||
pub use doctate_server::analyze::{DOCUMENT_FILE, Document};
|
||||
pub use doctate_server::paths::CLOSE_MARKER;
|
||||
|
||||
/// Legacy filename of the per-case analysis input. The server no
|
||||
/// longer writes or reads it — the in-flight marker lives in `InFlight`
|
||||
/// and the payload travels with the `AnalyzeJob`. This constant is
|
||||
/// retained only for tests that simulate an orphan file from a
|
||||
/// pre-refactor server. New tests should not seed this file.
|
||||
pub const ANALYSIS_INPUT_FILE: &str = "analysis_input.json";
|
||||
|
||||
/// Seed a `document.json` for tests. `covered_mtime` is the RFC3339
|
||||
/// snapshot mtime the document is supposed to "cover" — for tests that
|
||||
/// don't care about the auto-trigger state machine, pass any RFC3339
|
||||
|
||||
Reference in New Issue
Block a user