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.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for JobManager
impl !RefUnwindSafe for JobManager
impl Send for JobManager
impl Sync for JobManager
impl Unpin for JobManager
impl !UnwindSafe for JobManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more