Expand description
Official Rust SDK for the Santati audit-log API.
Emit one audit event or a batch, list events with filters and cursor
pagination, and walk every page with Events::iterate. The crate is
async and needs a Tokio runtime.
use santati::{EventInput, ListParams, Santati, StreamExt};
let client = Santati::builder("sat_sk_...").trail("billing").build()?;
let events = client.events();
let result = events
.emit(EventInput {
event: "invoice.voided".into(),
organization_id: Some("org_acme".into()),
..Default::default()
})
.await?;
if let Some(event) = &result.event {
println!("{} (duplicate: {})", event.id, result.duplicate);
}
let mut stream = std::pin::pin!(events.iterate(ListParams {
trail: Some("billing".into()),
..Default::default()
}));
while let Some(event) = stream.next().await {
println!("{}", event?.event);
}§Outbox
With Builder::outbox, Events::emit validates like a plain emit,
stores the envelope in the OutboxStore and returns at once with
EmitResult::queued set and its idempotency key, without making a
request. A background task drains the outbox in batches; Santati::flush
and Santati::close drain it synchronously, so call close before the
program exits.
use santati::{EventInput, MemoryOutbox, Santati};
let client = Santati::builder("sat_sk_...")
.trail("billing")
.outbox(MemoryOutbox::new(10_000)?)
.build()?;
let result = client.events().emit(EventInput::new("invoice.voided")).await?;
assert!(result.queued);
client.close().await?;The surface this implements, and its error kinds and retry policy, are
documented in docs/sdk-surface.md. Event definitions, their JSON Schema
versions and the standard packs are managed through Santati::schemas.
Structs§
- Actor
Input - Who acted, as supplied to
crate::Events::emit. - Audit
Event - Batch
Item - One entry of
BatchResult::results, in submission order. - Batch
Item Error - Why one batch item was rejected.
- Batch
Result - The result of
crate::Events::emit_batch. - Builder
- Builds a
Santati; every option has a documented default andBuilder::buildvalidates the two that can be wrong. - Definition
Input - The definition
crate::Schemas::create_definitionsends:actionplus the members that areSome.Some(vec![])forallowed_target_typesis sent as[]. - Definition
Page - One page of
crate::Schemas::list_definitions. - Definition
Update - The changes
crate::Schemas::update_definitionsends: only the members that areSome, so the default sends{}. - Emit
Result - The result of
crate::Events::emit. - Error
Details - Everything known about a failure.
- Event
Actor - EventActor : Who acted, in the producer’s own ids. Documentation-only on the write path —
apps.audit_trails.ingestis the validator — and the shapeAuditEventSerializer.get_actoralways returns, so every key is present on a read even when the producer sent none of them. - Event
Definition - Event
Input - One event to emit, in the envelope’s own shape.
- Event
Page - One page of
crate::Events::list. - Event
Schema Version - Event
Target - EventTarget : One object an event acted on, in the producer’s own ids. The shape
AuditEventSerializer.get_targetsreturns, and the shape ingest accepts on an envelope’stargetsarray. - Events
- The client’s event operations, borrowed from a
Santati. - List
Params - The filters
crate::Events::listandcrate::Events::iterateaccept. - Memory
Outbox - A bounded in-memory
OutboxStore: the default. - Ocsf
Mapping - Outbox
Entry - One stored event and the store’s handle for it.
- Page
Params - The page selectors of
crate::Schemas::list_definitionsandcrate::Schemas::list_versions; absent members are not sent. Theiterate_*methods manage the cursor themselves and ignorecursor. - Santati
- A Santati client: one API key, one origin, one HTTP connection pool.
- Schema
Check - Schema
Check Failure - Schema
Version Page - One page of
crate::Schemas::list_versions. - Schema
Version Result - A schema version and the
ETagheader its response carried. - Schemas
- The client’s schema operations, borrowed from a
Santati. - Send
Outcome - What
post_sendreceives next to the stored event. - Standard
Event - Standard
Event Catalog - Standard
Pack - Standard
Pack Install Result - Target
Input - One object an event acted on, as supplied to
crate::Events::emit.
Enums§
- Batch
Status - How one batch item ended up.
- Error
- Every failure the SDK reports, and its
ErrorDetails. - Error
Kind - Which of the nine failure kinds an
Erroris. - Send
Status - How one event’s delivery ended, as seen by
post_send.
Constants§
- DEFAULT_
BASE_ URL - The API origin used when
base_urlis not set. - DEFAULT_
INITIAL_ BACKOFF_ MS - Backoff base used when
initial_backoff_msis not set. - DEFAULT_
MAX_ BACKOFF_ MS - Backoff cap used when
max_backoff_msis not set. - DEFAULT_
MAX_ RETRIES - Retries used when
max_retriesis not set. - DEFAULT_
TIMEOUT_ MS - Per-attempt timeout used when
timeout_msis not set.
Traits§
- Outbox
Store - Where a queued
Events::emitkeeps events until the worker sends them. - Stream
Ext - An extension trait for
Streams that provides a variety of convenient combinator functions.