Expand description
Traffic-split plugin (traffic-split) — a port of Apache APISIX’s
traffic-split plugin for weighted / conditional traffic steering
(canary, blue-green, A/B).
A request is matched against an ordered list of rules; the first rule
whose match condition passes selects a set of weighted_upstreams. One
weighted slot is then picked by weighted round-robin. A slot either names a
concrete target set (upstream.targets) or carries only a weight (the
“default” slot, meaning “use the route’s normal upstream”).
Split-node wiring (featherbit design — read this before wiring the
graph). This node sits before the route’s normal upstream node. It
exposes the usual success / error ports and the caller wires them so
that the two outcomes reach the right place:
- Default slot picked (or no rule matched): the plugin returns
Ok(ctx)unchanged. Wiresuccess→ the rest of the pipeline (the normalupstreamnode). The request is proxied by the route as usual. - Target slot picked: the plugin proxies the request itself to the
chosen target (reusing the shared outbound client), writes the backend’s
reply onto
Context.response, and short-circuits by returningErr(code TRAFFIC_SPLIT_ROUTED)with the response already populated. Wireerror→client.in(the same conventionfault-injectionandmockinguse for “stop here, send this response”). If the split target itself is unreachable the node fails withTRAFFIC_SPLIT_UPSTREAM_ERRORand a prepared502body — also routed througherror.
This makes canary/blue-green trivial: give the default slot weight 90 and a canary target set weight 10, and 10% of matching traffic is proxied to the canary while the other 90% falls through to the normal upstream.
Structs§
- Rule 🔒
- Slot 🔒
- Target 🔒
- A single backend address (
host:port) a split slot forwards to. - Traffic
Split Plugin - Steers matching requests to a weighted set of upstream targets, or lets them fall through to the route’s normal upstream.
Functions§
- parse_
targets 🔒 - Parses a
{targets: [{host, port}], ...}upstream object into a target list. Entries missinghost/portare skipped; an empty result is an error (anupstreamblock must name at least one reachable target).