Skip to main content

Retries with the Go SDK

The SDK uses the go-retryablehttp module to support retry logic.

On line 17-18 of the following example, the SDK is set to retry if there is an unexpected error up to 10 times and wait 2 seconds between each retry:

package main

import (
"context"
"fmt"
"os"

sailpoint "github.com/sailpoint-oss/golang-sdk"
)

func main() {

ctx := context.TODO()
configuration := sailpoint.NewDefaultConfiguration()
apiClient := sailpoint.NewAPIClient(configuration)

configuration.HTTPClient.RetryMax = 10
configuration.HTTPClient.RetryWaitMax = time.Second * 2

resp, r, err := apiClient.V3.TransformsApi.ListTransforms(ctx).Filters("This is an incorrect string").Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `TransformsApi.ListTransforms``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `ListAccounts`: []Account
fmt.Fprintf(os.Stdout, "First response from `TransformsApi.ListTransforms`: %v\n", resp)

}