pub struct JobManager { /* private fields */ }Expand description
Manager for background jobs.
Implementations§
Source§impl JobManager
impl JobManager
Sourcepub fn spawn<F>(&self, command: String, future: F) -> JobId
pub fn spawn<F>(&self, command: String, future: F) -> JobId
Spawn a new background job from a future.
Sourcepub async fn register(&self, command: String, rx: Receiver<ExecResult>) -> JobId
pub async fn register(&self, command: String, rx: Receiver<ExecResult>) -> JobId
Spawn a job that’s already running and communicate via channel.
Sourcepub async fn register_with_streams(
&self,
command: String,
rx: Receiver<ExecResult>,
stdout: Arc<BoundedStream>,
stderr: Arc<BoundedStream>,
) -> JobId
pub async fn register_with_streams( &self, command: String, rx: Receiver<ExecResult>, stdout: Arc<BoundedStream>, stderr: Arc<BoundedStream>, ) -> JobId
Register a job with attached output streams.
The streams provide live access to job output via /v/jobs/{id}/stdout and /stderr.
Sourcepub async fn wait(&self, id: JobId) -> Option<ExecResult>
pub async fn wait(&self, id: JobId) -> Option<ExecResult>
Wait for a specific job to complete.
Sourcepub async fn wait_all(&self) -> Vec<(JobId, ExecResult)>
pub async fn wait_all(&self) -> Vec<(JobId, ExecResult)>
Wait for all jobs to complete, returning results in completion order.
Sourcepub async fn running_count(&self) -> usize
pub async fn running_count(&self) -> usize
Get the number of running jobs.
Sourcepub async fn get_command(&self, id: JobId) -> Option<String>
pub async fn get_command(&self, id: JobId) -> Option<String>
Get the command string for a job.
Sourcepub async fn get_status_string(&self, id: JobId) -> Option<String>
pub async fn get_status_string(&self, id: JobId) -> Option<String>
Get the status string for a job (for /v/jobs/{id}/status).
Sourcepub async fn read_stdout(&self, id: JobId) -> Option<Vec<u8>>
pub async fn read_stdout(&self, id: JobId) -> Option<Vec<u8>>
Read stdout stream content for a job.
Returns None if the job doesn’t exist or has no attached stream.
Sourcepub async fn read_stderr(&self, id: JobId) -> Option<Vec<u8>>
pub async fn read_stderr(&self, id: JobId) -> Option<Vec<u8>>
Read stderr stream content for a job.
Returns None if the job doesn’t exist or has no attached stream.
Sourcepub async fn register_stopped(
&self,
command: String,
pid: u32,
pgid: u32,
) -> JobId
pub async fn register_stopped( &self, command: String, pid: u32, pgid: u32, ) -> JobId
Register a stopped job (from Ctrl-Z on a foreground process).
Sourcepub async fn stop_job(&self, id: JobId, pid: u32, pgid: u32)
pub async fn stop_job(&self, id: JobId, pid: u32, pgid: u32)
Mark a job as stopped with its process info.
Sourcepub async fn resume_job(&self, id: JobId)
pub async fn resume_job(&self, id: JobId)
Mark a stopped job as resumed.
Sourcepub async fn last_stopped(&self) -> Option<JobId>
pub async fn last_stopped(&self) -> Option<JobId>
Get the most recently stopped job.