Expand description
Database event types and serialization.
This module provides types for database replication events (COPY, CDC, proxy) with FlexBuffers serialization for efficient wire format.
§Design
The key design decision is storing PostgreSQL binary format bytes directly
in ColumnValue.data to enable zero-copy for the high-throughput COPY path.
§Example
use scry_protocol::database_event::{
DatabaseEventBuilder, BatchBuilder, Row, ColumnValue, TypeTag,
serialize_batch, read_batch,
};
// Build an event
let event = DatabaseEventBuilder::insert("public", "users")
.position(12345)
.new_row(Row::new(vec![
ColumnValue::from_pg_binary(TypeTag::Int32, 23, vec![0, 0, 0, 1]),
]))
.build();
// Build a batch
let mut builder = BatchBuilder::new().source_id("my-source");
builder.add_event(event);
let batch = builder.finish().unwrap();
// Serialize
let bytes = serialize_batch(&batch).unwrap();
// Deserialize
let recovered = read_batch(&bytes).unwrap();Structs§
- Batch
Builder - Builder for constructing batches of events with efficient serialization.
- Column
Meta - Column metadata.
- Column
Value - A single column value. Uses raw PostgreSQL binary format bytes for zero-copy efficiency.
- Database
Event - A single database event.
- Database
Event Batch - Batch of events for efficient transport.
- Database
Event Builder - Builder for constructing a single DatabaseEvent.
- Relation
Meta - Relation (table) metadata.
- Row
- A row of column values.
- Sequence
Value - A PostgreSQL sequence value for synchronization.
Enums§
- Control
Directive - Control directive for coordinating producer/receiver behavior.
- Operation
Type - Database operation type.
- Replica
Identity - PostgreSQL replica identity setting.
- TypeTag
- Type tag for fast dispatch without parsing OID. Maps to PostgreSQL type categories.
Functions§
- read_
batch - Deserialize a batch from FlexBuffers format.
- read_
event - Deserialize a single event from FlexBuffers format.
- serialize_
batch - Serialize a batch to FlexBuffers format.
- serialize_
event - Serialize a single event to FlexBuffers format.