Documentation
¶
Overview ¶
Package inject provides error injection for testing cloudemu services.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Countdown ¶
type Countdown struct {
// contains filtered or unexported fields
}
Countdown injects errors for the first N calls, then stops.
func NewCountdown ¶
NewCountdown creates a policy that injects for the first n calls.
func (*Countdown) ShouldInject ¶
ShouldInject returns true while the countdown is positive.
type Injector ¶
type Injector struct {
// contains filtered or unexported fields
}
Injector manages error injection per service/operation.
type NthCall ¶
type NthCall struct {
N int
// contains filtered or unexported fields
}
NthCall injects an error on every Nth call.
func NewNthCall ¶
NewNthCall creates a policy that injects on every Nth call.
func (*NthCall) ShouldInject ¶
ShouldInject returns true on every Nth call.
type Policy ¶
type Policy interface {
ShouldInject() bool
}
Policy determines when to inject an error.
type Probabilistic ¶
type Probabilistic struct {
Probability float64
}
Probabilistic injects errors with a given probability.
func NewProbabilistic ¶
func NewProbabilistic(p float64) *Probabilistic
NewProbabilistic creates a policy with the given probability (0.0-1.0).
func (*Probabilistic) ShouldInject ¶
func (p *Probabilistic) ShouldInject() bool
ShouldInject returns true with the configured probability.