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 async fn migrate_caller_keys(
&self,
map: impl Fn(&str) -> Option<String>,
) -> Result<CallerKeyMigration, Error>
Available on crate feature sqlite only.
pub async fn migrate_caller_keys( &self, map: impl Fn(&str) -> Option<String>, ) -> Result<CallerKeyMigration, Error>
sqlite only.Moves each caller partition map renames to its new key, with its
tasks, their logged events and its idempotency keys, in one
transaction (audit register R12); see
caller_keys.
§Errors
A database error, including a task id the new partition already holds; nothing is moved then.
Source§impl TenantAwareSqliteTaskStore
impl TenantAwareSqliteTaskStore
Sourcepub async fn erase_caller(&self, caller: &str) -> Result<CallerErasure, Error>
Available on crate feature sqlite only.
pub async fn erase_caller(&self, caller: &str) -> Result<CallerErasure, Error>
sqlite only.Removes every partition of caller, in every tenant, with its tasks,
their logged events and its idempotency keys, in one transaction; see
CallerErasure.
§Errors
A database error; nothing is removed then.
Source§impl TenantAwareSqliteTaskStore
impl TenantAwareSqliteTaskStore
Sourcepub const fn with_max_page_size(self, max: u32) -> TenantAwareSqliteTaskStore
Available on crate feature sqlite only.
pub const fn with_max_page_size(self, max: u32) -> TenantAwareSqliteTaskStore
sqlite only.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 fn with_metrics(self, metrics: MetricsHandle) -> TenantAwareSqliteTaskStore
Available on crate feature sqlite only.
pub fn with_metrics(self, metrics: MetricsHandle) -> TenantAwareSqliteTaskStore
sqlite only.Sets where this store reports an event it could not record.
Defaults to NoopMetrics. See
event_append_error for why an
append that wrote nothing cannot be an error, and what a non-zero rate
means.
Sourcepub async fn new(url: &str) -> Result<TenantAwareSqliteTaskStore, Error>
Available on crate feature sqlite only.
pub async fn new(url: &str) -> Result<TenantAwareSqliteTaskStore, Error>
sqlite only.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: Pool<Sqlite>,
) -> Result<TenantAwareSqliteTaskStore, Error>
Available on crate feature sqlite only.
pub async fn from_pool( pool: Pool<Sqlite>, ) -> Result<TenantAwareSqliteTaskStore, Error>
sqlite only.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,
) -> Result<PurgeReport, A2aError>
Available on crate feature sqlite only.
pub async fn purge_expired( &self, policy: &RetentionPolicy, ) -> Result<PurgeReport, A2aError>
sqlite only.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 threads or processes sharing the file: each
batch is a single DELETE, and SQLite lets one write statement run
at a time, so a second sweep’s batch is picked after the first one’s
rows are gone rather than alongside them. That holds only where
SQLite’s file locking does, which is local storage.
§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 is_process_local(&self) -> bool
fn is_process_local(&self) -> bool
Source§fn isolates_tenants(&self) -> bool
fn isolates_tenants(&self) -> bool
Source§fn supports_idempotency(&self) -> bool
fn supports_idempotency(&self) -> bool
Source§fn database(&self) -> Option<StoreDatabase>
fn database(&self) -> Option<StoreDatabase>
CLIENT span around each of the store’s operations and measures in
db.client.operation.duration (the OpenTelemetry database
conventions; crate::store::traced). Read moreSource§fn turn_claims(&self) -> Option<Arc<dyn TurnClaimStore>>
fn turn_claims(&self) -> Option<Arc<dyn TurnClaimStore>>
crate::store::claim). Read moreSource§fn claim_idempotency_key<'a>(
&'a self,
key: &'a str,
message_id: &'a MessageId,
task_id: &'a TaskId,
) -> Pin<Box<dyn Future<Output = Result<IdempotencyClaim, A2aError>> + Send + 'a>>
fn claim_idempotency_key<'a>( &'a self, key: &'a str, message_id: &'a MessageId, task_id: &'a TaskId, ) -> Pin<Box<dyn Future<Output = Result<IdempotencyClaim, A2aError>> + Send + 'a>>
Source§fn release_idempotency_key<'a>(
&'a self,
key: &'a str,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
fn release_idempotency_key<'a>( &'a self, key: &'a str, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
claim_idempotency_key,
so it can be claimed again. Read moreSource§fn idempotency_holder<'a>(
&'a self,
key: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Option<IdempotencyHolder>, A2aError>> + Send + 'a>>
fn idempotency_holder<'a>( &'a self, key: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Option<IdempotencyHolder>, A2aError>> + Send + 'a>>
Source§fn save<'a>(
&'a self,
task: &'a Task,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
fn save<'a>( &'a self, task: &'a Task, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
Source§fn get<'a>(
&'a self,
id: &'a TaskId,
) -> Pin<Box<dyn Future<Output = Result<Option<Task>, A2aError>> + Send + 'a>>
fn get<'a>( &'a self, id: &'a TaskId, ) -> Pin<Box<dyn Future<Output = Result<Option<Task>, A2aError>> + Send + 'a>>
None if not found. Read moreSource§fn get_with_position<'a>(
&'a self,
id: &'a TaskId,
) -> Pin<Box<dyn Future<Output = Result<Option<(Task, Option<u64>)>, A2aError>> + Send + 'a>>
fn get_with_position<'a>( &'a self, id: &'a TaskId, ) -> Pin<Box<dyn Future<Output = Result<Option<(Task, Option<u64>)>, A2aError>> + Send + 'a>>
Source§fn list<'a>(
&'a self,
params: &'a ListTasksParams,
) -> Pin<Box<dyn Future<Output = Result<TaskListResponse, A2aError>> + Send + 'a>>
fn list<'a>( &'a self, params: &'a ListTasksParams, ) -> Pin<Box<dyn Future<Output = Result<TaskListResponse, A2aError>> + Send + 'a>>
Source§fn insert_if_absent<'a>(
&'a self,
task: &'a Task,
) -> Pin<Box<dyn Future<Output = Result<bool, A2aError>> + Send + 'a>>
fn insert_if_absent<'a>( &'a self, task: &'a Task, ) -> Pin<Box<dyn Future<Output = Result<bool, A2aError>> + Send + 'a>>
Source§fn delete<'a>(
&'a self,
id: &'a TaskId,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
fn delete<'a>( &'a self, id: &'a TaskId, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
Source§fn supports_event_log(&self) -> bool
fn supports_event_log(&self) -> bool
Source§fn append_event<'a>(
&'a self,
task_id: &'a TaskId,
seq: u64,
event: &'a StreamResponse,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
fn append_event<'a>( &'a self, task_id: &'a TaskId, seq: u64, event: &'a StreamResponse, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
seq in the task’s log. Read moreSource§fn last_event_seq<'a>(
&'a self,
task_id: &'a TaskId,
) -> Pin<Box<dyn Future<Output = Result<u64, A2aError>> + Send + 'a>>
fn last_event_seq<'a>( &'a self, task_id: &'a TaskId, ) -> Pin<Box<dyn Future<Output = Result<u64, A2aError>> + Send + 'a>>
seq this task’s log holds, or 0 when it is empty. Read moreSource§fn earliest_event_seq<'a>(
&'a self,
task_id: &'a TaskId,
) -> Pin<Box<dyn Future<Output = Result<Option<u64>, A2aError>> + Send + 'a>>
fn earliest_event_seq<'a>( &'a self, task_id: &'a TaskId, ) -> Pin<Box<dyn Future<Output = Result<Option<u64>, A2aError>> + Send + 'a>>
seq this task’s log still holds, or None when it holds
nothing — or when the store cannot say, which is the default. Read moreSource§fn trim_event_log<'a>(
&'a self,
task_id: &'a TaskId,
below: u64,
) -> Pin<Box<dyn Future<Output = Result<u64, A2aError>> + Send + 'a>>
fn trim_event_log<'a>( &'a self, task_id: &'a TaskId, below: u64, ) -> Pin<Box<dyn Future<Output = Result<u64, A2aError>> + Send + 'a>>
below, and returns how
many it dropped: the compaction of a live task’s log (audit H13, ADR
0047, option C), which
RetentionPolicy::max_events_per_live_task
drives from the SQL stores’ purge_expired. Read moreSource§fn read_events<'a>(
&'a self,
task_id: &'a TaskId,
after_seq: u64,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<RecordedEvent>, A2aError>> + Send + 'a>>
fn read_events<'a>( &'a self, task_id: &'a TaskId, after_seq: u64, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<RecordedEvent>, A2aError>> + Send + 'a>>
after_seq. Read moreSource§fn count<'a>(
&'a self,
) -> Pin<Box<dyn Future<Output = Result<u64, A2aError>> + Send + 'a>>
fn count<'a>( &'a self, ) -> Pin<Box<dyn Future<Output = Result<u64, A2aError>> + Send + 'a>>
Source§fn health<'a>(
&'a self,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
fn health<'a>( &'a self, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
RequestHandler::task_store_health). Read moreSource§fn seals_content(&self) -> bool
fn seals_content(&self) -> bool
Source§fn save_artifact_delta<'a>(
&'a self,
task: &'a Task,
delta: ArtifactDelta,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
fn save_artifact_delta<'a>( &'a self, task: &'a Task, delta: ArtifactDelta, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
task. Read moreSource§fn save_status_delta<'a>(
&'a self,
task: &'a Task,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
fn save_status_delta<'a>( &'a self, task: &'a Task, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
Source§fn try_save_artifact_delta<'a>(
&'a self,
_task: &'a Task,
_delta: ArtifactDelta,
) -> Pin<Box<dyn Future<Output = Result<bool, A2aError>> + Send + 'a>>
fn try_save_artifact_delta<'a>( &'a self, _task: &'a Task, _delta: ArtifactDelta, ) -> Pin<Box<dyn Future<Output = Result<bool, A2aError>> + Send + 'a>>
Ok(true) when applied, Ok(false) when the
caller must write the task whole. Read moreSource§fn try_save_status_delta<'a>(
&'a self,
_task: &'a Task,
) -> Pin<Box<dyn Future<Output = Result<bool, A2aError>> + Send + 'a>>
fn try_save_status_delta<'a>( &'a self, _task: &'a Task, ) -> Pin<Box<dyn Future<Output = Result<bool, A2aError>> + Send + 'a>>
try_save_artifact_delta for
save_status_delta: writes the status
in place and returns true, or writes nothing and returns false. Read moreSource§fn save_appending_history<'a>(
&'a self,
task: &'a Task,
messages: &'a [Message],
limit: HistoryLimit,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
fn save_appending_history<'a>( &'a self, task: &'a Task, messages: &'a [Message], limit: HistoryLimit, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
messages, without the caller
shipping the history it has already stored. Read moreSource§fn hold_events(&self, task_id: &TaskId, after: u64) -> Option<EventHold>
fn hold_events(&self, task_id: &TaskId, after: u64) -> Option<EventHold>
after for a stream that still owes those
positions, until the hold is advanced or dropped (spec §3.5.2); see
EventHolds. Synchronous: a stream takes
it while it is built. A wrapper must forward it. Read moreSource§fn watch_event_log(
&self,
task_id: &TaskId,
) -> Option<Pin<Box<dyn Future<Output = LogWake> + Send>>>
fn watch_event_log( &self, task_id: &TaskId, ) -> Option<Pin<Box<dyn Future<Output = LogWake> + Send>>>
SubscribeToTask stream that would otherwise read the store on a timer
(audit E-F25 (b), ADR 0057). None, the default, is a store that
cannot say. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for TenantAwareSqliteTaskStore
impl !UnwindSafe for TenantAwareSqliteTaskStore
impl Forget for TenantAwareSqliteTaskStore
impl Freeze for TenantAwareSqliteTaskStore
impl Move for TenantAwareSqliteTaskStore
impl Send for TenantAwareSqliteTaskStore
impl Sync for TenantAwareSqliteTaskStore
impl Unpin for TenantAwareSqliteTaskStore
impl UnsafeUnpin for TenantAwareSqliteTaskStore
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].