https://github.com/devnw/bridgekeeper
https://github.com/devnw/bridgekeeper
Last synced: 4 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/devnw/bridgekeeper
- Owner: devnw
- License: apache-2.0
- Created: 2020-01-30T00:35:15.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2024-12-12T21:10:29.000Z (about 1 year ago)
- Last Synced: 2025-09-18T02:23:37.729Z (4 months ago)
- Language: Go
- Homepage:
- Size: 159 KB
- Stars: 0
- Watchers: 0
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Bridgekeeper - HTTP Request Limiter and Retrier
[](https://github.com/devnw/bridgekeeper/actions/workflows/build.yml)
[](https://pkg.go.dev/go.devnw.com/bk)
[](https://opensource.org/licenses/Apache-2.0)
## Using Bridgekeeper
```go
go get -u go.devnw.com/bk/v2@latest
```
## Version 2 Changes
Version 2 changes the API for Bridgekeeper to using a direct function literal
in the `New` function so that it can accept both the `Do` and `RoundTrip`
functions from the `http.Client` and `http.Transport` respectively. This
allows for Bridgekeeper to support connections where a custom `http.Transport`
is may be required, for example, when using a custom TLS configuration.
### HTTP Client Example
```go
client := bk.New(
ctx, // Your application context
http.DefaultClient.Do, // Your HTTP Client Do function (http.Client.Do)
time.Millisecond, // Delay between requests
5, // Retry count
10, // Concurrent request limit
http.DefaultClient.Timeout, // Request timeout
)
resp, err := client.Do(http.NewRequest(http.MethodGet, "localhost:5555"))
if err != nil {
log.Fatal(err)
}
```
### HTTP Round Tripper Example
```go
client := bk.New(
ctx, // Your application context
http.DefaultTransport.RoundTrip, // Your HTTP Transport
time.Millisecond, // Delay between requests
5, // Retry count
10, // Concurrent request limit
http.DefaultClient.Timeout, // Request timeout
)
resp, err := client.RoundTrip(http.NewRequest(http.MethodGet, "localhost:5555"))
if err != nil {
log.Fatal(err)
}
```
> NOTE: Bridgekeeper Returns a Do / RoundTrip Compliant HTTP Client