feat: catalogue generate now rate limits

Closes coop-cloud/organising#231.
This commit is contained in:
2021-11-03 06:53:19 +01:00
parent 08aca28d9d
commit e4e606efb0
2 changed files with 25 additions and 0 deletions

View File

@ -11,6 +11,7 @@ import (
"coopcloud.tech/abra/pkg/catalogue"
"coopcloud.tech/abra/pkg/config"
"coopcloud.tech/abra/pkg/git"
"coopcloud.tech/abra/pkg/limit"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
)
@ -74,10 +75,14 @@ var catalogueGenerateCommand = &cli.Command{
logrus.Debugf("ensuring '%v' recipe(s) are locally present and up-to-date", len(repos))
cloneLimiter := limit.New(10)
retrieveBar := formatter.CreateProgressbar(len(repos), "retrieving recipes...")
ch := make(chan string, len(repos))
for _, repoMeta := range repos {
go func(rm catalogue.RepoMeta) {
cloneLimiter.Begin()
defer cloneLimiter.End()
if recipeName != "" && recipeName != rm.Name {
ch <- rm.Name
retrieveBar.Add(1)