I have the following interface and struct
type PiplineStep interface {
Do(ctx context.Context, in <-chan Message) (<-chan Message, <-chan error, error)
}
type Pipline struct {
Steps []core.PiplineStep
}
Now I am trying to daisy the interfaces to create a pipeline like the following
for _, step := range p.Steps {
out, errc, err := step.Do(ctx, out)
errcList = append(errcList, errc)
if err != nil {
errc <- err
return
}
select {
case outer <- msg:
case <-ctx.Done():
return
}
}
But the compiler says no is this possible?
I get the following Error 'out declared and not used' i have attempted following but it appears that all steps are receiving the same chan
for _, step := range p.Steps {
var tmpOut <-chan core.Message
tmpOut = out
tmpOut, errcTmp, err := step.Do(ctx, tmpOut)
errcList = append(errcList, errcTmp)
if err != nil {
errc <- err
return
}
select {
case out <- msg:
case <-ctx.Done():
return
}
}