Documentation

Overview

Package fault handles fault injection for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Injector

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

An Injector reports whether fake errors should be returned.

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.

Source Files