Skip to main content

Crate scry_protocol

Crate scry_protocol 

Source
Expand description

§Scry Protocol

Event protocol for Scry SQL proxy. Provides types and serialization for query events captured by the proxy.

§Features

  • Event Types: QueryEvent and QueryEventBuilder for 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§

DeserializedBatch
A deserialized batch of query events
Duration
A Duration type to represent a span of time, typically used for system timeouts.
FlatBuffersSerializer
Serializes a batch of QueryEvents to FlexBuffers format
FlexBuffersDeserializer
Deserializes batches of QueryEvents from FlexBuffers format
QueryEvent
Represents a captured SQL query event from the proxy
QueryEventBuilder
Builder for creating QueryEvent instances
SystemTime
A measurement of the system clock, useful for talking to external entities like the file system or other processes.

Enums§

ParamValue
Represents a typed parameter value from PostgreSQL’s Bind message.