Skip to main content

HaltStore

Trait HaltStore 

Source
pub trait HaltStore:
    Send
    + Sync
    + 'static {
    // Required methods
    fn load(
        &self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<StoredHalt>, A2aError>> + Send + '_>>;
    fn put<'a>(
        &'a self,
        halt: &'a StoredHalt,
    ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>;
    fn remove<'a>(
        &'a self,
        scope: &'a HaltScope,
    ) -> Pin<Box<dyn Future<Output = Result<bool, A2aError>> + Send + 'a>>;

    // Provided methods
    fn is_process_local(&self) -> bool { ... }
    fn signals(&self) -> Option<Receiver<HaltSignal>> { ... }
    fn publish_cancel<'a>(
        &'a self,
        tenant: &'a str,
        task: &'a str,
    ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>> { ... }
}
Expand description

Where halts are kept so that every replica sees them and a restart keeps them.

§Contract

  • put stores halt, replacing any halt of the same scope.
  • remove deletes the halt of exactly that scope and says whether there was one; removing HaltScope::Tenant leaves HaltScope::All in place, and removing HaltScope::Root leaves its tenant’s halt in place.
  • Every scope is kept, HaltScope::Root included: a store that keys scopes by a string uses one key per scope, as the SQL stores’ (all, tenant:<t>, root:<n>:<tenant><root>) do.
  • load returns every halt stored, at most one per scope.
  • An error is an error: a store that cannot be read must not answer with no halts, since an empty list resumes every replica that polls it.

Required Methods§

Source

fn load( &self, ) -> Pin<Box<dyn Future<Output = Result<Vec<StoredHalt>, A2aError>> + Send + '_>>

Every halt in force.

§Errors

When the store cannot be read.

Source

fn put<'a>( &'a self, halt: &'a StoredHalt, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>

Stores halt, replacing a halt of the same scope.

§Errors

When the store cannot be written.

Source

fn remove<'a>( &'a self, scope: &'a HaltScope, ) -> Pin<Box<dyn Future<Output = Result<bool, A2aError>> + Send + 'a>>

Removes the halt of exactly scope; whether there was one.

§Errors

When the store cannot be written.

Provided Methods§

Source

fn is_process_local(&self) -> bool

Whether this store keeps its state in this process alone.

The default is false: a store this crate cannot see into (yours, over Redis, say) is taken to be shared. The in-memory ones answer true. Profile::Production reads it: on a task store that is shared between processes, a store that only this process can see makes the fleet behave as if it had no store (audit E-F13).

Source

fn signals(&self) -> Option<Receiver<HaltSignal>>

A subscription to this store’s pushed signals, or None (the default) for a store that cannot push; the handler then polls only.

Source

fn publish_cancel<'a>( &'a self, tenant: &'a str, task: &'a str, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>

Tells every handler sharing this store that task in tenant was cancelled. The default does nothing: without a push, the executor running the task learns of it at its next refused write.

§Errors

When the signal cannot be sent.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§