29 lines
1.0 KiB
Go
29 lines
1.0 KiB
Go
|
|
package httpclient
|
||
|
|
|
||
|
|
import "time"
|
||
|
|
|
||
|
|
// Config holds configuration for the HTTP client.
|
||
|
|
type Config struct {
|
||
|
|
// Name identifies this client in logs and circuit breaker metrics.
|
||
|
|
Name string `env:"EINHERJAR_HTTP_CLIENT_NAME" envDefault:"http"`
|
||
|
|
Timeout time.Duration `env:"EINHERJAR_HTTP_TIMEOUT" envDefault:"30s"`
|
||
|
|
DialTimeout time.Duration `env:"EINHERJAR_HTTP_DIAL_TIMEOUT" envDefault:"5s"`
|
||
|
|
MaxRetries uint `env:"EINHERJAR_HTTP_MAX_RETRIES" envDefault:"3"`
|
||
|
|
RetryDelay time.Duration `env:"EINHERJAR_HTTP_RETRY_DELAY" envDefault:"1s"`
|
||
|
|
CBThreshold uint32 `env:"EINHERJAR_HTTP_CB_THRESHOLD" envDefault:"10"`
|
||
|
|
CBTimeout time.Duration `env:"EINHERJAR_HTTP_CB_TIMEOUT" envDefault:"1m"`
|
||
|
|
}
|
||
|
|
|
||
|
|
// DefaultConfig returns a Config with sensible production defaults.
|
||
|
|
func DefaultConfig() Config {
|
||
|
|
return Config{
|
||
|
|
Name: "http",
|
||
|
|
Timeout: 30 * time.Second,
|
||
|
|
DialTimeout: 5 * time.Second,
|
||
|
|
MaxRetries: 3,
|
||
|
|
RetryDelay: 1 * time.Second,
|
||
|
|
CBThreshold: 10,
|
||
|
|
CBTimeout: 1 * time.Minute,
|
||
|
|
}
|
||
|
|
}
|