canary

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package canary provides canary deployment capabilities for TokMan

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnalysisConfig

type AnalysisConfig struct {
	Enabled          bool
	Interval         time.Duration
	SuccessfulRuns   int
	FailedRuns       int
	LookbackDuration time.Duration
	ConfidenceLevel  float64
}

AnalysisConfig defines automated analysis settings

type Deployment

type Deployment struct {
	ID             string
	Name           string
	Service        string
	CurrentVersion string
	TargetVersion  string
	Status         DeploymentStatus
	Strategy       Strategy
	TrafficSplit   TrafficSplit
	Metrics        Metrics
	Analysis       AnalysisConfig
	RollbackConfig RollbackConfig
	Phases         []Phase
	CurrentPhase   int
	// contains filtered or unexported fields
}

Deployment manages canary releases

func (*Deployment) Abort

func (d *Deployment) Abort(reason string) error

Abort stops the deployment

func (*Deployment) OnEvent

func (d *Deployment) OnEvent(handler EventHandler)

OnEvent registers an event handler

func (*Deployment) Rollback

func (d *Deployment) Rollback() error

Rollback rolls back the deployment

func (*Deployment) Start

func (d *Deployment) Start(ctx context.Context) error

Start begins a canary deployment

type DeploymentConfig

type DeploymentConfig struct {
	Name           string
	Service        string
	CurrentVersion string
	TargetVersion  string
	Strategy       Strategy
	Metrics        Metrics
	Analysis       AnalysisConfig
	Rollback       RollbackConfig
	Steps          int
	StepWeight     float64
}

DeploymentConfig holds deployment configuration

type DeploymentStatus

type DeploymentStatus string

DeploymentStatus represents the state of a deployment

const (
	StatusPending     DeploymentStatus = "pending"
	StatusRunning     DeploymentStatus = "running"
	StatusPromoting   DeploymentStatus = "promoting"
	StatusPromoted    DeploymentStatus = "promoted"
	StatusRollingBack DeploymentStatus = "rolling_back"
	StatusRolledBack  DeploymentStatus = "rolled_back"
	StatusFailed      DeploymentStatus = "failed"
	StatusAborted     DeploymentStatus = "aborted"
)

type Event

type Event struct {
	Type       EventType
	Timestamp  time.Time
	Deployment string
	Phase      string
	Message    string
	Data       map[string]interface{}
}

Event represents a deployment event

type EventHandler

type EventHandler func(event Event)

EventHandler handles deployment events

type EventType

type EventType string

EventType represents the type of event

const (
	EventStarted       EventType = "started"
	EventPhaseStarted  EventType = "phase_started"
	EventPhaseComplete EventType = "phase_complete"
	EventPromoted      EventType = "promoted"
	EventRollback      EventType = "rollback"
	EventFailed        EventType = "failed"
	EventAborted       EventType = "aborted"
)

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager manages canary deployments

func NewManager

func NewManager() *Manager

NewManager creates a canary deployment manager

func (*Manager) CreateDeployment

func (m *Manager) CreateDeployment(config DeploymentConfig) (*Deployment, error)

CreateDeployment creates a new canary deployment

func (*Manager) GetDeployment

func (m *Manager) GetDeployment(id string) (*Deployment, error)

func (*Manager) ListDeployments

func (m *Manager) ListDeployments() []*Deployment

ListDeployments returns all deployments

type MetricThreshold

type MetricThreshold struct {
	Min       *float64
	Max       *float64
	Target    float64
	Tolerance float64
}

MetricThreshold defines a threshold for a custom metric

type Metrics

type Metrics struct {
	ErrorRateThreshold  float64
	LatencyP99Threshold time.Duration
	LatencyP95Threshold time.Duration
	LatencyP50Threshold time.Duration
	ThroughputMin       float64
	CustomMetrics       map[string]MetricThreshold
}

Metrics holds metric thresholds for analysis

type Phase

type Phase struct {
	ID            string
	Name          string
	TrafficWeight float64
	Duration      time.Duration
	Pause         time.Duration
	Metrics       PhaseMetrics
	Status        PhaseStatus
	StartTime     time.Time
	EndTime       time.Time
}

Phase represents a canary phase

type PhaseMetrics

type PhaseMetrics struct {
	Requests   int64
	Errors     int64
	ErrorRate  float64
	LatencyP50 time.Duration
	LatencyP95 time.Duration
	LatencyP99 time.Duration
	Throughput float64
}

PhaseMetrics holds metrics for a phase

type PhaseStatus

type PhaseStatus string

PhaseStatus represents phase status

const (
	PhaseStatusPending   PhaseStatus = "pending"
	PhaseStatusRunning   PhaseStatus = "running"
	PhaseStatusWaiting   PhaseStatus = "waiting"
	PhaseStatusCompleted PhaseStatus = "completed"
	PhaseStatusFailed    PhaseStatus = "failed"
)

type RollbackConfig

type RollbackConfig struct {
	Enabled           bool
	AutoRollback      bool
	OnErrorRate       float64
	OnLatencyIncrease float64
	OnMetricFailure   []string
	ManualApproval    bool
}

RollbackConfig defines rollback behavior

type Strategy

type Strategy string

Strategy defines the canary strategy

const (
	StrategyLinear   Strategy = "linear"
	StrategyStepped  Strategy = "stepped"
	StrategyAnalysis Strategy = "analysis"
	StrategyShadow   Strategy = "shadow"
)

type TrafficSplit

type TrafficSplit struct {
	Canary   float64
	Baseline float64
	Stable   float64
}

TrafficSplit defines how traffic is distributed

Jump to

Keyboard shortcuts

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