pub struct QueryGate { /* private fields */ }Expand description
Enforces single-flight query execution per app key with daemon-first cancel.
Implementations§
Source§impl QueryGate
impl QueryGate
Sourcepub fn acquire(
&self,
app_key: &str,
cancel: CancelFn,
send_cancel: Option<SendCancelFn>,
) -> Result<(), ErrQueryBusy>
pub fn acquire( &self, app_key: &str, cancel: CancelFn, send_cancel: Option<SendCancelFn>, ) -> Result<(), ErrQueryBusy>
Reserve app_key for one agent turn.
Returns ErrQueryBusy when a query is already in flight. Pass the local
cancel callback for the query’s timeout context (the same one the turn loop
derives from). send_cancel, when provided, sends the daemon cancel and is
invoked from Self::cancel on a detached 10s timeout.
Sourcepub async fn cancel(&self, app_key: &str) -> Result<()>
pub async fn cancel(&self, app_key: &str) -> Result<()>
Cooperatively stop a running query for app_key.
Sends the daemon cancel first (10s timeout, detached from the caller’s
cancellation), then invokes the local cancel callback. Returns Ok(()) when
no query is in flight (intent already satisfied).
Sourcepub fn release(&self, app_key: &str)
pub fn release(&self, app_key: &str)
Clear the gate for app_key without sending a daemon cancel.
Call when a query completes normally (success or local failure) so the next turn can acquire.
Sourcepub fn set_send_cancel(&self, app_key: &str, send_cancel: SendCancelFn)
pub fn set_send_cancel(&self, app_key: &str, send_cancel: SendCancelFn)
Update the daemon-cancel sender for an already-acquired session.
Sourcepub fn replace_cancel(&self, app_key: &str, cancel: CancelFn)
pub fn replace_cancel(&self, app_key: &str, cancel: CancelFn)
Update the local cancel callback for an already-acquired session.