pub struct JobManager { /* private fields */ }Expand description
Manages background jobs with retry logic and persistence.
Implementations§
Source§impl JobManager
impl JobManager
Sourcepub fn enqueue(&mut self, name: impl Into<String>) -> JobRecord
pub fn enqueue(&mut self, name: impl Into<String>) -> JobRecord
Enqueues a new job and returns its record.
Sourcepub fn set_running(&mut self, id: &str)
pub fn set_running(&mut self, id: &str)
Transitions a job to running and clears its retry schedule.
Sourcepub fn update_progress(
&mut self,
id: &str,
progress: u8,
detail: Option<String>,
)
pub fn update_progress( &mut self, id: &str, progress: u8, detail: Option<String>, )
Updates a job’s progress (clamped to 100) and optional detail message.
Sourcepub fn complete(&mut self, id: &str)
pub fn complete(&mut self, id: &str)
Marks a job as completed with 100% progress and clears its retry schedule.
Sourcepub fn fail(&mut self, id: &str, detail: impl Into<String>)
pub fn fail(&mut self, id: &str, detail: impl Into<String>)
Marks a job as failed and schedules a retry if attempts remain.
Sourcepub fn pause(&mut self, id: &str, detail: Option<String>)
pub fn pause(&mut self, id: &str, detail: Option<String>)
Pauses a job, optionally updating its detail message.
Sourcepub fn resume(&mut self, id: &str, detail: Option<String>)
pub fn resume(&mut self, id: &str, detail: Option<String>)
Resumes a paused or failed job back to running status.
Sourcepub fn history(&self, id: &str) -> Vec<JobHistoryEntry>
pub fn history(&self, id: &str) -> Vec<JobHistoryEntry>
Returns the history entries for a job, or an empty vec if not found.
Sourcepub fn resume_pending(&mut self) -> Vec<JobRecord>
pub fn resume_pending(&mut self) -> Vec<JobRecord>
Resets queued or running jobs back to queued on application resume.
Sourcepub fn load_from_store(&mut self, store: &StateStore) -> Result<()>
pub fn load_from_store(&mut self, store: &StateStore) -> Result<()>
Loads jobs from the state store, deserializing extended detail when available.
Sourcepub fn persist_job(&self, store: &StateStore, id: &str) -> Result<()>
pub fn persist_job(&self, store: &StateStore, id: &str) -> Result<()>
Persists a single job’s current state to the state store.
Sourcepub fn persist_all(&self, store: &StateStore) -> Result<()>
pub fn persist_all(&self, store: &StateStore) -> Result<()>
Persists all in-memory jobs to the state store.