Expand description
§Scry Protocol
Event protocol for Scry SQL proxy. Provides types and serialization for query events captured by the proxy.
§Features
- Event Types:
QueryEventandQueryEventBuilderfor constructing events - FlexBuffers Serialization: Efficient, schema-less binary serialization
- FlexBuffers Deserialization: Deserialize event batches from binary format
- Batch Support: Serialize and deserialize multiple events in a single batch
§Wire Format
Events are serialized using FlexBuffers, a schema-less binary format from the FlatBuffers project. This provides:
- Compact binary representation
- Backward/forward compatibility
- Zero-copy deserialization capabilities
- Works seamlessly with serde
§Example: Serialization
use scry_protocol::{QueryEventBuilder, FlatBuffersSerializer};
use std::time::Duration;
let event = QueryEventBuilder::new("SELECT * FROM users")
.connection_id("conn-123")
.database("mydb")
.duration(Duration::from_millis(5))
.build();
let batch = vec![event];
let bytes = FlatBuffersSerializer::serialize_batch(&batch, "proxy-1", 0);§Example: Deserialization
use scry_protocol::FlexBuffersDeserializer;
let result = FlexBuffersDeserializer::deserialize_batch(&bytes);
match result {
Ok(batch) => {
println!("Proxy ID: {}", batch.proxy_id);
println!("Batch seq: {}", batch.batch_seq);
println!("Events: {}", batch.events.len());
}
Err(e) => eprintln!("Deserialization error: {}", e),
}Modules§
- database_
event - Database event types and serialization.
Structs§
- Deserialized
Batch - A deserialized batch of query events
- Duration
- A
Durationtype to represent a span of time, typically used for system timeouts. - Flat
Buffers Serializer - Serializes a batch of QueryEvents to FlexBuffers format
- Flex
Buffers Deserializer - Deserializes batches of QueryEvents from FlexBuffers format
- Query
Event - Represents a captured SQL query event from the proxy
- Query
Event Builder - Builder for creating QueryEvent instances
- System
Time - A measurement of the system clock, useful for talking to external entities like the file system or other processes.
Enums§
- Param
Value - Represents a typed parameter value from PostgreSQL’s Bind message.