pub struct TimeoutManager { /* private fields */ }Expand description
Timeout manager for commands and acknowledgments
Tracks command expiration (TTL) and acknowledgment timeouts. Provides efficient lookup of expired commands via BTreeMap.
Implementations§
Source§impl TimeoutManager
impl TimeoutManager
Sourcepub async fn register_expiration(
&self,
command: &HierarchicalCommand,
) -> Result<()>
pub async fn register_expiration( &self, command: &HierarchicalCommand, ) -> Result<()>
Register a command for expiration tracking
If the command has an expires_at field, it will be tracked
for automatic expiration.
Sourcepub async fn process_expired(&self) -> Vec<String>
pub async fn process_expired(&self) -> Vec<String>
Check and process expired commands
Returns a list of command IDs that have expired. This should be called periodically by a background task.
Sourcepub async fn unregister_expiration(&self, command_id: &str) -> Result<()>
pub async fn unregister_expiration(&self, command_id: &str) -> Result<()>
Unregister a command from expiration tracking
Called when a command completes before expiring.
Sourcepub async fn register_ack_timeout(
&self,
command_id: String,
expected_acks: Vec<String>,
timeout: Duration,
) -> Result<()>
pub async fn register_ack_timeout( &self, command_id: String, expected_acks: Vec<String>, timeout: Duration, ) -> Result<()>
Register an acknowledgment timeout
Tracks expected acknowledgments for a command with a timeout.
Sourcepub async fn record_ack(&self, command_id: &str, node_id: &str) -> bool
pub async fn record_ack(&self, command_id: &str, node_id: &str) -> bool
Record a received acknowledgment
Updates the tracking for a command’s acknowledgments. Returns true if all expected acks have been received.
Sourcepub async fn check_ack_timeouts(&self) -> Vec<String>
pub async fn check_ack_timeouts(&self) -> Vec<String>
Check for acknowledgment timeouts
Returns list of command IDs that have timed out waiting for acks. A command has timed out if:
- The timeout period has elapsed
- Not all expected acknowledgments have been received
Sourcepub async fn get_ack_status(&self, command_id: &str) -> Option<AckTimeout>
pub async fn get_ack_status(&self, command_id: &str) -> Option<AckTimeout>
Get acknowledgment status for a command
Returns the acknowledgment tracking info if it exists.
Sourcepub async fn unregister_ack_timeout(&self, command_id: &str) -> Result<()>
pub async fn unregister_ack_timeout(&self, command_id: &str) -> Result<()>
Remove acknowledgment timeout tracking
Called when a command completes or is cancelled.
Sourcepub async fn expiration_count(&self) -> usize
pub async fn expiration_count(&self) -> usize
Get count of commands being tracked for expiration
Sourcepub async fn ack_timeout_count(&self) -> usize
pub async fn ack_timeout_count(&self) -> usize
Get count of commands being tracked for ack timeout
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TimeoutManager
impl !RefUnwindSafe for TimeoutManager
impl Send for TimeoutManager
impl Sync for TimeoutManager
impl Unpin for TimeoutManager
impl UnsafeUnpin for TimeoutManager
impl !UnwindSafe for TimeoutManager
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
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