varta-client
Agent API — emit VLP frames over a Unix Domain Socket. One connect call
allocates a socket; every subsequent beat call is zero-allocation and
non-blocking.
Quick start
use ;
API summary
Varta
| Method | Signature | Description |
|---|---|---|
connect |
(path: impl AsRef<Path>) -> io::Result<Varta> |
Open a non-blocking UnixDatagram to the observer. The only allocation point. |
beat |
(&mut self, status: Status, payload: u64) -> BeatOutcome |
Emit one 32-byte VLP frame. Never blocks; never allocates. |
BeatOutcome
| Variant | Meaning |
|---|---|
Sent |
Kernel accepted the datagram. |
Dropped |
Observer absent, queue full, or socket vanished — treat as no-op. |
Failed(io::Error) |
Unexpected I/O error; the inner error does not allocate. |
Status
| Variant | Wire value | Meaning |
|---|---|---|
Ok |
0 |
Healthy and making progress. |
Degraded |
1 |
Making progress with elevated trouble. |
Critical |
2 |
About to die; also emitted by the panic hook. |
Stall |
3 |
Synthesised by varta-watch on silence; agents do not send this. |
Payload encoding
The 64-bit payload field is application-defined. A common convention is to
pack two u32 values:
// high 32 bits = queue depth, low 32 bits = last error code
let payload = << 32 | ;
The observer carries the payload opaquely; decoding belongs to the agent and any downstream tool that reads the exported metrics file.
panic-handler feature flag
Enable the optional panic hook to emit a Status::Critical frame before
normal unwinding:
# Cargo.toml
[]
= "../varta-client"
= ["panic-handler"]
// Call once at process start, before any other setup.
install_panic_handler;
The hook chains the previously installed hook (preserving the default panic
message and any user hooks). The sole heap allocation is the Box created by
std::panic::set_hook at install time; the hook closure itself is stack-only.
Constraints
- Zero production dependencies.
[dependencies]is empty (plus the path dep onvarta-vlp); no registry crate is pulled in. - Zero steady-state allocation. After
Varta::connect,beat()does not touch the heap. Verified by a guard-allocator test invarta-tests. - Non-blocking.
beat()callsset_nonblocking(true)on the socket;WouldBlockis treated asDropped— the caller never stalls.
See also
- Protocol crate:
crates/varta-vlp/README.md - Examples:
crates/varta-client/examples/ - Architecture:
docs/architecture/vlp-frame.md