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
Click to show internal directories.
Click to hide internal directories.