adapter
Module[Adapter]: where logs are stored, and the adapters that ship.
Contents
2 submodules, and what the module defines itself.
use utopia_audit::Adapter;pub trait Adapter: Send + SyncA store of audit logs. Implement it to keep logs anywhere else.
adapter::clickhouse
Own page[ClickHouse]: logs as rows of a ClickHouse MergeTree table, over its
HTTP interface.
use utopia_audit::adapter::clickhouse::ClickHouse;pub struct ClickHouse<A = Client<Http>>The ClickHouse adapter: each log is a row of a MergeTree table
(<namespace>_audits in database default unless set otherwise),
partitioned by month and ordered by time, with bloom-filter skip indexes.
Queries go over ClickHouse's HTTP interface through A, a
utopia-client transport (by default a Client over Http with a
30 second timeout, redirects followed and connections reused), with
typed {paramN:Type} parameters.
Logs carry the actor (actorId, actorType, actorInternalId; the
legacy userId, userType, userInternalId are accepted and returned
too), the resource (resource, and its resourceType, resourceId,
resourceParent parsed from it when not given), the project, team and
host, geo, SDK and user-agent columns. Schema columns missing from a log
are taken from its data; the rest of data is stored as JSON.
With shared tables, rows carry the tenant and every read, count and cleanup is limited to the current one.
use utopia_audit::adapter::clickhouse::Options;pub struct OptionsHow to reach ClickHouse, besides its host.
Default.pub const DEFAULT_DATABASE: &str = "default"The default database, default.
pub const DEFAULT_PORT: i64 = 8123The ClickHouse HTTP port, 8123.
pub const DEFAULT_TABLE: &str = "audits"The default table name, audits.
adapter::database
Own page[Database]: logs as documents of a utopia-database collection.
use utopia_audit::adapter::database::Database;pub struct DatabaseThe database must exist before Adapter::setup creates the
collection.
Debug.