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
Context → CompiledGraph::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) andgateway.yaml(routes and node-graph policies). All values support${ENV_VAR:-default}interpolation: raw YAML file text is interpolated byload_yaml_with_env, and structured plugin config authored through the Admin API / Web UI (or delivered over etcd) is interpolated at graph-compile time byinterpolate_env_json. - config_
store 🔒 - Configuration source abstraction.
- consumers 🔒
- Consumer identities and credentials.
- context 🔒
- The per-request
Contextobject 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.yamlfor changes (via thenotifycrate) and triggers aSharedStatereload 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
/metricsendpoint. - 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 thePlugintrait — the contract every graph node implements — andcreate_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
tracingsubscriber in JSON or plain-text format. - main 🔒
- shutdown_
signal 🔒 - Completes when the process receives a termination signal: Ctrl+C on any
platform, or
SIGTERMon Unix (the signal container orchestrators send). - spawn_
etcd_ 🔒watch - Spawns the etcd watch task (cluster-wide config convergence).