Skip to content

Commit ee832ef

Browse files
committed
Limit the number of concurrent list nodes processed
It uses the current capacity of the limiter as a hint as this is set based on the maxParallelism field on the schema.
1 parent c1d9693 commit ee832ef

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

internal/exec/exec.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,14 @@ func (r *Request) execList(ctx context.Context, sels []selected.Selection, typ *
312312
l := resolver.Len()
313313
entryouts := make([]bytes.Buffer, l)
314314

315+
sem := make(chan struct{}, cap(r.Limiter))
315316
if selected.HasAsyncSel(sels) {
316317
var wg sync.WaitGroup
317318
wg.Add(l)
318319
for i := 0; i < l; i++ {
320+
sem <- struct{}{}
319321
go func(i int) {
322+
defer func() { <-sem }()
320323
defer wg.Done()
321324
defer r.handlePanic(ctx)
322325
r.execSelectionSet(ctx, sels, typ.OfType, &pathSegment{path, i}, s, resolver.Index(i), &entryouts[i])

0 commit comments

Comments
 (0)