Back to

package util

v0.0.0 (abe510f)
Latest Go to latest
Published: 0 hours ago | License: Apache-2.0 | Module:



var (
	// MockPilotGrpcAddr is the address to be used for grpc connections.
	MockPilotGrpcAddr string

	MockPilotSGrpcAddr string

	// MockPilotHTTPPort is the dynamic port for pilot http
	MockPilotHTTPPort int

	// MockPilotGrpcPort is the dynamic port for pilot grpc
	MockPilotGrpcPort int

func Backoff

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

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

func RandomString(n int) string

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

type Break

type Break struct {
	Err error

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

func (Break) Error

func (e Break) Error() string

type Retrier

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

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

type TearDownFunc

type TearDownFunc func()

TearDownFunc is to be called to tear down a test server.

func EnsureTestServer

func EnsureTestServer(args ...func(*bootstrap.PilotArgs)) (*bootstrap.Server, TearDownFunc)

EnsureTestServer will ensure a pilot server is running in process and initializes the MockPilotUrl and MockPilotGrpcAddr to allow connections to the test pilot.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
f or F : Jump to identifier