fetchCommitMetasParallel fetches commit metadata for a list of SHAs concurrently, bounded by maxConcurrency. Returns an immutable map of SHA → CommitMeta; failed fetches are logged and omitted (heuristic priors fall back to 1.0).
(ctx context.Context, repo string, shas []string, maxConcurrency int)
| 477 | // bounded by maxConcurrency. Returns an immutable map of SHA → CommitMeta; failed |
| 478 | // fetches are logged and omitted (heuristic priors fall back to 1.0). |
| 479 | func fetchCommitMetasParallel(ctx context.Context, repo string, shas []string, maxConcurrency int) map[string]CommitMeta { |
| 480 | metas := make([]CommitMeta, len(shas)) |
| 481 | ok := make([]bool, len(shas)) |
| 482 | |
| 483 | g, ctx := errgroup.WithContext(ctx) |
| 484 | g.SetLimit(maxConcurrency) |
| 485 | for i, sha := range shas { |
| 486 | g.Go(func() error { |
| 487 | meta, err := fetchCommitMeta(ctx, repo, sha) |
| 488 | if err != nil { |
| 489 | fmt.Printf("Warning: failed to fetch metadata for commit %s: %v\n", sha[:7], err) |
| 490 | return nil |
| 491 | } |
| 492 | metas[i] = meta |
| 493 | ok[i] = true |
| 494 | return nil |
| 495 | }) |
| 496 | } |
| 497 | _ = g.Wait() |
| 498 | |
| 499 | commitMetas := make(map[string]CommitMeta, len(shas)) |
| 500 | for i, sha := range shas { |
| 501 | if ok[i] { |
| 502 | commitMetas[sha] = metas[i] |
| 503 | } |
| 504 | } |
| 505 | return commitMetas |
| 506 | } |
no test coverage detected