Skip to main content

DaemonClient

Struct DaemonClient 

Source
pub struct DaemonClient { /* private fields */ }
Expand description

Synchronous IPC client that communicates with the daemon over a local socket.

Messages are framed with a 4-byte big-endian length prefix followed by a protobuf-encoded payload.

Implementations§

Source§

impl DaemonClient

Source

pub fn connect(scope_hash: Option<&str>) -> Result<Self, ClientError>

Connect to a running daemon identified by an optional scope hash.

The socket path is computed by paths::socket_path and the name type dispatch matches the server via paths::make_socket_name.

Source

pub fn connect_to(socket_path: &str) -> Result<Self, ClientError>

Connect to a daemon listening at an explicit socket path.

Use this when you already know the socket path (e.g. in integration tests that start a server on a unique path).

Source

pub fn send_request( &mut self, request: DaemonRequest, ) -> Result<DaemonResponse, ClientError>

Send a request and wait for the corresponding response.

The request is length-prefixed (4-byte big-endian u32) then protobuf-encoded. The response uses the same framing.

Source

pub fn ping(&mut self) -> Result<DaemonResponse, ClientError>

Ping the daemon to check liveness.

Source

pub fn shutdown( &mut self, graceful: bool, timeout_seconds: f64, ) -> Result<DaemonResponse, ClientError>

Ask the daemon to shut down.

Source

pub fn status(&mut self) -> Result<DaemonResponse, ClientError>

Query daemon status.

Source

pub fn list_active(&mut self) -> Result<DaemonResponse, ClientError>

List all active tracked processes.

Source

pub fn list_by_originator( &mut self, tool: &str, ) -> Result<DaemonResponse, ClientError>

List tracked processes filtered by originator tool name.

Source

pub fn kill_zombies( &mut self, dry_run: bool, ) -> Result<DaemonResponse, ClientError>

Kill zombie processes tracked by the daemon.

Source

pub fn kill_tree( &mut self, pid: u32, timeout_seconds: f64, ) -> Result<DaemonResponse, ClientError>

Kill a process tree rooted at pid.

Source

pub fn get_process_tree( &mut self, pid: u32, ) -> Result<DaemonResponse, ClientError>

Get the process tree display for a given PID.

Source

pub fn spawn_command( &mut self, request: &SpawnCommandRequest, ) -> Result<SpawnedDaemon, ClientError>

Ask the daemon to spawn and track a detached shell command.

Source

pub fn service_start( &mut self, config: ServiceConfig, ) -> Result<DaemonResponse, ClientError>

Start a supervised service from a ServiceConfig.

Source

pub fn service_stop( &mut self, target: &str, ) -> Result<DaemonResponse, ClientError>

Stop a supervised service identified by name, id, or "all".

Source

pub fn service_restart( &mut self, target: &str, ) -> Result<DaemonResponse, ClientError>

Restart a supervised service identified by name, id, or "all".

Source

pub fn service_delete( &mut self, target: &str, ) -> Result<DaemonResponse, ClientError>

Delete a supervised service from the registry.

Source

pub fn service_list(&mut self) -> Result<DaemonResponse, ClientError>

List all supervised services known to the daemon.

Source

pub fn service_describe( &mut self, target: &str, ) -> Result<DaemonResponse, ClientError>

Describe a single supervised service in detail.

Source

pub fn service_logs( &mut self, target: &str, lines: u32, follow: bool, ) -> Result<DaemonResponse, ClientError>

Fetch buffered log output for a supervised service.

Source

pub fn service_flush( &mut self, target: &str, ) -> Result<DaemonResponse, ClientError>

Flush buffered logs for a supervised service.

Source

pub fn service_save(&mut self) -> Result<DaemonResponse, ClientError>

Persist the current set of supervised services to a snapshot.

Source

pub fn service_resurrect(&mut self) -> Result<DaemonResponse, ClientError>

Restore supervised services from the most recent snapshot.

Source

pub fn resize_pty_session( &mut self, session_id: &str, rows: u16, cols: u16, ) -> Result<(), ClientError>

Resize a PTY session without going through an attach (#130 M5 follow-up). The new size persists for the lifetime of the session; subsequent attaches can override it via their own rows/cols fields.

Source

pub fn purge_exited_sessions( &mut self, originator: &str, ) -> Result<PurgeExitedSessionsResponse, ClientError>

Purge exited sessions from both daemon-side registries (#130 M9 H4). Returns counts of PTY and pipe sessions reaped.

Source

pub fn bulk_terminate_sessions( &mut self, older_than_secs: u64, originator: &str, grace_ms: u32, ) -> Result<BulkTerminateSessionsResponse, ClientError>

Schedule termination of every session older than the threshold (#130 M9 H4). older_than_secs=0 terminates everything in scope.

Source

pub fn get_session_backlog( &mut self, session_id: &str, pipe_stream: PipeStreamKind, ) -> Result<Option<GetSessionBacklogResponse>, ClientError>

Snapshot a PTY or pipe session’s output backlog without consuming it. For pipe sessions, pipe_stream selects between stdout and stderr (default stdout). For PTY sessions pipe_stream is ignored. Returns None when the session is not found.

Source§

impl DaemonClient

Source

pub fn spawn_pipe_session( &mut self, request: &PipeSpawnRequest, ) -> Result<SpawnedPipeSession, ClientError>

Source

pub fn list_pipe_sessions( &mut self, originator_filter: &str, ) -> Result<Vec<PipeSessionInfo>, ClientError>

Source

pub fn detach_pipe_stream( &mut self, session_id: &str, stream: PipeStreamKind, ) -> Result<(), ClientError>

Source

pub fn terminate_pipe_session( &mut self, session_id: &str, grace_ms: u32, ) -> Result<(), ClientError>

Source

pub fn write_pipe_stdin( &mut self, session_id: &str, data: &[u8], close_after: bool, ) -> Result<u64, ClientError>

Source§

impl DaemonClient

Source

pub fn spawn_pty_session( &mut self, request: &PtySpawnRequest, ) -> Result<SpawnedPtySession, ClientError>

Ask the daemon to spawn a new PTY session that it owns.

Source

pub fn list_pty_sessions( &mut self, originator_filter: &str, ) -> Result<Vec<PtySessionInfo>, ClientError>

List PTY sessions known to the daemon. Empty originator_filter returns all sessions in scope.

Source

pub fn detach_pty_session( &mut self, session_id: &str, ) -> Result<(), ClientError>

Ask the daemon to detach any current attachment from a session, leaving the session alive. Idempotent.

Source

pub fn terminate_pty_session( &mut self, session_id: &str, grace_ms: u32, ) -> Result<(), ClientError>

Schedule termination of a PTY session. Returns as soon as the daemon accepts the schedule; the actual termination happens on a daemon background task (soft signal, grace, then hard kill).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.