Skip to content

Latest commit

 

History

History
50 lines (31 loc) · 2.29 KB

File metadata and controls

50 lines (31 loc) · 2.29 KB

retryableRequest

import "github.com/greenbone/opensight-golang-libraries/pkg/retryableRequest"

Package retryableRequest provides a function to retry an http request up to a configured number of retries. It builds on [retryablehttp], but works with the default [http.Client].

Index

func DeepCopyRequest(request *http.Request) (copy *http.Request, err error)

DeepCopyRequest returns a deep copy of the request. The context of the original request is placed by context.Background. An error indicates a problem with the http request. In that case the passed request should no longer be used.

func ExecuteRequestWithRetry(ctx context.Context, client *http.Client, request *http.Request, maxRetries int, retryWaitMin, retryWaitMax time.Duration) (*http.Response, error)

ExecuteRequestWithRetry executes the given request via the passed http client and retries on failures. An error is only returned if there was a non retryable error or the maximum number of retries was reached. It uses the retry policy of [retryablehttp.ErrorPropagatedRetryPolicy] and exponential backoff from [retryablehttp.DefaultBackoff].

func IsOk

func IsOk(statusCode int) bool

IsOk returns true on a 2xx http status code

Generated by gomarkdoc