Skip to main content

acquire_job_singleton

Function acquire_job_singleton 

Source
pub fn acquire_job_singleton(
    job_type: JobType,
    namespace: &str,
    wait_seconds: Option<u64>,
) -> Result<File, AppError>
Expand description

Acquires a process-wide singleton lock for a heavy job type and namespace.

G28-B (v1.0.68): ensures at most one enrich, ingest --mode claude-code, or ingest --mode codex runs at a time per namespace. A second invocation in the same namespace either:

  • Returns immediately with AppError::JobSingletonLocked { job_type, namespace } when wait_seconds is None or Some(0).
  • Polls every JOB_SINGLETON_POLL_INTERVAL_MS ms until the lock drops or the deadline expires, returning the same error on timeout.

The returned File MUST be kept alive until the process exits; dropping it releases the singleton for the next invocation.