chaos

package
v9.4.47+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrNoEnt is generated on an unknown chaos ID.
	ErrNoEnt = errors.New("ID does not exist")
	// ErrChaos is generated when Action is set to Error
	ErrChaos = errors.New("Chaos generated error")
)

Functions

func Activate

func Activate(activate bool)

Activate activates chaos points in the system.

func Disable

func Disable(id ID) error

Disable chaos point identified by ID.

func Enable

func Enable(id ID, when When, what Action) error

Enable chaos point identified by ID.

func Now

func Now(id ID) error

Now will trigger chaos point if it is enabled.

Types

type Action

type Action int

Action to take when a chaos point is triggered.

const (
	// Crash at a call to Now().
	Crash Action = 1 << iota
	// Error out at calll to Now();
	Error
)

type Chaos

type Chaos struct {
	ID      ID
	Pkg     string
	Fn      string
	Desc    string
	Enabled bool
	What    Action
	When    When
	Count   int
}

Chaos represents an instance of a chaos point

func Enumerate

func Enumerate(pkg string) []Chaos

Enumerate all chaos points in the system for specified package. If the pkg is "" enumerate all chaos points.

type ID

type ID uint32

ID identifies a chaos point.

func Add

func Add(pkg string, fn string, desc string) ID

Add new chaos point. The ID returned can be used to perform operations on this Chaos Point.

type When

type When int

When defines when a chaos point is triggered

const (
	// Once chaos at the first call to ChaosNow.
	Once When = 1 << iota
	// Random chaos at a random number of calls to ChaosNow.
	Random
)

Jump to

Keyboard shortcuts

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