Documentation
¶
Overview ¶
Package fault provides facilities for simulated fault injection.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Contingency ¶
Contingency is a condition under which a fault should be injected. It is effectively a predicate; if it evaluates to true, a fault will be injected. Otherwise, if false, no fault will be returned to the application.
func After ¶
func After(n int) Contingency
After is a contingency that occurs after the first n attempts.
func First ¶
func First(n int) Contingency
First is a contingency that occurs during the first n attempts.
func Random ¶
func Random(p float32) Contingency
Random is a contingency that occurs with a probability equal to the given p-value.
type Fault ¶
Fault is an injector of simulated errors. A single fault instance should be spawned for one test.
A fault is thread-safe; it can be invoked from multiple goroutines.
type Spec ¶
type Spec struct { Cnt Contingency Err error }
Spec outlines the conditions for a fault, comprising a contingency, as well as an error that is reported when said contingency arises.
Specifications are completely reusable; one can create multiple Fault objects from a single Spec. Fault objects, on the other hand, should not be reused as they encompass invocation counters.