Documentation
¶
Overview ¶
Package chaos provides chaos engineering capabilities for TokMan
Package chaos provides additional chaos experiments
Index ¶
- func BlastRadius(experiment *Experiment, services []string) map[string]float64
- func CascadingFailure(ctx context.Context, config CascadeConfig) error
- func DNSChaos(ctx context.Context, config DNSConfig) error
- func DependencyFailure(ctx context.Context, config DependencyConfig) error
- func DiskFailure(ctx context.Context, config DiskConfig) error
- func NetworkPartition(ctx context.Context, config PartitionConfig) error
- func StandardFaultHandlers() map[ExperimentType]FaultHandler
- func TimeDrift(ctx context.Context, config TimeConfig) error
- type CascadeConfig
- type ChaosTemplate
- type DNSConfig
- type DependencyConfig
- type DiskConfig
- type Engine
- func (e *Engine) GetExperiment(id string) (*Experiment, error)
- func (e *Engine) GetStatus(id string) (Status, error)
- func (e *Engine) ListExperiments() []*Experiment
- func (e *Engine) RegisterExperiment(ex *Experiment) error
- func (e *Engine) RegisterHandler(t ExperimentType, h FaultHandler)
- func (e *Engine) StartExperiment(ctx context.Context, id string) error
- func (e *Engine) StopExperiment(id string) error
- type Experiment
- type ExperimentSchedule
- type ExperimentType
- type FaultConfig
- type FaultHandler
- type GameDayConfig
- type GameDayResult
- type GameDayScenario
- type PartitionConfig
- type SafetyConfig
- type ScenarioResult
- type ScheduleConfig
- type ScheduledExperiment
- type ScopeConfig
- type State
- type Status
- type TimeConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BlastRadius ¶
func BlastRadius(experiment *Experiment, services []string) map[string]float64
BlastRadius calculates blast radius
func CascadingFailure ¶
func CascadingFailure(ctx context.Context, config CascadeConfig) error
CascadingFailure simulates cascading failures
func DependencyFailure ¶
func DependencyFailure(ctx context.Context, config DependencyConfig) error
DependencyFailure simulates external dependency failures
func DiskFailure ¶
func DiskFailure(ctx context.Context, config DiskConfig) error
DiskFailure simulates disk failures
func NetworkPartition ¶
func NetworkPartition(ctx context.Context, config PartitionConfig) error
NetworkPartition creates network partition between services
func StandardFaultHandlers ¶
func StandardFaultHandlers() map[ExperimentType]FaultHandler
StandardFaultHandlers returns default fault handlers
Types ¶
type CascadeConfig ¶
CascadeConfig holds cascading failure configuration
type ChaosTemplate ¶
type ChaosTemplate struct {
Name string
Description string
Type ExperimentType
DefaultConfig map[string]interface{}
Setup func() error
Execute func(ctx context.Context, config map[string]interface{}) error
Teardown func() error
}
ChaosTemplate represents reusable chaos experiment templates
func StandardTemplates ¶
func StandardTemplates() []ChaosTemplate
StandardTemplates returns standard chaos templates
type DependencyConfig ¶
type DependencyConfig struct {
Dependencies []string
Duration time.Duration
FailureType string // timeout, error, slow
}
DependencyConfig holds dependency failure configuration
type DiskConfig ¶
DiskConfig holds disk failure configuration
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine manages chaos experiments
func (*Engine) GetExperiment ¶
func (e *Engine) GetExperiment(id string) (*Experiment, error)
GetExperiment returns experiment details
func (*Engine) ListExperiments ¶
func (e *Engine) ListExperiments() []*Experiment
ListExperiments returns all experiments
func (*Engine) RegisterExperiment ¶
func (e *Engine) RegisterExperiment(ex *Experiment) error
RegisterExperiment adds an experiment
func (*Engine) RegisterHandler ¶
func (e *Engine) RegisterHandler(t ExperimentType, h FaultHandler)
RegisterHandler registers a fault handler
func (*Engine) StartExperiment ¶
StartExperiment begins a chaos experiment
func (*Engine) StopExperiment ¶
StopExperiment stops a running experiment
type Experiment ¶
type Experiment struct {
ID string
Name string
Description string
Type ExperimentType
Config FaultConfig
Scope ScopeConfig
Schedule ScheduleConfig
Safety SafetyConfig
// contains filtered or unexported fields
}
Experiment defines a chaos experiment
func NewExperiment ¶
func NewExperiment(name string, t ExperimentType) *Experiment
NewExperiment creates a new experiment with sensible defaults
type ExperimentSchedule ¶
type ExperimentSchedule struct {
Experiments []ScheduledExperiment
}
ExperimentSchedule schedules chaos experiments
func Schedule ¶
func Schedule(experiments []*Experiment, interval time.Duration) *ExperimentSchedule
Schedule creates a schedule
type ExperimentType ¶
type ExperimentType string
ExperimentType defines the type of chaos experiment
const ( TypeLatency ExperimentType = "latency" TypeError ExperimentType = "error" TypeMemory ExperimentType = "memory" TypeCPU ExperimentType = "cpu" TypeNetwork ExperimentType = "network" TypeDisk ExperimentType = "disk" TypeKill ExperimentType = "kill" TypeTimeDrift ExperimentType = "time_drift" TypeDependency ExperimentType = "dependency" )
type FaultConfig ¶
type FaultConfig struct {
Probability float64 // 0.0 to 1.0
Duration time.Duration
Intensity float64 // 0.0 to 1.0
Target string // specific target identifier
Attributes map[string]interface{}
}
FaultConfig holds fault injection configuration
type FaultHandler ¶
type FaultHandler func(ctx context.Context, config FaultConfig) error
FaultHandler is a function that injects a specific type of fault
type GameDayConfig ¶
type GameDayConfig struct {
Name string
Scenarios []GameDayScenario
Duration time.Duration
}
GameDayConfig holds game day configuration
type GameDayResult ¶
type GameDayResult struct {
StartTime time.Time
EndTime time.Time
Scenarios []ScenarioResult
}
GameDayResult holds game day results
func GameDay ¶
func GameDay(ctx context.Context, config GameDayConfig) (*GameDayResult, error)
GameDay runs a chaos game day
type GameDayScenario ¶
type GameDayScenario struct {
Name string
Experiment *Experiment
ExpectedMTTR time.Duration
}
GameDayScenario represents a game day scenario
type PartitionConfig ¶
type PartitionConfig struct {
Source string
Destination string
Duration time.Duration
Direction string // one-way or two-way
}
PartitionConfig holds partition configuration
type SafetyConfig ¶
type SafetyConfig struct {
AutoRollback bool
MaxDuration time.Duration
AbortOnError bool
HealthCheck func() bool
KillSwitch chan struct{}
}
SafetyConfig defines safety mechanisms
type ScenarioResult ¶
type ScenarioResult struct {
Name string
StartTime time.Time
EndTime time.Time
Success bool
Error string
MTTR time.Duration
}
ScenarioResult represents scenario results
type ScheduleConfig ¶
type ScheduleConfig struct {
StartTime time.Time
EndTime time.Time
Cron string
Duration time.Duration
Continuous bool
}
ScheduleConfig defines when to run the experiment
type ScheduledExperiment ¶
type ScheduledExperiment struct {
Experiment *Experiment
Schedule time.Time
Repeat bool
Interval time.Duration
}
ScheduledExperiment represents a scheduled experiment
type ScopeConfig ¶
type ScopeConfig struct {
Services []string
Instances []string
Percentage float64 // percentage of targets affected
Tags map[string]string
}
ScopeConfig defines the blast radius