faults

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrHijackingUnsupported = errors.New("connection reset simulation requires HTTP/1.x hijacking")

Functions

This section is empty.

Types

type Engine

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

func New

func New(opts Options) *Engine

func (*Engine) Apply

func (e *Engine) Apply(ctx context.Context, rule rules.Rule, w http.ResponseWriter, r *http.Request) (Result, error)

type FixedRandom

type FixedRandom struct {
	Value float64
}

FixedRandom always returns Value, so effects fire when Value < probability.

func (FixedRandom) Float64

func (f FixedRandom) Float64() float64

type LockedRandom

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

func NewLockedRandom

func NewLockedRandom(seed *int64) *LockedRandom

func (*LockedRandom) Float64

func (l *LockedRandom) Float64() float64

type Options

type Options struct {
	Random  Random
	Sleeper Sleeper
	Seed    *int64
	Metrics *metrics.Metrics
	Logger  *slog.Logger
}

type Random

type Random interface {
	Float64() float64
}

type Result

type Result struct {
	// Stop reports that the effect already answered the client.
	Stop bool
	// Faulted reports that at least one effect actually ran.
	Faulted bool
}

type Sleeper

type Sleeper interface {
	Sleep(ctx context.Context, d time.Duration) error
}

type TimerSleeper

type TimerSleeper struct{}

func (TimerSleeper) Sleep

Jump to

Keyboard shortcuts

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