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
impl DaemonClient
Sourcepub fn connect(scope_hash: Option<&str>) -> Result<Self, ClientError>
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.
Sourcepub fn connect_to(socket_path: &str) -> Result<Self, ClientError>
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).
Sourcepub fn send_request(
&mut self,
request: DaemonRequest,
) -> Result<DaemonResponse, ClientError>
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.
Sourcepub fn ping(&mut self) -> Result<DaemonResponse, ClientError>
pub fn ping(&mut self) -> Result<DaemonResponse, ClientError>
Ping the daemon to check liveness.
Sourcepub fn shutdown(
&mut self,
graceful: bool,
timeout_seconds: f64,
) -> Result<DaemonResponse, ClientError>
pub fn shutdown( &mut self, graceful: bool, timeout_seconds: f64, ) -> Result<DaemonResponse, ClientError>
Ask the daemon to shut down.
Sourcepub fn status(&mut self) -> Result<DaemonResponse, ClientError>
pub fn status(&mut self) -> Result<DaemonResponse, ClientError>
Query daemon status.
Sourcepub fn list_active(&mut self) -> Result<DaemonResponse, ClientError>
pub fn list_active(&mut self) -> Result<DaemonResponse, ClientError>
List all active tracked processes.
Sourcepub fn list_by_originator(
&mut self,
tool: &str,
) -> Result<DaemonResponse, ClientError>
pub fn list_by_originator( &mut self, tool: &str, ) -> Result<DaemonResponse, ClientError>
List tracked processes filtered by originator tool name.
Sourcepub fn kill_zombies(
&mut self,
dry_run: bool,
) -> Result<DaemonResponse, ClientError>
pub fn kill_zombies( &mut self, dry_run: bool, ) -> Result<DaemonResponse, ClientError>
Kill zombie processes tracked by the daemon.
Sourcepub fn kill_tree(
&mut self,
pid: u32,
timeout_seconds: f64,
) -> Result<DaemonResponse, ClientError>
pub fn kill_tree( &mut self, pid: u32, timeout_seconds: f64, ) -> Result<DaemonResponse, ClientError>
Kill a process tree rooted at pid.
Sourcepub fn get_process_tree(
&mut self,
pid: u32,
) -> Result<DaemonResponse, ClientError>
pub fn get_process_tree( &mut self, pid: u32, ) -> Result<DaemonResponse, ClientError>
Get the process tree display for a given PID.
Sourcepub fn spawn_command(
&mut self,
request: &SpawnCommandRequest,
) -> Result<SpawnedDaemon, ClientError>
pub fn spawn_command( &mut self, request: &SpawnCommandRequest, ) -> Result<SpawnedDaemon, ClientError>
Ask the daemon to spawn and track a detached shell command.
Sourcepub fn service_start(
&mut self,
config: ServiceConfig,
) -> Result<DaemonResponse, ClientError>
pub fn service_start( &mut self, config: ServiceConfig, ) -> Result<DaemonResponse, ClientError>
Start a supervised service from a ServiceConfig.
Sourcepub fn service_stop(
&mut self,
target: &str,
) -> Result<DaemonResponse, ClientError>
pub fn service_stop( &mut self, target: &str, ) -> Result<DaemonResponse, ClientError>
Stop a supervised service identified by name, id, or "all".
Sourcepub fn service_restart(
&mut self,
target: &str,
) -> Result<DaemonResponse, ClientError>
pub fn service_restart( &mut self, target: &str, ) -> Result<DaemonResponse, ClientError>
Restart a supervised service identified by name, id, or "all".
Sourcepub fn service_delete(
&mut self,
target: &str,
) -> Result<DaemonResponse, ClientError>
pub fn service_delete( &mut self, target: &str, ) -> Result<DaemonResponse, ClientError>
Delete a supervised service from the registry.
Sourcepub fn service_list(&mut self) -> Result<DaemonResponse, ClientError>
pub fn service_list(&mut self) -> Result<DaemonResponse, ClientError>
List all supervised services known to the daemon.
Sourcepub fn service_describe(
&mut self,
target: &str,
) -> Result<DaemonResponse, ClientError>
pub fn service_describe( &mut self, target: &str, ) -> Result<DaemonResponse, ClientError>
Describe a single supervised service in detail.
Sourcepub fn service_logs(
&mut self,
target: &str,
lines: u32,
follow: bool,
) -> Result<DaemonResponse, ClientError>
pub fn service_logs( &mut self, target: &str, lines: u32, follow: bool, ) -> Result<DaemonResponse, ClientError>
Fetch buffered log output for a supervised service.
Sourcepub fn service_flush(
&mut self,
target: &str,
) -> Result<DaemonResponse, ClientError>
pub fn service_flush( &mut self, target: &str, ) -> Result<DaemonResponse, ClientError>
Flush buffered logs for a supervised service.
Sourcepub fn service_save(&mut self) -> Result<DaemonResponse, ClientError>
pub fn service_save(&mut self) -> Result<DaemonResponse, ClientError>
Persist the current set of supervised services to a snapshot.
Sourcepub fn service_resurrect(&mut self) -> Result<DaemonResponse, ClientError>
pub fn service_resurrect(&mut self) -> Result<DaemonResponse, ClientError>
Restore supervised services from the most recent snapshot.
Sourcepub fn resize_pty_session(
&mut self,
session_id: &str,
rows: u16,
cols: u16,
) -> Result<(), ClientError>
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.
Sourcepub fn purge_exited_sessions(
&mut self,
originator: &str,
) -> Result<PurgeExitedSessionsResponse, ClientError>
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.
Sourcepub fn bulk_terminate_sessions(
&mut self,
older_than_secs: u64,
originator: &str,
grace_ms: u32,
) -> Result<BulkTerminateSessionsResponse, ClientError>
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.
Sourcepub fn get_session_backlog(
&mut self,
session_id: &str,
pipe_stream: PipeStreamKind,
) -> Result<Option<GetSessionBacklogResponse>, ClientError>
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
impl DaemonClient
pub fn spawn_pipe_session( &mut self, request: &PipeSpawnRequest, ) -> Result<SpawnedPipeSession, ClientError>
pub fn list_pipe_sessions( &mut self, originator_filter: &str, ) -> Result<Vec<PipeSessionInfo>, ClientError>
pub fn detach_pipe_stream( &mut self, session_id: &str, stream: PipeStreamKind, ) -> Result<(), ClientError>
pub fn terminate_pipe_session( &mut self, session_id: &str, grace_ms: u32, ) -> Result<(), ClientError>
pub fn write_pipe_stdin( &mut self, session_id: &str, data: &[u8], close_after: bool, ) -> Result<u64, ClientError>
Source§impl DaemonClient
impl DaemonClient
Sourcepub fn spawn_pty_session(
&mut self,
request: &PtySpawnRequest,
) -> Result<SpawnedPtySession, ClientError>
pub fn spawn_pty_session( &mut self, request: &PtySpawnRequest, ) -> Result<SpawnedPtySession, ClientError>
Ask the daemon to spawn a new PTY session that it owns.
Sourcepub fn list_pty_sessions(
&mut self,
originator_filter: &str,
) -> Result<Vec<PtySessionInfo>, ClientError>
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.
Sourcepub fn detach_pty_session(
&mut self,
session_id: &str,
) -> Result<(), ClientError>
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.
Sourcepub fn terminate_pty_session(
&mut self,
session_id: &str,
grace_ms: u32,
) -> Result<(), ClientError>
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).