diff --git a/README.md b/README.md index cc25af9..432b986 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # 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) @@ -11,18 +11,19 @@ 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 diff --git a/bridgekeeper.go b/bk.go similarity index 99% rename from bridgekeeper.go rename to bk.go index 8435f0d..a6e6bee 100644 --- a/bridgekeeper.go +++ b/bk.go @@ -1,4 +1,4 @@ -package bridgekeeper +package bk import ( "context" diff --git a/bridgekeeper_mocks_test.go b/bk_mocks_test.go similarity index 98% rename from bridgekeeper_mocks_test.go rename to bk_mocks_test.go index 6ba2094..5b25a82 100644 --- a/bridgekeeper_mocks_test.go +++ b/bk_mocks_test.go @@ -1,4 +1,4 @@ -package bridgekeeper +package bk import ( "context" diff --git a/bridgekeeper_test.go b/bk_test.go similarity index 99% rename from bridgekeeper_test.go rename to bk_test.go index 0237e5c..16af41d 100644 --- a/bridgekeeper_test.go +++ b/bk_test.go @@ -1,4 +1,4 @@ -package bridgekeeper +package bk import ( "context" diff --git a/exported.go b/exported.go index fd3af9f..d6f8456 100644 --- a/exported.go +++ b/exported.go @@ -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. @@ -7,7 +7,7 @@ // - Delay between requests // - Number of retries per request // - Concurrency limit for the client -package bridgekeeper +package bk import ( "context" @@ -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, @@ -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 } diff --git a/go.mod b/go.mod index 22e2448..ddcc5ca 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module go.devnw.com/bridgekeeper +module go.devnw.com/bk go 1.16