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, error)
NewRetryableHTTPClient creates a new HTTP client with retry capabilities.
This client is built around the single shared, SSRF-guarded *http.Client the process constructs once at startup (see internal/utils.InitSharedHTTPClient and cmd/main.go) — it no longer builds its own independent httpclient.New config. As of this writing RetryableHTTPClient has no callers in this module; whoever wires it to a concrete call site inherits the shared client's SSRF policy (netguard.PermitPrivateBlockMetadata() by default, operator-configurable via platform_api.http_client in config.toml) automatically, rather than needing to decide on one independently.
timeout is accepted for call-site compatibility (and is still used as this client's own Do-loop budget expectations) but no longer varies the underlying transport's construction — the shared client's own Timeouts.Overall is a safety-net only; a real per-call budget should be supplied via context.WithTimeout on the request passed to Do, matching every other caller of the shared client (see internal/utils/mcp.go, common.go).
Parameters:
- maxRetries: Maximum number of retry attempts (e.g., 3 for spec requirement)
- timeout: Retained for call-site compatibility; see doc comment above
Returns:
- *RetryableHTTPClient: A configured HTTP client with retry logic
- error: if the shared HTTP client has not yet been initialized (see utils.InitSharedHTTPClient, called once at process startup)
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