client

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RetryableHTTPClient

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

RetryableHTTPClient wraps an HTTP client with retry logic

func NewRetryableHTTPClient

func NewRetryableHTTPClient(maxRetries int, timeout time.Duration) *RetryableHTTPClient

NewRetryableHTTPClient creates a new HTTP client with retry capabilities

Parameters:

  • maxRetries: Maximum number of retry attempts (e.g., 3 for spec requirement)
  • timeout: Timeout duration for each HTTP request (e.g., 15 seconds)

Returns:

  • *RetryableHTTPClient: A configured HTTP client with retry logic

func (*RetryableHTTPClient) Do

Do executes an HTTP request with retry logic

Retry behavior:

  • Retries on network errors or 5xx server errors
  • Does NOT retry on 4xx client errors (non-retryable)
  • Uses linear backoff (1 second between retries)
  • Maximum attempts = maxRetries + 1 (initial attempt + retries)

Parameters:

  • req: The HTTP request to execute

Returns:

  • *http.Response: The HTTP response if successful
  • error: Error if all retry attempts fail

Jump to

Keyboard shortcuts

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