This directory houses chainless-lb-backend, the core library crate of the Chainless-LB workspace.
Unlike traditional monolithic proxies, the backend is purposefully developed as an embeddable edge SDK. It abstracts away the heavy lifting of pingora, OpenTelemetry, circuit breaking, and protocol decoding into highly modular Rust traits. It enables you to consume this library to build your own custom edge topology or gateway endpoints (refer to the /examples/ directory for robust implementations).
-
Static Pipeline Dispatching:
- Uses zero-cost abstractions by type-locking execution pipelines at compile time via the
PipelineBuilderandErasedPipelinemapping. - Middlewares like Rate Limiters (
rate_limit.rs) and Circuit Breakers (circuit_breaker.rs) are executed rapidly without runtimeBox<dyn ...>allocation overhead.
- Uses zero-cost abstractions by type-locking execution pipelines at compile time via the
-
Kernel-Space Hooks (eBPF):
- The
/ebpf/module relies on theayaframework to natively inject safe, Rust-compiled XDP filters directly into the Linux kernel stack. - Provides mechanisms like
block_ip()andallow_ip()outside of user-space traffic limits.
- The
-
Pluggable Architecture:
- Authentication: Controlled by the
AuthProvidertrait. TheNoOpAuthprovider enables raw passthrough, while custom handlers can seamlessly verify JWTs, delegate to ORY networks, or execute local PKI checks without altering the core LB runtime. - Caching: Governed by the
CacheTrait. Natively integratesmoka(a heavily concurrent LRU cache paradigm) but is designed to allow custom SSD / persistence traits mapped directly into the internal Pingora router.
- Authentication: Controlled by the
-
Deep Observability:
- The
observability/engine dynamically routes traffic into/var/logtargets (usingtracing-appenderfor non-blocking production output) or local streams based on TOML parameters. - Natively connects
prometheushistogram payloads back out as seamless OTLP formats (gRPC or HTTP).
- The
To consume the chainless-lb-backend inside a custom Rust application, simply add it to your Cargo.toml:
[dependencies]
chainless-lb-backend = { path = "../backend" }You can then natively initialize the static topology using config::load_config() to acquire your TOML payload, and securely dispatch Pingora structures over traits logic:
use chainless_lb_backend::proxy::LB;
use chainless_lb_backend::middleware::PipelineBuilder;
// Assemble zero-cost structures statically matched with your TOML
let pipeline = PipelineBuilder::new()
.with_rate_limit(10_000)
.build();
// ... Insert into Pingora execution context natively- pingora (0.8.0): The native
C++NGINX replacement built by Cloudflare strictly handling multi-threaded event looping and downstream sockets. - moka (0.12): Used for advanced cache abstractions avoiding heavy lock contentions in
CacheTrait. - aya: Replaces raw C bindings to deploy BPF routing configurations into the OS safely.
- opentelemetry / tracing: Handles edge-level non-blocking analytics reporting to minimize request latency hits.