pub struct ChangeLogWrite<'a> {
pub object_type: &'a str,
pub modification_type: &'a str,
pub tenant_id: Option<Uuid>,
pub trace_id: Option<&'a str>,
pub schema_version: Option<&'a str>,
pub trace_context: Option<&'a str>,
}Expand description
The framework-owned change-log row the mutation executor writes in-txn.
Carries only the fields the adapter cannot derive from the
app.mutation_response row it already holds: the DML verb and a NOT-NULL
object_type fallback. The changed-entity identity + payload (object_id,
object_data, updated_fields, cascade) are read from the function’s own
returned row inside the same transaction (see
DatabaseAdapter::execute_function_call_with_changelog).
This is the Change Spine transactional-outbox contract. Beyond the
object_type/modification_type + changed-entity columns, it stamps the
envelope: tenant_id (carried here, from SecurityContext),
trace_id (the W3C trace id of the originating request), schema_version
(the compiled schema’s content hash — a per-deployment constant),
trace_context (the full W3C trace context as JSON), commit_time
(clock_timestamp() at INSERT), and seq (the table’s SEQUENCE default).
The remaining envelope columns (actor_type, acting_for) stay NULL pending
their upstream issue (#390).
Fields§
§object_type: &'a strNOT-NULL fallback for object_type when the row’s entity_type is NULL.
Sourced from MutationDefinition.return_type (always present).
modification_type: &'a strThe DML verb written to modification_type (e.g. "INSERT",
"UPDATE", "DELETE", "CUSTOM"), from MutationOperation.
tenant_id: Option<Uuid>The tenant partition stamp written to the tenant_id UUID column — the
Trinity public-facing identifier, read from SecurityContext.tenant_id
at write time and never reconstructed from connection / RLS state
(RLS is PG-only; out-of-session spine consumers bypass it, so the row
must carry tenant identity explicitly). None (→ SQL NULL) for an
unauthenticated request, a request with no tenant, or a tenant
identifier that is not a UUID.
trace_id: Option<&'a str>The W3C trace id of the originating request, written to the trace_id
column so an outbox row links back to its distributed trace (the #392
perf tooling surfaces it as the investigation handle). Read from the
request’s traceparent header at write time; None (→ SQL NULL) for a
request without a trace context — e.g. an unauthenticated mutation, which
carries no SecurityContext to stamp.
schema_version: Option<&'a str>The compiled schema’s version written to the schema_version column so an
outbox row records which deployment produced it — the replay /
zero-downtime correctness handle for #378 (reject a row replayed under a
different schema). A per-deployment constant derived from the compiled
schema (CompiledSchema::content_hash()), not from the request, so it
changes on any schema change. None (→ SQL NULL) for producers with no
compiled schema in scope — cooperative external producers (ETL) and the
non-PostgreSQL no-op path.
trace_context: Option<&'a str>The originating request’s full W3C trace context as a JSON object
({version, trace_id, parent_id, trace_flags, tracestate?}), written to the
trace_context JSONB column so a row carries enough to re-propagate /
reconstruct the distributed trace — not just the scalar trace_id. Carried
here as pre-serialized JSON text (the adapter binds it to the JSONB
column). Built from the request’s traceparent / tracestate headers at
write time; None (→ SQL NULL) for a request without a valid trace context,
consistent with trace_id.
Implementations§
Source§impl<'a> ChangeLogWrite<'a>
impl<'a> ChangeLogWrite<'a>
Sourcepub const fn new(object_type: &'a str, modification_type: &'a str) -> Self
pub const fn new(object_type: &'a str, modification_type: &'a str) -> Self
Build a change-log write descriptor with no envelope stamps (tenant_id,
trace_id, schema_version and trace_context NULL). Chain
with_tenant_id /
with_trace_id /
with_schema_version /
with_trace_context to stamp them.
Sourcepub const fn with_tenant_id(self, tenant_id: Option<Uuid>) -> Self
pub const fn with_tenant_id(self, tenant_id: Option<Uuid>) -> Self
Stamp the tenant partition id (the Trinity public-facing UUID) onto the
outbox row. None leaves tenant_id NULL — for system / unauthenticated
rows, or a tenant identifier that is not UUID-shaped.
Sourcepub const fn with_trace_id(self, trace_id: Option<&'a str>) -> Self
pub const fn with_trace_id(self, trace_id: Option<&'a str>) -> Self
Stamp the originating request’s W3C trace id onto the outbox row. None
leaves trace_id NULL — for a request with no trace context.
Sourcepub const fn with_schema_version(self, schema_version: Option<&'a str>) -> Self
pub const fn with_schema_version(self, schema_version: Option<&'a str>) -> Self
Stamp the compiled schema’s version (its content hash) onto the outbox
row. None leaves schema_version NULL — for producers with no compiled
schema in scope (cooperative external producers, the non-PostgreSQL no-op
path).
Sourcepub const fn with_trace_context(self, trace_context: Option<&'a str>) -> Self
pub const fn with_trace_context(self, trace_context: Option<&'a str>) -> Self
Stamp the originating request’s full W3C trace context (pre-serialized JSON
text) onto the outbox row’s trace_context JSONB column. None leaves it
NULL — for a request with no valid trace context, or a non-PostgreSQL
no-op / cooperative producer.
Trait Implementations§
Source§impl<'a> Clone for ChangeLogWrite<'a>
impl<'a> Clone for ChangeLogWrite<'a>
Source§fn clone(&self) -> ChangeLogWrite<'a>
fn clone(&self) -> ChangeLogWrite<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more