1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//! 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.
//!
//! ```no_run
//! use santati::{EventInput, ListParams, Santati, StreamExt};
//!
//! # async fn run() -> Result<(), santati::Error> {
//! 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);
//! }
//! # Ok(())
//! # }
//! ```
//!
//! # 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.
//!
//! ```no_run
//! use santati::{EventInput, MemoryOutbox, Santati};
//!
//! # async fn run() -> Result<(), santati::Error> {
//! 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?;
//! # Ok(())
//! # }
//! ```
//!
//! 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`].
pub use async_trait;
pub use ;
pub use ;
pub use Events;
pub use StreamExt;
pub use ;
pub use RedisOutbox;
pub use ;
pub use Schemas;
pub use ;