faults

package
v0.13.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package faults contains simple fault injection code

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActiveFaultsCollector

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

func NewActiveFaultsCollector

func NewActiveFaultsCollector(s *Set) *ActiveFaultsCollector

func (*ActiveFaultsCollector) Collect

func (c *ActiveFaultsCollector) Collect(ch chan<- prometheus.Metric)

func (*ActiveFaultsCollector) Describe

func (c *ActiveFaultsCollector) Describe(ch chan<- *prometheus.Desc)

type Description

type Description struct {
	Operation        string
	Parameters       Parameters
	OnFault          func(Description, Parameters) error
	Count            int64
	FaultDescription string
}

Description defines a configured fault to inject. Faults are matched on an Operation and Parameters. To match, the Operation must be exactly the same, and all Parameters entries present in the Description must be present in the actual operation (but not vice versa!). A configured fault will execute at most Count times before being disabled. When it does execute, OnFault will be executed, and any error it returns will be returned to the caller. At most one Description is executed for a given invocation. If multiple match, which runs is undefined.

type Parameters

type Parameters = map[string]string

type Set

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

func NewSet

func NewSet(appName string) *Set

func (*Set) Add

func (s *Set) Add(d Description)

func (*Set) Check

func (s *Set) Check(op string, params Parameters) error

Check looks for an active fault description and runs it.

func (*Set) Current

func (s *Set) Current() map[string][]Description

Current gets a copy of the currently configured set of faults. Due to concurrency considerations, the remaining count on the descriptions may be out of date by the time the value is returned.

func (*Set) MustRegister

func (s *Set) MustRegister(registerer prometheus.Registerer)

func (*Set) Register

func (s *Set) Register(registerer prometheus.Registerer) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL