go4.org: go4.org/fault Index | Files

package fault

import "go4.org/fault"

Package fault handles fault injection for testing.

Index

Package Files

fault.go

type Injector Uses

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

An Injector reports whether fake errors should be returned.

func NewInjector Uses

func NewInjector(name string) *Injector

NewInjector returns a new fault injector with the given name. The environment variable "FAULT_" + capital(name) + "_FAIL_PERCENT" controls the percentage of requests that fail. If undefined or zero, no requests fail.

func (*Injector) FailErr Uses

func (in *Injector) FailErr(err *error) bool

FailErr checks ShouldFail and, if true, assigns a fake error to err and returns true.

func (*Injector) ShouldFail Uses

func (in *Injector) ShouldFail() bool

ShouldFail reports whether a fake error should be returned.

Package fault imports 5 packages (graph) and is imported by 4 packages. Updated 2016-07-18. Refresh now. Tools for package owners.