Skip to content

Commit 4090952

Browse files
committed
fix: grouping pipeline
when no groupers are registered, simply forward every asset from the adapter as a single-item group instead of closing the channel
1 parent 76f0f5c commit 4090952

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

internal/groups/groups.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,31 @@ func (p *GrouperPipeline) PipeGrouper(ctx context.Context, in chan *assets.Asset
5050
gOut := make(chan *assets.Group) // output channel for groups
5151
out := make(chan *assets.Asset) // output channel for the last grouper
5252

53+
// Fast path: no groupers configured, just forward assets as single-item groups.
54+
if len(p.groupers) == 0 {
55+
go func() {
56+
defer close(gOut)
57+
for {
58+
select {
59+
case <-ctx.Done():
60+
return
61+
case a, ok := <-in:
62+
if !ok {
63+
return
64+
}
65+
if a != nil {
66+
select {
67+
case <-ctx.Done():
68+
return
69+
case gOut <- assets.NewGroup(assets.GroupByNone, a):
70+
}
71+
}
72+
}
73+
}
74+
}()
75+
return gOut
76+
}
77+
5378
inChans := make([]chan *assets.Asset, len(p.groupers))
5479
outChans := make([]chan *assets.Asset, len(p.groupers))
5580

0 commit comments

Comments
 (0)