pub struct SqliteAuditStore { /* private fields */ }audit only.Expand description
An AuditStore in SQLite tables a2a_audit_records,
a2a_audit_checkpoints, a2a_audit_holds and a2a_audit_subject_keys,
created if absent.
It can share a database (and a pool) with SqliteTaskStore;
it touches only its own tables. Each record is stored as the exact JSON
it was sealed with, so it reads back byte-for-byte equal and its hash
still verifies.
Implementations§
Source§impl SqliteAuditStore
impl SqliteAuditStore
Sourcepub async fn new(url: &str) -> Result<SqliteAuditStore, Error>
pub async fn new(url: &str) -> Result<SqliteAuditStore, Error>
Opens (or creates) a database at url and its audit tables.
§Errors
Returns an error if the database cannot be opened or the tables created.
Sourcepub async fn from_pool(pool: Pool<Sqlite>) -> Result<SqliteAuditStore, Error>
pub async fn from_pool(pool: Pool<Sqlite>) -> Result<SqliteAuditStore, Error>
Uses an existing pool, creating the audit tables if absent.
§Errors
Returns an error if the tables cannot be created.
Trait Implementations§
Source§impl AuditStore for SqliteAuditStore
impl AuditStore for SqliteAuditStore
Source§fn delete_through_unless_held<'a>(
&'a self,
chain: &'a str,
seq: u64,
) -> Pin<Box<dyn Future<Output = Result<Option<u64>, A2aError>> + Send + 'a>>
fn delete_through_unless_held<'a>( &'a self, chain: &'a str, seq: u64, ) -> Pin<Box<dyn Future<Output = Result<Option<u64>, A2aError>> + Send + 'a>>
One transaction whose first statement is a write: that takes
SQLite’s write lock, which a hold’s insert needs too, so the hold is
read and the records deleted with none placed in between. The hold is
tested inside each DELETE, so a held chain loses nothing.
Source§fn is_process_local(&self) -> bool
fn is_process_local(&self) -> bool
Source§fn head<'a>(
&'a self,
chain: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Option<(u64, String)>, A2aError>> + Send + 'a>>
fn head<'a>( &'a self, chain: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Option<(u64, String)>, A2aError>> + Send + 'a>>
seq stored in chain and that record’s hash.Source§fn append<'a>(
&'a self,
record: &'a AuditRecord,
) -> Pin<Box<dyn Future<Output = Result<Appended, A2aError>> + Send + 'a>>
fn append<'a>( &'a self, record: &'a AuditRecord, ) -> Pin<Box<dyn Future<Output = Result<Appended, A2aError>> + Send + 'a>>
(chain, seq) is already taken.Source§fn read<'a>(
&'a self,
chain: &'a str,
after: u64,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<AuditRecord>, A2aError>> + Send + 'a>>
fn read<'a>( &'a self, chain: &'a str, after: u64, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<AuditRecord>, A2aError>> + Send + 'a>>
limit records of chain with seq above after, in order.Source§fn chains(
&self,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, A2aError>> + Send + '_>>
fn chains( &self, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, A2aError>> + Send + '_>>
Source§fn put_checkpoint<'a>(
&'a self,
checkpoint: &'a Checkpoint,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
fn put_checkpoint<'a>( &'a self, checkpoint: &'a Checkpoint, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
seq and kind.Source§fn checkpoints<'a>(
&'a self,
chain: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Checkpoint>, A2aError>> + Send + 'a>>
fn checkpoints<'a>( &'a self, chain: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Checkpoint>, A2aError>> + Send + 'a>>
chain, in seq order.Source§fn last_before<'a>(
&'a self,
chain: &'a str,
cutoff_ms: i64,
) -> Pin<Box<dyn Future<Output = Result<Option<(u64, String)>, A2aError>> + Send + 'a>>
fn last_before<'a>( &'a self, chain: &'a str, cutoff_ms: i64, ) -> Pin<Box<dyn Future<Output = Result<Option<(u64, String)>, A2aError>> + Send + 'a>>
chain sealed before cutoff_ms (Unix
milliseconds), as (seq, hash).Source§fn delete_through<'a>(
&'a self,
chain: &'a str,
seq: u64,
) -> Pin<Box<dyn Future<Output = Result<u64, A2aError>> + Send + 'a>>
fn delete_through<'a>( &'a self, chain: &'a str, seq: u64, ) -> Pin<Box<dyn Future<Output = Result<u64, A2aError>> + Send + 'a>>
chain up to and including seq, and the
checkpoints below seq (an anchor at seq itself is kept). Returns
how many records went.Source§fn place_hold<'a>(
&'a self,
hold: &'a LegalHold,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
fn place_hold<'a>( &'a self, hold: &'a LegalHold, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
chain, replacing any reason already given.Source§fn release_hold<'a>(
&'a self,
chain: &'a str,
) -> Pin<Box<dyn Future<Output = Result<bool, A2aError>> + Send + 'a>>
fn release_hold<'a>( &'a self, chain: &'a str, ) -> Pin<Box<dyn Future<Output = Result<bool, A2aError>> + Send + 'a>>
chain; returns whether there was one.Source§fn holds(
&self,
) -> Pin<Box<dyn Future<Output = Result<Vec<LegalHold>, A2aError>> + Send + '_>>
fn holds( &self, ) -> Pin<Box<dyn Future<Output = Result<Vec<LegalHold>, A2aError>> + Send + '_>>
Source§fn supports_subject_keys(&self) -> bool
fn supports_subject_keys(&self) -> bool
AuditLog::with_privacy
refuses a store that answers false.Source§fn subject_key<'a>(
&'a self,
chain: &'a str,
lookup: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Option<SubjectKey>, A2aError>> + Send + 'a>>
fn subject_key<'a>( &'a self, chain: &'a str, lookup: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Option<SubjectKey>, A2aError>> + Send + 'a>>
Source§fn subject_key_by_sid<'a>(
&'a self,
chain: &'a str,
sid: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Option<SubjectKey>, A2aError>> + Send + 'a>>
fn subject_key_by_sid<'a>( &'a self, chain: &'a str, sid: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Option<SubjectKey>, A2aError>> + Send + 'a>>
Source§fn subject_keys<'a>(
&'a self,
chain: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Vec<SubjectKey>, A2aError>> + Send + 'a>>
fn subject_keys<'a>( &'a self, chain: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Vec<SubjectKey>, A2aError>> + Send + 'a>>
chain, for dropping those no record names. Read moreSource§fn put_subject_key<'a>(
&'a self,
chain: &'a str,
key: &'a SubjectKey,
) -> Pin<Box<dyn Future<Output = Result<bool, A2aError>> + Send + 'a>>
fn put_subject_key<'a>( &'a self, chain: &'a str, key: &'a SubjectKey, ) -> Pin<Box<dyn Future<Output = Result<bool, A2aError>> + Send + 'a>>
key for chain unless a key with its lookup is there;
false when one was, and nothing was stored. Atomic: of two writers
racing on one lookup, exactly one stores. Read moreSource§fn delete_subject_key<'a>(
&'a self,
chain: &'a str,
lookup: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, A2aError>> + Send + 'a>>
fn delete_subject_key<'a>( &'a self, chain: &'a str, lookup: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Option<String>, A2aError>> + Send + 'a>>
chain whose lookup is lookup, returning its
sid, or None when there was none. Must not leave a copy: what it
deletes is what erasure destroys. Read moreSource§fn append_next_naming<'a>(
&'a self,
chain: &'a str,
sids: &'a [String],
seal: &'a (dyn Fn(Option<(u64, String)>, Option<i64>) -> Pin<Box<dyn Future<Output = Result<AuditRecord, A2aError>> + Send + 'a>> + Send + Sync),
) -> Pin<Box<dyn Future<Output = Result<NamedAppend, A2aError>> + Send + 'a>>
fn append_next_naming<'a>( &'a self, chain: &'a str, sids: &'a [String], seal: &'a (dyn Fn(Option<(u64, String)>, Option<i64>) -> Pin<Box<dyn Future<Output = Result<AuditRecord, A2aError>> + Send + 'a>> + Send + Sync), ) -> Pin<Box<dyn Future<Output = Result<NamedAppend, A2aError>> + Send + 'a>>
append_next for a record sealed under the keys
whose handles are sids: stores it only if every one of those keys is
still in the store, checked atomically with the store’s write, so that
delete_subject_key_unless_named
either sees this record or deleted the key before it, which this then
sees. The same contract as append_next otherwise. Read moreSource§fn delete_subject_key_unless_named<'a>(
&'a self,
chain: &'a str,
lookup: &'a str,
sid: &'a str,
scanned_through: u64,
) -> Pin<Box<dyn Future<Output = Result<bool, A2aError>> + Send + 'a>>
fn delete_subject_key_unless_named<'a>( &'a self, chain: &'a str, lookup: &'a str, sid: &'a str, scanned_through: u64, ) -> Pin<Box<dyn Future<Output = Result<bool, A2aError>> + Send + 'a>>
chain whose lookup is lookup and handle sid,
unless a record with seq above scanned_through references sid
(sid_marker); true when it was deleted. For dropping keys no
record names: the caller has read the chain through
scanned_through, found no record naming sid, and this checks the
records stored since, atomically with the deletion (see
append_next_naming). Read moreSource§fn delete_subject_keys_unless_held<'a>(
&'a self,
chain: &'a str,
lookups: &'a [String],
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<String>>, A2aError>> + Send + 'a>>
fn delete_subject_keys_unless_held<'a>( &'a self, chain: &'a str, lookups: &'a [String], ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<String>>, A2aError>> + Send + 'a>>
chain whose lookup is in lookups, unless a
legal hold is placed on chain: None when one is, with nothing
deleted; otherwise the sid of each key deleted. All or nothing, and
the hold is read atomically with the deletion, as
delete_through_unless_held
reads it. Read moreSource§fn append_next<'a>(
&'a self,
chain: &'a str,
seal: &'a (dyn Fn(Option<(u64, String)>, Option<i64>) -> Pin<Box<dyn Future<Output = Result<AuditRecord, A2aError>> + Send + 'a>> + Send + Sync),
) -> Pin<Box<dyn Future<Output = Result<Option<AuditRecord>, A2aError>> + Send + 'a>>
fn append_next<'a>( &'a self, chain: &'a str, seal: &'a (dyn Fn(Option<(u64, String)>, Option<i64>) -> Pin<Box<dyn Future<Output = Result<AuditRecord, A2aError>> + Send + 'a>> + Send + Sync), ) -> Pin<Box<dyn Future<Output = Result<Option<AuditRecord>, A2aError>> + Send + 'a>>
chain: reads its head, has seal build the
record that follows it, and stores that. Ok(None) when another writer
took the position first: nothing was stored, and the caller asks again. Read moreSource§impl Clone for SqliteAuditStore
impl Clone for SqliteAuditStore
Source§fn clone(&self) -> SqliteAuditStore
fn clone(&self) -> SqliteAuditStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for SqliteAuditStore
impl !UnwindSafe for SqliteAuditStore
impl Forget for SqliteAuditStore
impl Freeze for SqliteAuditStore
impl Move for SqliteAuditStore
impl Send for SqliteAuditStore
impl Sync for SqliteAuditStore
impl Unpin for SqliteAuditStore
impl UnsafeUnpin for SqliteAuditStore
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].