-
Release v1.0.0 Stable
released this
2026-05-29 10:07:06 -06:00 | 0 commits to main since this releasev1.0.0
code.nochebuena.dev/einherjar/httpclient
Architecture Decisions Resolved
Decision Outcome Retry library avast/retry-go— idiomatic Go, supports condition functionsCircuit breaker library sony/gobreaker— battle-tested, simple state machineProvider interface Single Domethod — narrowest useful contract; consumers compose behaviourGeneric JSON helpers DoJSON[T]andDoJSONRequest[Req, Resp]— reduce boilerplate without hiding the client
API
import "code.nochebuena.dev/einherjar/httpclient" // Package sentinel // Module identifies this package to observability systems. // httpclient returns a Provider — not registered with the launcher as a lifecycle component. // Register Module manually with any version registry if needed. var Module observability.Identifiable // Interface type Provider interface { Do(req *http.Request) (*http.Response, error) } // Config type Config struct { 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"` } func DefaultConfig() Config // Constructors func New(logger logging.Logger, cfg Config) Provider func NewWithDefaults(logger logging.Logger) Provider // Helpers func DoJSON[T any](ctx context.Context, client Provider, req *http.Request) (*T, error) func DoJSONRequest[Req, Resp any](ctx context.Context, client Provider, method, rawURL string, body Req) (*Resp, error) func MapStatusToError(code int, msg string) error
Install
go get code.nochebuena.dev/einherjar/httpclient@v1.0.0
Dependencies
Module Version Role code.nochebuena.dev/einherjar/contractsv1.0.0 logging.Loggercode.nochebuena.dev/einherjar/corev1.0.0 xerrorsgithub.com/avast/retry-go/v4v4.3.4 Retry with configurable conditions github.com/sony/gobreakerv1.0.0 Circuit breaker Downloads