crash

package
v0.2010.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package crash provides a framework for adding probabilistic crash points. The package provides a global singleton that can be used to register, configure, and trigger crashes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Config

func Config(crashPointConfig map[string]float64)

Config configure the global crash point values.

func Here

func Here(crashPointID string)

Here invokes the global crasher to crash at this point based on the passed in crashPointID's probability.

func InitFlags

func InitFlags() *flag.FlagSet

InitFlags creates flags from the registered crash points and registers those flags with Viper.

func ListRegisteredCrashPoints

func ListRegisteredCrashPoints() []string

ListRegisteredCrashPoints lists the registered crash points for the global Crasher instance.

func LoadViperArgValues

func LoadViperArgValues()

LoadViperArgValues loads viper arg values into the crash point config of the global crasher.

func OverrideGlobalOptions

func OverrideGlobalOptions(options CrasherOptions)

OverrideGlobalOptions overrides global crasher options.

func RegisterCrashPoints

func RegisterCrashPoints(crashPointIDs ...string)

RegisterCrashPoints registers crash points with the global Crasher instance.

Types

type Crasher

type Crasher struct {
	CrashPointConfig map[string]float64
	CrashMethod      func()
	CLIPrefix        string
	Rand             RandomProvider
	// contains filtered or unexported fields
}

Crasher is a crash controller.

func New

func New(options CrasherOptions) *Crasher

New creates a new crasher.

func (*Crasher) Config

func (c *Crasher) Config(crashPointConfig map[string]float64)

Config configures the crash point probabilities.

func (*Crasher) Here

func (c *Crasher) Here(crashPointID string)

Here crashes at this point based on the passed in crashPointID's probability.

func (*Crasher) InitFlags

func (c *Crasher) InitFlags() *flag.FlagSet

InitFlags creates flags from the registered crash points and registers those flags with Viper.

func (*Crasher) ListRegisteredCrashPoints

func (c *Crasher) ListRegisteredCrashPoints() []string

ListRegisteredCrashPoints lists the registered crash points for a Crasher instance.

func (*Crasher) LoadViperArgValues

func (c *Crasher) LoadViperArgValues()

LoadViperArgValues loads viper arg values into the crash point config.

func (*Crasher) RegisterCrashPoints

func (c *Crasher) RegisterCrashPoints(crashPointIDs ...string)

RegisterCrashPoints registers crash points for a Crasher instance.

type CrasherOptions

type CrasherOptions struct {
	CrashMethod func()
	CLIPrefix   string
	Rand        RandomProvider
	CallerSkip  int
}

CrasherOptions options used to create a new crasher.

type RandomProvider

type RandomProvider interface {
	Float64() float64
}

RandomProvider interface that provides a Float64 random.

Jump to

Keyboard shortcuts

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