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_addr | SocketAddr | QUIC endpoint (default 127.0.0.1:4433) |
| source_name | String | Unique source identifier |
| schema | SchemaId | Newtype ID referencing a registered schema |
| compression | Compression | None, Lz4, Zstd { level } |
| spill_buffer | SpillBuffer | Ring buffer with disk spill on backpressure |
| command_handler | Option<CommandHandler> | Callback for server-initiated commands |
TetrapusClient API
| Method | Signature |
|---|---|
| connect | async fn connect(config: TetrapusConfig) -> Result<Self> |
| send | async fn send(&self, payload: &[u8]) -> Result<()> |
| send_batch | async fn send_batch(&self, items: Vec<Vec<u8>>) -> Result<()> |
| shutdown | async 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.