Documentation
¶
Overview ¶
Package route implements the per-query branch selection used by zonegitd's canary feature.
This is intentionally a tiny subset of docs/SELECTORS.md — one rule shape only: "hash(client.subnet, salt) % 100 < pct -> branch". The full grammar is a v3 feature; what's here is what the demo actually needs to land UC5 ("send 20% of traffic to canary, snap it back on one ref move").
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BucketRouter ¶
type BucketRouter struct {
DefaultBranch string
CanaryBranch string
Pct int // 0..100; 0 disables, 100 sends everything to canary
Salt string // makes independent rollouts independent
}
BucketRouter splits traffic between two branches by hashing the client /24 (IPv4) or /48 (IPv6) into 100 buckets. Buckets 0..Pct-1 go to CanaryBranch; the rest go to DefaultBranch.
Stable: the same client subnet always lands in the same bucket given the same salt. Operators rotate the salt to "reshuffle" cohorts.
func NewBucketRouter ¶
func NewBucketRouter(defaultBranch, canarySpec, salt string) (*BucketRouter, error)
NewBucketRouter validates inputs and returns a router. canarySpec is "branch:pct" (e.g. "canary:20"). defaultBranch is what non-canary traffic resolves to.
func (*BucketRouter) Route ¶
func (b *BucketRouter) Route(q resolve.QueryContext) string
Route picks the branch for q. Implements the resolve.Router interface.
func (*BucketRouter) String ¶
func (b *BucketRouter) String() string
String returns a one-line summary suitable for the metrics info gauge.