Documentation ¶
Overview ¶
Package failpoint provides the code point in the path, which can be controlled by user's variable.
Inspired by FreeBSD fail(9): https://freebsd.org/cgi/man.cgi?query=fail.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Failpoint ¶
Failpoint is used to add code points where error or panic may be injected by user. The user controlled variable will be parsed for how the error injected code should fire. There is the way to set the rule for failpoint.
<count>*<type>[(arg)][-><more terms>]
The <type> argument specifies which action to take; it can be one of:
off: Takes no action (does not trigger failpoint and no argument) error: Triggers failpoint error with specified argument(string) panic: Triggers panic with specified argument(string) delay: Sleep the specified number of milliseconds
The <count>* modifiers prior to <type> control when <type> is executed. For example, "5*error(oops)" means "return error oops 5 times total". The operator -> can be used to express cascading terms. If you specify <term1>-><term2>, it means that if <term1> does not execute, <term2> will be evaluated. If you want the error injected code should fire in second call, you can specify "1*off->1*error(oops)".
Inspired by FreeBSD fail(9): https://freebsd.org/cgi/man.cgi?query=fail.
func NewFailpoint ¶
NewFailpoint returns failpoint control.
func (*Failpoint) DelegatedEval ¶
DelegatedEval evaluates a failpoint but delegates to caller to fire that.
type Type ¶
type Type int
Type is the type of failpoint to specifies which action to take.
const ( // TypeInvalid is invalid type TypeInvalid Type = iota // TypeOff takes no action TypeOff // TypeError triggers failpoint error with specified argument TypeError // TypePanic triggers panic with specified argument TypePanic // TypeDelay sleeps with the specified number of milliseconds TypeDelay )