Documentation
¶
Overview ¶
Package httpclient provides a resilient HTTP client wrapper around go-resty. It features automatic Retries with exponential backoff, Circuit Breaker via gobreaker, and automatic OpenTelemetry W3C Trace Context propagation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CBConfig ¶
type CBConfig struct {
Enabled bool
Name string
MaxRequests uint32
Interval time.Duration
Timeout time.Duration
ReadyToTripFailRatio float64
ReadyToTripMinRequests uint32
OnStateChange func(name string, from gobreaker.State, to gobreaker.State)
}
CBConfig configures the Circuit Breaker pattern.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a wrapper around resty.Client that provides Circuit Breaking and Telemetry.
func (*Client) Execute ¶
func (c *Client) Execute(ctx context.Context, fn func(req *resty.Request) (*resty.Response, error)) (*resty.Response, error)
Execute performs an HTTP request wrapped in a Circuit Breaker (if enabled). The provided function `fn` describes how to actually build and send the request using the Resty client.
type Config ¶
type Config struct {
BaseURL string
Timeout time.Duration
Retry RetryConfig
CircuitBreaker CBConfig
EnableTelemetry bool
}
Config represents the overall configuration for the HTTP Client.
func DefaultConfig ¶
DefaultConfig returns a recommended set of default configurations.