Skip to main content

Crate featherbit

Crate featherbit 

Source
Expand description

§featherbit

A high-performance API gateway delivered as a single Rust binary.

Featherbit routes traffic through node-graph policies declared in YAML: each policy is a pipeline of nodes wired together by success/error ports. Plugins come in two tiers — 13 native Rust plugins (proxying, auth, rate-limiting, CORS, logging, …) plus scripted plugins written in Lua. A context::Context object (request, response, message, errors) flows through every node in the pipeline. Operations are handled by an admin REST API with an embedded React UI, configuration hot-reload via a file watcher, and Prometheus metrics per route and per node.

§Architecture

Request flow: HTTP request → server::listener matches a route → builds a ContextCompiledGraph::execute() walks the policy’s nodes following success/error ports → the final Context.response is sent to the client.

Configuration lives in two files: system.yaml (listeners, timeouts, admin API, logging) and gateway.yaml (routes and policies). Both support ${ENV_VAR:-default} interpolation and the latter is hot-reloaded on change.

Modules§

admin 🔒
Admin API and UI server.
balancer 🔒
Shared upstream load balancer.
batch 🔒
Batching sink for logger plugins.
config 🔒
Configuration loading and schema types for the gateway’s two YAML files: system.yaml (process-level settings: listener, timeouts, admin, logging) and gateway.yaml (routes and node-graph policies). All values support ${ENV_VAR:-default} interpolation: raw YAML file text is interpolated by load_yaml_with_env, and structured plugin config authored through the Admin API / Web UI (or delivered over etcd) is interpolated at graph-compile time by interpolate_env_json.
config_store 🔒
Configuration source abstraction.
consumers 🔒
Consumer identities and credentials.
context 🔒
The per-request Context object that flows through every node of a policy graph, carrying the inbound request, the response under construction, free-form inter-node state, and any errors accumulated along the way. Serializable so it can be marshalled to and from Lua scripts.
debug 🔒
Debug mode: per-request policy-execution tracing and the plugin sandbox.
graph 🔒
Node-graph policy engine: compiles YAML-declared policies into executable pipelines and validates their structure.
hot_reload 🔒
Hot-reload of the gateway configuration: watches gateway.yaml for changes (via the notify crate) and triggers a SharedState reload so route and policy edits apply without restarting the process.
metrics 🔒
Prometheus metrics for the gateway: per-route request counters and latency histograms plus per-node execution metrics, rendered in the Prometheus text format at the Admin API’s /metrics endpoint.
outbound 🔒
Shared outbound HTTP client for plugin callouts and upstream proxying.
plugins 🔒
Two-tier plugin system: native Rust plugins (native) and scripted plugins (script). Defines the Plugin trait — the contract every graph node implements — and create_plugin, the single factory that maps node-type strings from YAML config to plugin instances.
ratelimit 🔒
Pluggable counter backends for rate-limiting plugins.
routing 🔒
Route matching: decides which configured route (and thus which policy graph) handles an incoming request, based on path, method, header, and host rules from gateway.yaml.
server 🔒
Data-plane HTTP server: accepts client connections, matches routes, and runs the matched policy graph for each request.
state 🔒
Shared, lock-protected gateway state used by the data plane, the Admin API, and the hot-reload watcher. Owns the current gateway config and the routes compiled from it, and provides the recompile/swap operations.
stream 🔒
L4 (TCP/UDP) stream proxying — a data path independent of the HTTP engine.
traffic 🔒
Shared state for traffic-control plugins whose logic spans the upstream call — concurrency limits, circuit breakers, and response caching.
vars 🔒
Request/response variable resolution and condition expressions.

Structs§

Cli 🔒
Command-line arguments: paths to the two YAML configuration files.

Functions§

build_etcd_source 🔒
Builds the etcd config store and the initial gateway config (seeding etcd from the local file when the prefix is empty).
init_logging 🔒
Initializes the global tracing subscriber in JSON or plain-text format.
main 🔒
shutdown_signal 🔒
Completes when the process receives a termination signal: Ctrl+C on any platform, or SIGTERM on Unix (the signal container orchestrators send).
spawn_etcd_watch 🔒
Spawns the etcd watch task (cluster-wide config convergence).