Skip to content

Commit

Permalink
Add rate limits for rss and cli: 1/50sec+50cc
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Kisler <admin@dkisler.com>
  • Loading branch information
kislerdm committed Nov 28, 2023
1 parent 1d92861 commit adfd186
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/internal/github/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ type Client struct {
// NewClient creates a new GitHub client.
func NewClient(ctx context.Context, log *slog.Logger, token string) Client {
httpClient := &http.Client{Transport: &transport{token: token, ctx: ctx}}

// As in the Arel's app:
retryClient := retryablehttp.NewClient()
retryClient.HTTPClient = httpClient
Expand All @@ -52,10 +51,10 @@ func NewClient(ctx context.Context, log *slog.Logger, token string) Client {
httpClient: retryClient,
ghClient: githubv4.NewClient(httpClient),

cliThrottle: NewThrottle(ctx, time.Second/30, 30),
cliThrottle: NewThrottle(ctx, time.Second/50, 50),
apiThrottle: NewThrottle(ctx, time.Second, 3),
assetThrottle: NewThrottle(ctx, time.Second/30, 30),
rssThrottle: NewThrottle(ctx, time.Second/30, 30),
rssThrottle: NewThrottle(ctx, time.Second/50, 50),
}
/* TODO
retryClient := retryablehttp.NewClient()
Expand Down
4 changes: 2 additions & 2 deletions src/internal/github/rss.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ func (c Client) getReleaseRSSFeed(releasesRSSURL string) (*gofeed.Feed, error) {
// Q: why the logic implemented here https://github.com/RLRabinowitz/rlrabinowitz.github.io takes
// an order of magnitude less time to bump versions?

// done := c.rssThrottle()
// defer done()
done := c.rssThrottle()
defer done()

resp, err := c.httpClient.Get(releasesRSSURL)
if err != nil {
Expand Down

0 comments on commit adfd186

Please sign in to comment.