Added ‘bundler’ module

resolves a v3 document or a model into a single document.

Signed-off-by: quobix <dave@quobix.com>
This commit is contained in:
quobix
2024-01-17 11:47:50 -05:00
parent 1da99d7efe
commit 2bc6e9f028
10 changed files with 2423 additions and 2189 deletions

View File

@@ -571,7 +571,10 @@ func (index *SpecIndex) ExtractComponentsFromRefs(refs []*Reference) []*Referenc
var found []*Reference
// run this async because when things get recursive, it can take a while
c := make(chan bool)
var c chan bool
if !index.config.ExtractRefsSequentially {
c = make(chan bool)
}
locate := func(ref *Reference, refIndex int, sequence []*ReferenceMapped) {
located := index.FindComponent(ref.FullDefinition)
@@ -604,7 +607,9 @@ func (index *SpecIndex) ExtractComponentsFromRefs(refs []*Reference) []*Referenc
index.refErrors = append(index.refErrors, indexError)
index.errorLock.Unlock()
}
c <- true
if !index.config.ExtractRefsSequentially {
c <- true
}
}
var refsToCheck []*Reference
@@ -615,14 +620,20 @@ func (index *SpecIndex) ExtractComponentsFromRefs(refs []*Reference) []*Referenc
for r := range refsToCheck {
// expand our index of all mapped refs
go locate(refsToCheck[r], r, mappedRefsInSequence)
//locate(refsToCheck[r], r, mappedRefsInSequence) // used for sync testing.
if !index.config.ExtractRefsSequentially {
go locate(refsToCheck[r], r, mappedRefsInSequence) // run async
} else {
locate(refsToCheck[r], r, mappedRefsInSequence) // run synchronously
}
}
completedRefs := 0
for completedRefs < len(refsToCheck) {
<-c
completedRefs++
if !index.config.ExtractRefsSequentially {
completedRefs := 0
for completedRefs < len(refsToCheck) {
<-c
completedRefs++
}
}
for m := range mappedRefsInSequence {
if mappedRefsInSequence[m] != nil {