istio: Index | Files | Directories

package util

import ""


Package Files

common_utils.go compare_utils.go retry.go

func Backoff Uses

func Backoff(baseDelay, maxDelay time.Duration, retries int) time.Duration

Backoff returns a random value in [0, maxDelay] that increases exponentially with retries, starting from baseDelay. It is the Go equivalent to C++'s //util/time/

func Compare Uses

func Compare(out, model []byte) error

Compare compares two byte slices. It returns an error with a contextual diff if they are not equal.

func RandomString Uses

func RandomString(n int) string

RandomString returns a random string of size n (letters only)

type Break Uses

type Break struct {
    Err error

Break the retry loop if the error returned is of this type.

func (Break) Error Uses

func (e Break) Error() string

type Retrier Uses

type Retrier struct {
    // BaseDelay is the minimum delay between retry attempts.
    BaseDelay time.Duration
    // MaxDelay is the maximum delay allowed between retry attempts.
    MaxDelay time.Duration
    // MaxDuration is the maximum cumulative duration allowed for all retries
    MaxDuration time.Duration
    // Retries defines number of retry attempts
    Retries int

Retrier contains the retry configuration parameters.

func (Retrier) Retry Uses

func (r Retrier) Retry(ctx context.Context, fn func(ctx context.Context, retryIndex int) error) (int, error)

Retry calls the given function a number of times, unless it returns a nil or a Break


leakleak checks for goroutine leaks in tests This is (heavily) inspired by and

Package util imports 7 packages (graph). Updated 2021-01-09. Refresh now. Tools for package owners.