SDK Integration

The nerve-sdk crate connects external data sources to Tetrapus over QUIC with bidirectional command channels.

Architecture

Text
Your App → TetrapusClient → QUIC (4433) → tetrapus-server
                  |                                    |
            SpillBuffer                          WAL + Routing
                  |                                    |
            CommandHandler ←— bidi stream ←— Commands

TetrapusConfig

Field Type Description
server_addrSocketAddrQUIC endpoint (default 127.0.0.1:4433)
source_nameStringUnique source identifier
schemaSchemaIdNewtype ID referencing a registered schema
compressionCompressionNone, Lz4, Zstd { level }
spill_bufferSpillBufferRing buffer with disk spill on backpressure
command_handlerOption<CommandHandler>Callback for server-initiated commands

TetrapusClient API

Method Signature
connectasync fn connect(config: TetrapusConfig) -> Result<Self>
sendasync fn send(&self, payload: &[u8]) -> Result<()>
send_batchasync fn send_batch(&self, items: Vec<Vec<u8>>) -> Result<()>
shutdownasync fn shutdown(self) -> Result<()>

Basic Usage

Rust
use nerve_sdk::{TetrapusConfig, TetrapusClient, Compression};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let config = TetrapusConfig::builder()
        .server_addr("127.0.0.1:4433".parse()?)
        .source_name("my-sensor-fleet")
        .compression(Compression::Lz4)
        .build();

    let client = TetrapusClient::connect(config).await?;
    client.send(b"temperature=22.5").await?;
    client.shutdown().await
}

Command Handler

Register a callback to receive server-initiated commands over the bidirectional QUIC stream.

Rust
let config = TetrapusConfig::builder()
    .command_handler(|cmd| async move {
        match cmd.kind.as_str() {
            "set_interval" => { /* adjust sampling */ }
            "shutdown" => { /* graceful stop */ }
            _ => {}
        }
        Ok(())
    })
    .build();

Questions?

Reach out for help with integration, deployment, or custom domain codecs.