From d5524e69ccaef499ad26bef08115d25b859b4376 Mon Sep 17 00:00:00 2001 From: Tim Voronov Date: Thu, 2 May 2024 17:14:28 -0400 Subject: [PATCH] Update README.md --- README.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index f5575cb..06cf3cb 100644 --- a/README.md +++ b/README.md @@ -15,31 +15,31 @@ go get github.com/ziflex/throttle package myapp import ( - "context" - "net/http" - "github.com/ziflex/throttle" + "context" + "net/http" + "github.com/ziflex/throttle" ) type ApiClient struct { - transport *http.Client - throttler *throttle.Throttler[*http.Response] + transport *http.Client + throttler *throttle.Throttler[*http.Response] } func NewApiClient(rps uint64) *ApiClient { - return &ApiClient{ - transport: &http.Client{}, - throttler: throttle.New[*http.Response](rps), - } + return &ApiClient{ + transport: &http.Client{}, + throttler: throttle.New[*http.Response](rps), + } } func (c *ApiClient) Do(ctx context.Context, req *http.Request) (*http.Response, error) { - return c.throttler.Do(func() (*http.Response, error) { - select { - case <-ctx.Done(): - return nil, ctx.Err() - default: - return c.transport.Do(req) + return c.throttler.Do(func() (*http.Response, error) { + select { + case <-ctx.Done(): + return nil, ctx.Err() + default: + return c.transport.Do(req) } }) } -``` \ No newline at end of file +```