flaky

package
v0.0.0-...-d3da680 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: Apache-2.0, Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package flaky can be used to emulate flaky GAE errors that happen randomly with some probability.

NOTE: Emulates only datastore errors currently.

To install it:

ctx, fb := featureBreaker.FilterRDS(ctx, nil)
fb.BreakFeaturesWithCallback(
  flaky.Errors(...), featureBreaker.DatastoreFeatures...)

Index

Constants

This section is empty.

Variables

View Source
var ErrFlakyRPCDeadline = errors.New("simulated RPC deadline error")

ErrFlakyRPCDeadline is returned by FlakyErrors to indicate a deadline.

Functions

func Errors

Errors can be used to emulate flaky GAE errors that happen randomly with some probability.

NOTE: Emulates only datastore errors currently.

Types

type Params

type Params struct {
	// Rand is a source of pseudo-randomness to use.
	//
	// It will be accessed under a lock.
	//
	// By default it is new rand.NewSource(0).
	Rand interface {
		Int63() int64 // uniformly-distributed pseudo-random value in the range [0, 1<<63)
	}

	// DeadlineProbability is a probability of ErrFlakyRPCDeadline happening on
	// any of the calls that involve RPCs.
	//
	// Deadline can happen independently of other errors. For example,
	// a transaction can fail due to a deadline or due to a commit confict. These
	// events are assumed to be independent and their probabilities add up
	// accordingly.
	//
	// Default is 0 (no deadline errors at all).
	DeadlineProbability float64

	// ConcurrentTransactionProbability is a probability of datastore commit
	// returning ErrConcurrentTransaction.
	//
	// Default is 0 (no commit errors at all).
	ConcurrentTransactionProbability float64
}

Params define options for Errors

Jump to

Keyboard shortcuts

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