MCPcopy Create free account
hub / github.com/cli/cli / FetchDescriptionsConcurrent

Function FetchDescriptionsConcurrent

internal/skills/discovery/discovery.go:664–702  ·  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

662
663// FetchDescriptionsConcurrent fetches descriptions with bounded concurrency.
664func FetchDescriptionsConcurrent(client *api.Client, host, owner, repo string, skills []Skill, onProgress func(done, total int)) {
665 total := 0
666 for _, s := range skills {
667 if s.Description == "" {
668 total++
669 }
670 }
671 if total == 0 {
672 return
673 }
674
675 const maxWorkers = 10
676 var wg sync.WaitGroup
677 var done atomic.Int32
678
679 jobs := make(chan *Skill)
680
681 workers := min(maxWorkers, total)
682 for range workers {
683 wg.Go(func() {
684 for s := range jobs {
685 s.Description = fetchDescription(client, host, owner, repo, s)
686
687 d := int(done.Add(1))
688 if onProgress != nil {
689 onProgress(d, total)
690 }
691 }
692 })
693 }
694
695 for i := range skills {
696 if skills[i].Description == "" {
697 jobs <- &skills[i]
698 }
699 }
700 close(jobs)
701 wg.Wait()
702}
703
704// DiscoverSkillByPathOptions controls optional behavior for DiscoverSkillByPathWithOptions.
705type DiscoverSkillByPathOptions struct {

Callers 2

installRunFunction · 0.92

Calls 4

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

Tested by 1