Skip to content

Commit

Permalink
Updating name to bk since it's nice and short
Browse files Browse the repository at this point in the history
Fixed readme badges
  • Loading branch information
Benji Vesterby committed Mar 15, 2022
1 parent 641c4f6 commit bdada3b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
# Bridgekeeper - What is your (Re)Quest?

[![Build & Test](https://github.com/devnw/bridgekeeper/actions/workflows/build.yml/badge.svg)](https://github.com/devnw/bridgekeeper/actions/workflows/build.yml)
[![Go Report Card](https://goreportcard.com/badge/go.devnw.com/bridgekeeper)](https://goreportcard.com/report/go.devnw.com/bridgekeeper)
[![Go Report Card](https://goreportcard.com/badge/go.devnw.com/bk)](https://goreportcard.com/report/go.devnw.com/bk)
[![codecov](https://codecov.io/gh/devnw/bridgekeeper/branch/main/graph/badge.svg)](https://codecov.io/gh/devnw/bridgekeeper)
[![GoDoc](https://godoc.org/go.devnw.com/bridgekeeper?status.svg)](https://pkg.go.dev/go.devnw.com/bridgekeeper)
[![GoDoc](https://godoc.org/go.devnw.com/bk?status.svg)](https://pkg.go.dev/go.devnw.com/bk)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](http://makeapullrequest.com)

## Bridgekeeper is a request throttler for http.Client

Bridgekeeper replaces the hard implementation of `http.Client` with an
implementation of a shared interface such that anything implementing the
`bridgekeeper.Client` interface can use Bridgekeeper to throttle API requests through configuration.
`bk.Client` interface can use Bridgekeeper to throttle API requests through
configuration.

### Using Bridgekeeper

```go
go get -u go.devnw.com/bridgekeeper@latest
go get -u go.devnw.com/bk@latest
```

### Example

```go
client := New(
client := bk.New(
ctx, // Your application context
http.DefaultClient, // Your HTTP Client
time.Millisecond, // Delay between requests
Expand Down
2 changes: 1 addition & 1 deletion bridgekeeper.go → bk.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package bridgekeeper
package bk

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion bridgekeeper_mocks_test.go → bk_mocks_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package bridgekeeper
package bk

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion bridgekeeper_test.go → bk_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package bridgekeeper
package bk

import (
"context"
Expand Down
21 changes: 10 additions & 11 deletions exported.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Package bridgekeeper is intended to create a client side load balancer or
// package bk is intended to create a client side load balancer or
// rate limiter for API integrations. This library is specifically designed to
// wrap the `Do` method of the http.Client but since it uses an interface
// abstraction it can wrap any interface and limit requests.
Expand All @@ -7,7 +7,7 @@
// - Delay between requests
// - Number of retries per request
// - Concurrency limit for the client
package bridgekeeper
package bk

import (
"context"
Expand All @@ -23,13 +23,12 @@ type Client interface {
Do(req *http.Request) (*http.Response, error)
}

// New creates a new instance of the bridgekeeper for use with an api. New returns an
// interface implementation of Client which replaces the implementation of an
// http.Client interface so that it looks like an http.Client and can perform
// the same functions but it limits the requests using the parameters defined
// when created.
// NOTE: If a request timeout is not set at creation then the default HTTP
// client request timeout will be used
// New creates a new instance of the bridgekeeper for use with an api. New
// returns an interface implementation of Client which replaces the
// implementation of an http.Client interface so that it looks like an
// http.Client and can perform the same functions but it limits the requests
// using the parameters defined when created. NOTE: If a request timeout is not
// set at creation then the default HTTP client request timeout will be used
func New(
ctx context.Context,
client Client,
Expand Down Expand Up @@ -62,8 +61,8 @@ func New(

ctx, cancel := context.WithCancel(ctx)

// If a nil client is passed to the bridgekeeper then initialize using the default
// http client
// If a nil client is passed to the bridgekeeper then initialize using the
// default http client
if client == nil {
client = http.DefaultClient
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module go.devnw.com/bridgekeeper
module go.devnw.com/bk

go 1.16

Expand Down

0 comments on commit bdada3b

Please sign in to comment.