theatrus / mediate

Retryable, failure tolerant, and adaptive Golang HTTP client transports

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mediate

GoDoc Build Status

HTTP client transport for real-world and failure-tolerant communication in Go.

The following Golang adapters are designed to mix-in to the chain of http.RoundTrippers to add functionality such as:

  • FixedRetries: on recoverable errors, clone the request and attempt to re-issue it again a fixed number of times.
  • ReliableBody: consume the entire http.Response.Body into memory. If reading the body fails, the entire http.RoundTripper fails.
  • RateLimit: allow only N requests per given interval T through, blocking others.

Example

httpClient := &http.Client{}
httpClient.Transport = mediate.FixedRetries(3,
	mediate.ReliableBody(http.DefaultTransport),
)

About

Retryable, failure tolerant, and adaptive Golang HTTP client transports

License:Apache License 2.0


Languages

Language:Go 100.0%