pub struct TenantAwareSqliteTaskStore { /* private fields */ }Expand description
Tenant-scoped SQLite-backed TaskStore.
Each operation is scoped to the tenant from TenantContext. Tasks are
stored with a tenant_id column for database-level isolation, enabling
efficient per-tenant queries and deletion.
§Example
use a2a_protocol_server::store::TenantAwareSqliteTaskStore;
use a2a_protocol_server::store::tenant::TenantContext;
let store = TenantAwareSqliteTaskStore::new("sqlite::memory:").await?;
TenantContext::scope("acme", async {
// All operations here are scoped to tenant "acme"
}).await;Implementations§
Source§impl TenantAwareSqliteTaskStore
impl TenantAwareSqliteTaskStore
Sourcepub const fn with_max_page_size(self, max: u32) -> Self
pub const fn with_max_page_size(self, max: u32) -> Self
Caps the page size list returns, however large a page is asked for.
Defaults to DEFAULT_MAX_PAGE_SIZE, which explains why this store
needs its own knob rather than reading TaskStoreConfig.
Sourcepub async fn new(url: &str) -> Result<Self, Error>
pub async fn new(url: &str) -> Result<Self, Error>
Opens (or creates) a SQLite database and initializes the schema.
§Errors
Returns an error if the database cannot be opened or migration fails.
Sourcepub async fn from_pool(pool: SqlitePool) -> Result<Self, Error>
pub async fn from_pool(pool: SqlitePool) -> Result<Self, Error>
Creates a store from an existing connection pool.
§Errors
Returns an error if the schema migration fails.
Sourcepub async fn purge_expired(
&self,
policy: &RetentionPolicy,
) -> A2aResult<PurgeReport>
pub async fn purge_expired( &self, policy: &RetentionPolicy, ) -> A2aResult<PurgeReport>
Deletes terminal tasks that have outlived policy.
Nothing calls this for you. A persistent store keeps every task until
an operator says otherwise — see retention
for why that is the default and why the in-memory store does the
opposite — so this is the hook for whatever already schedules work: a
cron entry, a Kubernetes CronJob, a tokio interval in your own
binary.
Only Completed, Failed, Canceled and Rejected tasks are
eligible. A task still Working, or parked in InputRequired waiting
on a human, is never deleted however old it is.
Safe to run from several replicas at once: each batch is a single
DELETE whose subquery picks the rows, so two sweeps racing delete
disjoint sets rather than colliding.
§Errors
Returns an error if a delete fails. A sweep that fails partway has still committed its earlier batches; the counts in the returned report are lost in that case, but the deletions are not undone and the next sweep simply continues.
Trait Implementations§
Source§impl Clone for TenantAwareSqliteTaskStore
impl Clone for TenantAwareSqliteTaskStore
Source§fn clone(&self) -> TenantAwareSqliteTaskStore
fn clone(&self) -> TenantAwareSqliteTaskStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TenantAwareSqliteTaskStore
impl Debug for TenantAwareSqliteTaskStore
Source§impl TaskStore for TenantAwareSqliteTaskStore
impl TaskStore for TenantAwareSqliteTaskStore
Source§fn save<'a>(
&'a self,
task: &'a Task,
) -> Pin<Box<dyn Future<Output = A2aResult<()>> + Send + 'a>>
fn save<'a>( &'a self, task: &'a Task, ) -> Pin<Box<dyn Future<Output = A2aResult<()>> + Send + 'a>>
Source§fn get<'a>(
&'a self,
id: &'a TaskId,
) -> Pin<Box<dyn Future<Output = A2aResult<Option<Task>>> + Send + 'a>>
fn get<'a>( &'a self, id: &'a TaskId, ) -> Pin<Box<dyn Future<Output = A2aResult<Option<Task>>> + Send + 'a>>
None if not found. Read moreSource§fn list<'a>(
&'a self,
params: &'a ListTasksParams,
) -> Pin<Box<dyn Future<Output = A2aResult<TaskListResponse>> + Send + 'a>>
fn list<'a>( &'a self, params: &'a ListTasksParams, ) -> Pin<Box<dyn Future<Output = A2aResult<TaskListResponse>> + Send + 'a>>
Source§fn insert_if_absent<'a>(
&'a self,
task: &'a Task,
) -> Pin<Box<dyn Future<Output = A2aResult<bool>> + Send + 'a>>
fn insert_if_absent<'a>( &'a self, task: &'a Task, ) -> Pin<Box<dyn Future<Output = A2aResult<bool>> + Send + 'a>>
Source§fn delete<'a>(
&'a self,
id: &'a TaskId,
) -> Pin<Box<dyn Future<Output = A2aResult<()>> + Send + 'a>>
fn delete<'a>( &'a self, id: &'a TaskId, ) -> Pin<Box<dyn Future<Output = A2aResult<()>> + Send + 'a>>
Auto Trait Implementations§
impl !RefUnwindSafe for TenantAwareSqliteTaskStore
impl !UnwindSafe for TenantAwareSqliteTaskStore
impl Freeze for TenantAwareSqliteTaskStore
impl Send for TenantAwareSqliteTaskStore
impl Sync for TenantAwareSqliteTaskStore
impl Unpin for TenantAwareSqliteTaskStore
impl UnsafeUnpin for TenantAwareSqliteTaskStore
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request