diff options
| author | Jeff Carr <[email protected]> | 2025-01-18 11:11:16 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-01-18 11:11:16 -0600 |
| commit | cee7e25f3dd2884b405fb58cbd02e166a38de513 (patch) | |
| tree | 49777fb9f464a4c5bd26139ed38bf05209b11ebe | |
| parent | 9b8cb52b7b4ba895d026edb7c5e5f65d85d5a8ad (diff) | |
rill is awesome. thank Viktorv0.0.54
| -rw-r--r-- | goSrcScan.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/goSrcScan.go b/goSrcScan.go index a934b15..357fed3 100644 --- a/goSrcScan.go +++ b/goSrcScan.go @@ -201,3 +201,40 @@ func (f *Forge) RillRedoGoMod() int { return counter } + +// x is the size of the queued up pool (shouldn't matter here for this I think) +// y is how many simultanous functions will run +// todo: tune and compute x,y by # of CPUs and disk io +// todo: store x,y in forge config ? (or compute them. notsure) +func (f *Forge) RillFuncError(x int, y int, rillf func(*gitpb.Repo) error) int { + var all []*gitpb.Repo + tmp := f.Repos.All() + for tmp.Scan() { + repo := tmp.Next() + if !repo.IsValidDir() { + log.Printf("%s %-50s", "got an invalid repo in forgepb.RillFuncError()", repo.GetGoPath()) + continue + } + all = append(all, repo) + } + // Convert a slice of user IDs into a channel + ids := rill.FromSlice(all, nil) + + var counter int + // Read users from the API. + // Concurrency = 20 + dirs := rill.Map(ids, x, func(id *gitpb.Repo) (*gitpb.Repo, error) { + return id, nil + }) + + err := rill.ForEach(dirs, y, func(repo *gitpb.Repo) error { + counter += 1 + return rillf(repo) + }) + + if err != nil { + log.Info("rill.ForEach() error:", err) + } + + return counter +} |
