pub struct OperationTracker { /* private fields */ }Expand description
Tracks active operations with heartbeat-based liveness checking
Implementations§
Source§impl OperationTracker
impl OperationTracker
Sourcepub fn with_config(
heartbeat_interval: Duration,
max_missed_heartbeats: u32,
) -> Arc<Self>
pub fn with_config( heartbeat_interval: Duration, max_missed_heartbeats: u32, ) -> Arc<Self>
Create a new operation tracker with custom settings
Sourcepub fn subscribe(&self) -> Receiver<OperationEvent>
pub fn subscribe(&self) -> Receiver<OperationEvent>
Subscribe to operation events
Sourcepub async fn start_operation(
self: &Arc<Self>,
agent_id: &str,
resource_type: ResourceType,
scope: ResourceScope,
description: &str,
) -> Result<OperationHandle>
pub async fn start_operation( self: &Arc<Self>, agent_id: &str, resource_type: ResourceType, scope: ResourceScope, description: &str, ) -> Result<OperationHandle>
Start tracking a new operation
Returns an OperationHandle that:
- Automatically sends heartbeats
- Can have a process attached for liveness monitoring
- Signals completion when dropped
Sourcepub async fn heartbeat(&self, operation_id: &str, status: &str) -> Result<()>
pub async fn heartbeat(&self, operation_id: &str, status: &str) -> Result<()>
Update heartbeat and status for an operation
Sourcepub async fn add_output(&self, operation_id: &str, line: &str) -> Result<()>
pub async fn add_output(&self, operation_id: &str, line: &str) -> Result<()>
Add output line to an operation
Sourcepub async fn attach_process(
&self,
operation_id: &str,
process_id: u32,
) -> Result<()>
pub async fn attach_process( &self, operation_id: &str, process_id: u32, ) -> Result<()>
Attach a process ID to an operation for liveness monitoring
Sourcepub async fn get_status(&self, operation_id: &str) -> Option<OperationStatus>
pub async fn get_status(&self, operation_id: &str) -> Option<OperationStatus>
Get status of an operation
Sourcepub async fn list_operations(&self) -> Vec<OperationStatus>
pub async fn list_operations(&self) -> Vec<OperationStatus>
Get all active operations
Sourcepub async fn operations_for_agent(&self, agent_id: &str) -> Vec<OperationStatus>
pub async fn operations_for_agent(&self, agent_id: &str) -> Vec<OperationStatus>
Get operations for a specific agent
Sourcepub async fn find_operation(
&self,
resource_type: ResourceType,
scope: &ResourceScope,
) -> Option<OperationStatus>
pub async fn find_operation( &self, resource_type: ResourceType, scope: &ResourceScope, ) -> Option<OperationStatus>
Find operations by resource type and scope
Sourcepub async fn cleanup_stale(&self) -> Vec<String>
pub async fn cleanup_stale(&self) -> Vec<String>
Clean up stale operations (those with expired heartbeats)
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for OperationTracker
impl !RefUnwindSafe for OperationTracker
impl Send for OperationTracker
impl Sync for OperationTracker
impl Unpin for OperationTracker
impl UnsafeUnpin for OperationTracker
impl UnwindSafe for OperationTracker
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