Skip to content

Commit

Permalink
Add a rebuild recovery tool (#176)
Browse files Browse the repository at this point in the history
Add a tool to run rebuild recoveries
  • Loading branch information
msuozzo authored Feb 19, 2025
1 parent fcd6b22 commit 5ef7529
Show file tree
Hide file tree
Showing 2 changed files with 470 additions and 0 deletions.
13 changes: 13 additions & 0 deletions internal/httpx/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"bytes"
"errors"
"net/http"
"time"

"github.com/google/oss-rebuild/internal/cache"
)
Expand Down Expand Up @@ -72,3 +73,15 @@ func (cc *CachedClient) Do(req *http.Request) (*http.Response, error) {
}

var _ BasicClient = &CachedClient{}

type RateLimitedClient struct {
BasicClient
Ticker *time.Ticker
}

func (c *RateLimitedClient) Do(req *http.Request) (*http.Response, error) {
<-c.Ticker.C // Wait for next tick
return c.BasicClient.Do(req)
}

var _ BasicClient = &RateLimitedClient{}
Loading

0 comments on commit 5ef7529

Please sign in to comment.