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

Function FetchDescriptionsConcurrent

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

691
692// FetchDescriptionsConcurrent fetches descriptions with bounded concurrency.
693func FetchDescriptionsConcurrent(client *api.Client, host, owner, repo string, skills []Skill, onProgress func(done, total int)) {
694 total := 0
695 for _, s := range skills {
696 if s.Description == "" {
697 total++
698 }
699 }
700 if total == 0 {
701 return
702 }
703
704 const maxWorkers = 10
705 var wg sync.WaitGroup
706 var done atomic.Int32
707
708 jobs := make(chan *Skill)
709
710 workers := min(maxWorkers, total)
711 for range workers {
712 wg.Go(func() {
713 for s := range jobs {
714 s.Description = fetchDescription(client, host, owner, repo, s)
715
716 d := int(done.Add(1))
717 if onProgress != nil {
718 onProgress(d, total)
719 }
720 }
721 })
722 }
723
724 for i := range skills {
725 if skills[i].Description == "" {
726 jobs <- &skills[i]
727 }
728 }
729 close(jobs)
730 wg.Wait()
731}
732
733// DiscoverSkillByPathOptions controls optional behavior for DiscoverSkillByPathWithOptions.
734type DiscoverSkillByPathOptions struct {

Callers 2

installRunFunction · 0.92

Calls 2

fetchDescriptionFunction · 0.85
AddMethod · 0.65

Tested by 1