Skip to main content

tsoracle_server/
lib.rs

1//
2//  ░▀█▀░█▀▀░█▀█░█▀▄░█▀█░█▀▀░█░░░█▀▀
3//  ░░█░░▀▀█░█░█░█▀▄░█▀█░█░░░█░░░█▀▀
4//  ░░▀░░▀▀▀░▀▀▀░▀░▀░▀░▀░▀▀▀░▀▀▀░▀▀▀
5//
6//  tsoracle — Distributed Timestamp Oracle
7//
8//  Copyright (c) 2026 Prisma Risk
9//  Licensed under the Apache License, Version 2.0
10//  https://github.com/prisma-risk/tsoracle
11//
12
13//! gRPC server for tsoracle.
14//!
15//! Wires four pieces together:
16//! - [`tsoracle_core::Allocator`] — the sync window allocator.
17//! - A user-supplied [`tsoracle_consensus::ConsensusDriver`] — leadership
18//!   state plus durable high-water persistence.
19//! - The tonic-generated `TsoServiceServer` from `tsoracle-proto`,
20//!   mounted on `GetTs` and `GetTsBatch`.
21//! - The internal leader-watch pipeline and failover fence, which keep
22//!   timestamps strictly monotonic across leader transitions.
23
24// Panic policy (see CONTRIBUTING.md). `cfg_attr(not(test), ...)` skips the lint
25// for the lib's own unit tests; integration tests are separate compilation units.
26#![cfg_attr(not(test), warn(clippy::unwrap_used, clippy::expect_used))]
27//!
28//! Followers respond to RPCs with `FAILED_PRECONDITION` and a
29//! `tsoracle-leader-hint-bin` binary trailer; `tsoracle-client` consumes
30//! the hint to redirect without an extra round-trip.
31//!
32//! Use [`Server::builder`] to embed in another binary, or use the
33//! `tsoracle` CLI from `tsoracle-bin` for a standalone process. The
34//! [`docs`] module contains the docs.rs-rendered operations chapter; the
35//! repo's `docs/key-subsystems.md` covers the same internals in depth.
36//!
37//! TLS termination is configured via
38//! `ServerBuilder::tls_config(ServerTlsConfig)`; see
39//! `docs/operations.md` for deployment guidance.
40
41#[macro_use]
42mod failpoint;
43mod fence;
44mod leader_hint;
45mod server;
46mod service;
47
48pub mod docs;
49
50pub use server::{BuildError, Server, ServerBuilder, ServerError, ServingState};
51
52#[cfg(any(test, feature = "test-fakes"))]
53pub mod test_fakes;
54
55#[cfg(any(test, feature = "test-support"))]
56pub mod test_support;
57
58#[doc(hidden)]
59pub use leader_hint::decode_leader_hint as __priv_decode_leader_hint;