pub struct TaskDriver { /* private fields */ }Expand description
Manages in-flight task runs for a single camp.
Wrap in Arc to share across tasks; internal state is mutex-protected.
Implementations§
Source§impl TaskDriver
impl TaskDriver
Sourcepub async fn new(store: Arc<TaskStore>) -> Result<Self, DriverError>
pub async fn new(store: Arc<TaskStore>) -> Result<Self, DriverError>
Create a driver backed by store, with no side-channels.
Immediately scans the store for Running runs left over from a prior
daemon process and marks them Lost (“Lost-on-disappear”).
Sourcepub async fn with_channels(
store: Arc<TaskStore>,
channels: DriverChannels,
) -> Result<Self, DriverError>
pub async fn with_channels( store: Arc<TaskStore>, channels: DriverChannels, ) -> Result<Self, DriverError>
Like new but wires the optional DriverChannels side-channels
(completion notifications, live output tap).
Sourcepub async fn spawn_run(
&self,
cmd: &str,
opts: SpawnOpts,
) -> Result<TaskRunId, DriverError>
pub async fn spawn_run( &self, cmd: &str, opts: SpawnOpts, ) -> Result<TaskRunId, DriverError>
Spawn cmd in a PTY and start capturing its output. Returns immediately
with the new TaskRunId.
A beholder is selected via opts.beholder_select (default Auto). When
a Rewriter beholder matches, its adjust_argv is applied to the
command before spawning and the diff is recorded on beholder_status.
When opts.tty_attached is true, Rewriter beholders decline in
Auto mode to preserve human-readable output.
Output is written to the store as Stream::Stdout chunks (the PTY
kernel merges stdout and stderr). Signal handling and status updates
run in background tasks.
Sourcepub async fn resize_run(
&self,
id: &TaskRunId,
cols: u16,
rows: u16,
) -> Result<(), DriverError>
pub async fn resize_run( &self, id: &TaskRunId, cols: u16, rows: u16, ) -> Result<(), DriverError>
Resize a running task’s PTY and deliver SIGWINCH to the foreground
process group (portable-pty’s resize does the ioctl, which is what
signals the child).
Returns DriverError::NotFound when the run is not active on this
driver instance — the same contract as TaskDriver::send_stdin.
Sourcepub async fn kill_run(
&self,
id: &TaskRunId,
signal: Option<i32>,
) -> Result<(), DriverError>
pub async fn kill_run( &self, id: &TaskRunId, signal: Option<i32>, ) -> Result<(), DriverError>
Send signal to a running task. Defaults to SIGTERM (15).
For SIGTERM, the driver waits up to 5 seconds for the process to exit
before escalating to SIGKILL. Returns DriverError::NotFound if the
run is not active (already exited or launched on a different driver
instance).
Sourcepub async fn send_stdin(
&self,
id: &TaskRunId,
bytes: Vec<u8>,
) -> Result<(), DriverError>
pub async fn send_stdin( &self, id: &TaskRunId, bytes: Vec<u8>, ) -> Result<(), DriverError>
Write bytes to the stdin of a running task (requires stdin_enabled).
Auto Trait Implementations§
impl !RefUnwindSafe for TaskDriver
impl !UnwindSafe for TaskDriver
impl Freeze for TaskDriver
impl Send for TaskDriver
impl Sync for TaskDriver
impl Unpin for TaskDriver
impl UnsafeUnpin for TaskDriver
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> Fruit for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more