Skip to main content

Crate santati

Crate santati 

Source
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§

ActorInput
Who acted, as supplied to crate::Events::emit.
AuditEvent
BatchItem
One entry of BatchResult::results, in submission order.
BatchItemError
Why one batch item was rejected.
BatchResult
The result of crate::Events::emit_batch.
Builder
Builds a Santati; every option has a documented default and Builder::build validates the two that can be wrong.
DefinitionInput
The definition crate::Schemas::create_definition sends: action plus the members that are Some. Some(vec![]) for allowed_target_types is sent as [].
DefinitionPage
One page of crate::Schemas::list_definitions.
DefinitionUpdate
The changes crate::Schemas::update_definition sends: only the members that are Some, so the default sends {}.
EmitResult
The result of crate::Events::emit.
ErrorDetails
Everything known about a failure.
EventActor
EventActor : Who acted, in the producer’s own ids. Documentation-only on the write path — apps.audit_trails.ingest is the validator — and the shape AuditEventSerializer.get_actor always returns, so every key is present on a read even when the producer sent none of them.
EventDefinition
EventInput
One event to emit, in the envelope’s own shape.
EventPage
One page of crate::Events::list.
EventSchemaVersion
EventTarget
EventTarget : One object an event acted on, in the producer’s own ids. The shape AuditEventSerializer.get_targets returns, and the shape ingest accepts on an envelope’s targets array.
Events
The client’s event operations, borrowed from a Santati.
ListParams
The filters crate::Events::list and crate::Events::iterate accept.
MemoryOutbox
A bounded in-memory OutboxStore: the default.
OcsfMapping
OutboxEntry
One stored event and the store’s handle for it.
PageParams
The page selectors of crate::Schemas::list_definitions and crate::Schemas::list_versions; absent members are not sent. The iterate_* methods manage the cursor themselves and ignore cursor.
Santati
A Santati client: one API key, one origin, one HTTP connection pool.
SchemaCheck
SchemaCheckFailure
SchemaVersionPage
One page of crate::Schemas::list_versions.
SchemaVersionResult
A schema version and the ETag header its response carried.
Schemas
The client’s schema operations, borrowed from a Santati.
SendOutcome
What post_send receives next to the stored event.
StandardEvent
StandardEventCatalog
StandardPack
StandardPackInstallResult
TargetInput
One object an event acted on, as supplied to crate::Events::emit.

Enums§

BatchStatus
How one batch item ended up.
Error
Every failure the SDK reports, and its ErrorDetails.
ErrorKind
Which of the nine failure kinds an Error is.
SendStatus
How one event’s delivery ended, as seen by post_send.

Constants§

DEFAULT_BASE_URL
The API origin used when base_url is not set.
DEFAULT_INITIAL_BACKOFF_MS
Backoff base used when initial_backoff_ms is not set.
DEFAULT_MAX_BACKOFF_MS
Backoff cap used when max_backoff_ms is not set.
DEFAULT_MAX_RETRIES
Retries used when max_retries is not set.
DEFAULT_TIMEOUT_MS
Per-attempt timeout used when timeout_ms is not set.

Traits§

OutboxStore
Where a queued Events::emit keeps events until the worker sends them.
StreamExt
An extension trait for Streams that provides a variety of convenient combinator functions.

Attribute Macros§

async_trait