...

Package retry

import "github.com/google/s2a-go/retry"
Overview
Index

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

Variables

NewRetryer creates an instance of S2ARetryer using the defaultBackoff implementation.

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

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.

type S2ARetryer

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

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

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.