+// ProbeSlotSummarizer lets at most cap(slots) builds call inner at once. A
+// build past the limit waits for a slot.
+type ProbeSlotSummarizer struct {
+ inner Summarizer
+ slots chan struct{}
+}
+
+// Summarize waits for a slot and builds the node with inner.
+func (s ProbeSlotSummarizer) Summarize(ctx context.Context, task Task) (string, error) {
+ select {
+ case s.slots <- struct{}{}:
+ case <-ctx.Done():
+ return "", ctx.Err()
+ }
+
+ defer func() {
+ <-s.slots
+ }()
+
+ return s.inner.Summarize(ctx, task)
+}
+