MCPcopy Index your code
hub / github.com/cli/cli / FetchDescriptionsConcurrent

Function FetchDescriptionsConcurrent

internal/skills/discovery/discovery.go:638–676  ·  view source on GitHub ↗

FetchDescriptionsConcurrent fetches descriptions with bounded concurrency.

(client *api.Client, host, owner, repo string, skills []Skill, onProgress func(done, total int))

Source from the content-addressed store, hash-verified

636
637// FetchDescriptionsConcurrent fetches descriptions with bounded concurrency.
638func FetchDescriptionsConcurrent(client *api.Client, host, owner, repo string, skills []Skill, onProgress func(done, total int)) {
639 total := 0
640 for _, s := range skills {
641 if s.Description == "" {
642 total++
643 }
644 }
645 if total == 0 {
646 return
647 }
648
649 const maxWorkers = 10
650 var wg sync.WaitGroup
651 var done atomic.Int32
652
653 jobs := make(chan *Skill)
654
655 workers := min(maxWorkers, total)
656 for range workers {
657 wg.Go(func() {
658 for s := range jobs {
659 s.Description = fetchDescription(client, host, owner, repo, s)
660
661 d := int(done.Add(1))
662 if onProgress != nil {
663 onProgress(d, total)
664 }
665 }
666 })
667 }
668
669 for i := range skills {
670 if skills[i].Description == "" {
671 jobs <- &skills[i]
672 }
673 }
674 close(jobs)
675 wg.Wait()
676}
677
678// DiscoverSkillByPathOptions controls optional behavior for DiscoverSkillByPathWithOptions.
679type DiscoverSkillByPathOptions struct {

Callers 2

installRunFunction · 0.92

Calls 4

fetchDescriptionFunction · 0.85
AddMethod · 0.65
WaitMethod · 0.65
minFunction · 0.50

Tested by 1