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

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

ErrFlakyRPCDeadline is returned by FlakyErrors to indicate a deadline.


Functions

func Errors

func Errors(params Params) featureBreaker.BreakFeatureCallback

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

Source Files