crates/nornir-flight/src/lib.rs
//! # nornir-flight
//!
//! The constellation's ONE generic **Apache Arrow Flight transport seam**
//! (LAW #5, reuse). It is deliberately *use-case-agnostic*: raw Flight verbs
//! (`do_put` / `do_get` / `do_exchange`) over `RecordBatch`, plus two
//! schema-agnostic traits ([`FlightSink`] / [`FlightSource`]). Every actual Flight
//! use in nordisk — the build-info stream, skade-flight, a future knut
//! Flight-shuffle — is an **independent consumer on top of this transport**, not
//! a fork of it.
//!
//! ## What is shared vs. what is not
//! * **Shared (here):** the wire — tonic bootstrap, framing/backpressure, and
//! the three verbs, composing `nornir-service`'s bearer-auth interceptor and
//! serve loop (auth is **not re-rolled** — [`FlightServer`] wraps
//! `nornir_service::auth_interceptor` + `nornir_service::serve`).
//! * **NOT shared:** the schema and the meaning of the bytes. `graphar-flight`
//! (knut) is a *separate* Flight use (Cypher → Arrow **Flight-SQL**); it shares
//! nothing with this but the wire. Its `server.rs` was the working **precedent**
//! this bootstrap mirrors — not a dependency.
//!
//! ## The seam
//! * [`FlightServer::serve`] / [`FlightServer::serve_with_auth`] — start the
//! tonic Flight service over a [`FlightRoutes`] at an address.
//! * [`FlightSink`] — a producer's `do_put` target (decode → hand off batches).
//! * [`FlightSource`] — a consumer's `do_get` source (resolve ticket → batches).
//! * [`MemFlightStore`] — an in-memory reference impl of both (what the
//! round-trip test drives; also a real single-box sink).
//! * [`FlightConn`] — a thin client over the three verbs (bearer-aware).
//!
//! ## Round-trip contract
//! `put(key, batches)` then `get(key)` (or `exchange(key, batches)`) returns the
//! batches **byte-identical** — the property the acceptance test pins.
#[cfg(feature = "bench")]
pub mod bench;
mod client;
/// The Flight SQL door: Basic/bearer auth and the ODBC-safe handshake, shared
/// by every nordisk Flight SQL server.
pub mod door;
mod error;
mod server;
mod store;
mod traits;
pub use client::FlightConn;
pub use error::{Error, Result};
pub use server::{FlightRoutes, FlightServer, NornirFlightService};
pub use store::MemFlightStore;
pub use traits::{FlightSink, FlightSource};
// Re-export the batch/schema types callers deal in, so a consumer needs only
// this crate on its transport surface (the schema itself stays the caller's).
pub use arrow_array::RecordBatch;
pub use arrow_schema::{Schema, SchemaRef};
/// Emit a functional-status marker into the nornir test-matrix.
///
/// Wraps `nornir_testmatrix::functional_status` behind the `testmatrix` feature:
/// ON, each serve/put/get/exchange records a `(component, check, ok, detail)`
/// row read back by the matrix; OFF (default), it is a zero-cost no-op with no
/// nornir dependency — release builds strip it (L4). Same pattern graphar-flight
/// uses, so the two Flight uses report into one matrix.
#[cfg(feature = "testmatrix")]
#[inline]
pub fn functional_status(component: &str, check: &str, ok: bool, detail: &str) {
nornir_testmatrix::functional_status(component, check, ok, detail);
}
/// No-op fallback when the `testmatrix` feature is off (see the gated variant).
#[cfg(not(feature = "testmatrix"))]
#[inline]
pub fn functional_status(_component: &str, _check: &str, _ok: bool, _detail: &str) {}