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

faultline

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2018 License: MIT Imports: 7 Imported by: 0

README

go-faultline

Fault injection library and api's for Golang.

NOTE: this is just an idea so far and is still in development and prototyping.

See examples/server.go for an example..

Why?

This is an experimental form of chaos engineering for internal API's that can be used to inject failures with a certain probability. For example: cause 0.1% of requests to have additional latency or to return a 500 error.

By having tunable probablities and delays, and by outputting an audit log of the effects, this fault injection library adds a permanent level of unreliability to your API while helping you to debug when faults have been injected. This sounds bad, but remember that this can be used to enforce an error budget or SLO and will help to force consumers of the API to gracefully handle these faults.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Disabled

func Disabled(fl *FaultLine)

func Enabled

func Enabled(fl *FaultLine)

func ReplaceGlobals

func ReplaceGlobals(fl *FaultLine)

ReplaceGlobals will replace the core fault line object

Types

type FaultLine

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

func G

func G() *FaultLine

G returns the global fault line object

func (*FaultLine) DoInTheFuture

func (fl *FaultLine) DoInTheFuture(before time.Duration, f func(), ctx context.Context) bool

func (*FaultLine) Possible

func (fl *FaultLine) Possible() bool

Possible determines whether the possibility probability evaluated to true

func (*FaultLine) PossibleDelay

func (fl *FaultLine) PossibleDelay(ctx context.Context) bool

PossibleDelay will maybe add a small sleep time at the invocation site. Whether to sleep or not, and the exactly sleep time, are determined by the configuration of the FaultLine.

func (*FaultLine) PossibleError

func (fl *FaultLine) PossibleError(err error) error

PossibleError will maybe return a specific error here

func (*FaultLine) PossibleErrorOr

func (fl *FaultLine) PossibleErrorOr(existing error, possible error) error

PossibleErrorOr is a convenience feature that will return the existing error if not nil

func (*FaultLine) PossiblyDoInTheFuture

func (fl *FaultLine) PossiblyDoInTheFuture(before time.Duration, f func(), ctx context.Context) bool

func (*FaultLine) PossiblyPanicInTheFuture

func (fl *FaultLine) PossiblyPanicInTheFuture(before time.Duration, ctx context.Context) bool

func (*FaultLine) PossiblySignalInTheFuture

func (fl *FaultLine) PossiblySignalInTheFuture(signal os.Signal, before time.Duration, ctx context.Context) bool

func (*FaultLine) With

func (fl *FaultLine) With(options ...Option) *FaultLine

With is used to apply options to the FaultLine. It creates a new copy of the parent object

type Option

type Option func(fl *FaultLine)

func AuditFunction

func AuditFunction(f func(*FaultLine, string, string)) Option

func DisabledIf

func DisabledIf(b bool) Option

func EnabledIf

func EnabledIf(b bool) Option

func MaximumDelay

func MaximumDelay(duration time.Duration) Option

func ModifiedDelay

func ModifiedDelay(f func(float64) float64) Option

func Possibility

func Possibility(f float64) Option

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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