Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 implement 1 QPS rate limiting for cron best practices worker. #4090

Merged
merged 2 commits into from
May 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions cron/internal/cii/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"log"
"net/http"
"strings"
"time"

"github.com/ossf/scorecard/v5/clients"
"github.com/ossf/scorecard/v5/cron/config"
Expand Down Expand Up @@ -95,9 +96,13 @@ func main() {
panic(err)
}

throttle := time.NewTicker(time.Second) // bestpractices.dev wants 1 QPS
defer throttle.Stop()

pageNum := 1
pageResp, err := getPage(ctx, pageNum)
for err == nil && len(pageResp) > 0 {
<-throttle.C
if err := writeToCIIDataBucket(ctx, pageResp, ciiDataBucket); err != nil {
panic(err)
}
Expand Down