Documentation
¶
Index ¶
- type Client
- func (c *Client) Do(req *http.Request) (*http.Response, error)
- func (c *Client) DoRequestWithRetry(ctx context.Context, req *http.Request, retryOpts *RetryOptions) (*http.Response, error)
- func (c *Client) GetBaseURL() string
- func (c *Client) GetHTTPClient() *http.Client
- func (c *Client) InjectTraceContext(ctx context.Context, req *http.Request)
- type Options
- type RetryOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a generic HTTP client with common functionality
func (*Client) DoRequestWithRetry ¶
func (c *Client) DoRequestWithRetry(ctx context.Context, req *http.Request, retryOpts *RetryOptions) (*http.Response, error)
DoRequestWithRetry performs an HTTP request with retry logic
func (*Client) GetHTTPClient ¶
GetHTTPClient returns the underlying http.Client
type Options ¶
type Options struct {
BaseURL string
Timeout time.Duration
UserAgent string
Transport http.RoundTripper
TLSCACertFile string // For verifying server certificate
TLSClientCert string // Client certificate file for mTLS
TLSClientKey string // Client private key file for mTLS
TLSServerName string // Server name for TLS verification
InsecureSkipVerify bool // Skip TLS certificate verification (not recommended)
}
Options for creating a new Client
type RetryOptions ¶
type RetryOptions struct {
MaxRetries int
RetryDelay time.Duration
MaxRetryDelay time.Duration
BackoffMultiplier float64
RetryableStatusCodes []int
}
RetryOptions configuration for retry logic
func DefaultRetryOptions ¶
func DefaultRetryOptions() *RetryOptions
DefaultRetryOptions returns default retry options
func (*RetryOptions) CalculateRetryDelay ¶
func (r *RetryOptions) CalculateRetryDelay(attempt int) time.Duration
CalculateRetryDelay calculates the delay for the next retry attempt using exponential backoff
func (*RetryOptions) IsRetryableError ¶
func (r *RetryOptions) IsRetryableError(err error, statusCode int) bool
IsRetryableError checks if an error should trigger a retry
Click to show internal directories.
Click to hide internal directories.