| Crates.io | fgp-daemon |
| lib.rs | fgp-daemon |
| version | 0.1.0 |
| created_at | 2026-01-14 07:47:04.219675+00 |
| updated_at | 2026-01-14 07:47:04.219675+00 |
| description | Fast Gateway Protocol SDK for building low-latency daemon services |
| homepage | |
| repository | https://github.com/wolfiesch/fgp-daemon |
| max_upload_size | |
| id | 2042380 |
| size | 89,572 |
Rust SDK for building Fast Gateway Protocol (FGP) daemons.
FGP daemons use UNIX sockets with NDJSON framing to achieve 10-30ms response times, compared to 200-500ms for stdio-based protocols like MCP.
Add to your Cargo.toml:
[dependencies]
fgp-daemon = "0.1"
Create a daemon:
use fgp_daemon::{FgpServer, FgpService};
use std::collections::HashMap;
use serde_json::Value;
use anyhow::Result;
struct MyService;
impl FgpService for MyService {
fn name(&self) -> &str { "my-service" }
fn version(&self) -> &str { "1.0.0" }
fn dispatch(&self, method: &str, params: HashMap<String, Value>) -> Result<Value> {
match method {
"echo" => Ok(serde_json::json!({"echo": params})),
_ => anyhow::bail!("Unknown method: {}", method),
}
}
}
fn main() -> Result<()> {
let server = FgpServer::new(MyService, "~/.fgp/services/my-service/daemon.sock")?;
server.serve()
}
health, stop, methods handled automaticallyRequest:
{"id":"uuid","v":1,"method":"service.action","params":{}}
Response:
{"id":"uuid","ok":true,"result":{},"error":null,"meta":{"server_ms":12}}
See FGP-PROTOCOL.md for the full specification.
Run the echo daemon example:
cargo run --example echo_daemon
Test with netcat:
echo '{"id":"1","v":1,"method":"health","params":{}}' | nc -U ~/.fgp/services/echo/daemon.sock
use fgp_daemon::FgpClient;
let client = FgpClient::new("~/.fgp/services/gmail/daemon.sock")?;
// Call a method
let response = client.call("gmail.list", serde_json::json!({"limit": 10}))?;
// Built-in convenience methods
let health = client.health()?;
let methods = client.methods()?;
client.stop()?;
MIT