retry

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package retry provides a retry helper for talking to S2A gRPC server. The implementation is modeled after https://github.com/googleapis/google-cloud-go/blob/main/compute/metadata/retry.go

Index

Constants

This section is empty.

Variables

View Source
var NewRetryer = func() *S2ARetryer {
	return &S2ARetryer{bo: &defaultBackoff{
		cur: 100 * time.Millisecond,
		max: 30 * time.Second,
		mul: 2,
	}}
}

NewRetryer creates an instance of S2ARetryer using the defaultBackoff implementation.

Functions

func Run

func Run(ctx context.Context, f func() error)

Run uses S2ARetryer to execute the function passed in, until success or reaching max number of retry attempts.

func Sleep

func Sleep(ctx context.Context, d time.Duration) error

Sleep will wait for the specified duration or return on context expiration.

Types

type S2ARetryer

type S2ARetryer struct {
	// contains filtered or unexported fields
}

S2ARetryer implements a retry helper for talking to S2A gRPC server.

func (*S2ARetryer) Attempts

func (r *S2ARetryer) Attempts() int

Attempts return the number of retries attempted.

func (*S2ARetryer) Retry

func (r *S2ARetryer) Retry(err error) (time.Duration, bool)

Retry returns a boolean indicating whether retry should be performed and the backoff duration.

Jump to

Keyboard shortcuts

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