fault - ActiveState ActiveGo 1.8
...

Package fault

import "go4.org/fault"
Overview
Index

Overview ▾

Package fault handles fault injection for testing.

type Injector

An Injector reports whether fake errors should be returned.

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

func NewInjector

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

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

func (in *Injector) ShouldFail() bool

ShouldFail reports whether a fake error should be returned.