Help us shape the future of Go! Take the 2026 Go Developer Survey

canary

package
v0.3.2-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package canary watches progressive traffic shifts and rolls back on SLO breaches.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Steps          []float64
	Every          time.Duration
	MaxP95Latency  time.Duration
	MaxHTTP5xxRate float64
}

Config defines the release progression and SLO boundaries.

func ConfigFromDeploy

func ConfigFromDeploy(deploy *ast.DeployDecl) (Config, error)

ConfigFromDeploy derives canary steps, interval, and SLO limits from an AxLang deploy.

type HTTPController

type HTTPController struct {
	BaseURL      string
	ShiftPath    string
	RollbackPath string
	Token        string
	Client       *http.Client
}

HTTPController calls a deployment service to change traffic weight or roll back.

func (HTTPController) Rollback

func (h HTTPController) Rollback(ctx context.Context) error

func (HTTPController) Shift

func (h HTTPController) Shift(ctx context.Context, percent float64) error

type MetricsSource

type MetricsSource interface {
	Sample(context.Context) (Snapshot, error)
}

MetricsSource supplies canary health metrics.

type PrometheusSource

type PrometheusSource struct {
	BaseURL      string
	P95Query     string
	HTTP5xxQuery string
	Client       *http.Client
}

PrometheusSource reads latency and 5xx metrics from the Prometheus query API.

func (PrometheusSource) Sample

func (p PrometheusSource) Sample(ctx context.Context) (Snapshot, error)

Sample executes configured PromQL queries. Latency results are seconds; rate results are fractions between 0 and 1.

type Snapshot

type Snapshot struct {
	P95Latency  time.Duration
	HTTP5xxRate float64
}

Snapshot is a point-in-time view of deployment health metrics.

type TrafficController

type TrafficController interface {
	Shift(context.Context, float64) error
	Rollback(context.Context) error
}

TrafficController shifts traffic and can restore the previous stable version.

type Watcher

type Watcher struct {
	Metrics MetricsSource
	Traffic TrafficController
}

Watcher observes metrics after each canary step and stops on the first violation.

func (*Watcher) Run

func (w *Watcher) Run(ctx context.Context, cfg Config) error

Run performs each traffic step, waits between steps, and rolls back on unsafe or unknown health state. A successful return means the final step reached 100%.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL