tsoracle-server
Embeddable gRPC server for the tsoracle timestamp oracle.
Wires four pieces together: the sync window allocator from tsoracle-core, a user-supplied ConsensusDriver (leadership state + durable high-water persistence), the tonic-generated TsoService from tsoracle-proto, and the internal leader-watch pipeline + failover fence that keep timestamps strictly monotonic across leader transitions.
What's in the box
Server+ServerBuilder— the embedding entry point. Provide aConsensusDriverimpl, optional TLS config, optional metrics recorder, and serve on aSocketAddror pre-boundTcpListener.BuildError— surfaces invalid configurations at build time (missing driver, conflicting TLS settings, …).ServerError— runtime errors from the serving task.ServingState— observability snapshot for the leader-watch state machine.Bt— backtrace-on-error helper embedded in instrumentedServerErrorvariants. ZST and no-op unless thebtfeature is on; with it on, capture is still gated byRUST_BACKTRACE/RUST_LIB_BACKTRACE.
Usage shape
use Server;
use FileDriver;
async
See examples/embedded-server for graceful Ctrl-C shutdown, and the HA examples (openraft-standalone, openraft-piggyback, paxos-standalone, paxos-piggyback, paxos-embedded) for swapping the file driver out for a replicated one.
Follower behavior
Followers respond to RPCs with FAILED_PRECONDITION and a tsoracle-leader-hint-bin binary trailer. tsoracle-client consumes the hint to redirect transparently — no extra round trip.
Feature flags
tls-rustls(default) — TLS via rustls (tonic/tls-aws-lc).tls-native— TLS via the platform's native trust roots (tonic/tls-native-roots). Mutually exclusive withtls-rustlsat the consumer level; pick one.tracing(default) — emit tracing spans/events through thetracingfacade.metrics— emit allocator, leader, and request metrics through themetricsfacade.failpoints— enablesfailcrate injection for chaos coverage.yieldpoints— enablestsoracle-yieldpointinjection sites (async sibling of failpoints; off by default since production carries zero overhead).test-fakes/test-support— test-only fixtures for downstream integration suites.bt— capturesstd::backtrace::Backtracein instrumentedServerErrorvariants. Off by default to keep cold paths free.
Documentation
docs/key-subsystems.md— the leader-watch + failover fence pipeline in depth.docs/operations.md— deployment guidance, TLS, metrics shape.docs/consensus-integration.md— picking and implementing aConsensusDriver.