Retry on plugin API calls

This commit is contained in:
Ludovic Fernandez 2022-11-23 11:42:04 +01:00 committed by GitHub
parent ba1ca68977
commit 3dd4968c41
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 102 additions and 2 deletions

View file

@ -16,6 +16,9 @@ import (
"strings"
"time"
"github.com/hashicorp/go-retryablehttp"
"github.com/rs/zerolog/log"
"github.com/traefik/traefik/v2/pkg/logs"
"golang.org/x/mod/module"
"golang.org/x/mod/zip"
"gopkg.in/yaml.v3"
@ -77,8 +80,13 @@ func NewClient(opts ClientOptions) (*Client, error) {
return nil, fmt.Errorf("failed to create archives directory %s: %w", archivesPath, err)
}
client := retryablehttp.NewClient()
client.Logger = logs.NewRetryableHTTPLogger(log.Logger)
client.HTTPClient = &http.Client{Timeout: 10 * time.Second}
client.RetryMax = 3
return &Client{
HTTPClient: &http.Client{Timeout: 10 * time.Second},
HTTPClient: client.StandardClient(),
baseURL: baseURL,
archives: archivesPath,