3 ms·
I think you'd do better making the stages into plain functions that take an interface... why do the stages need to be structs at all?
by NateDad 12y ago
I think you'd do better making the stages into plain functions that take an interface... why do the stages need to be structs at all?
- jbert 12y agoIt's really the code to connect the stages. I want to support 1->many, so a single stage can fan out it's output to multiple consumers. The code which wants to be generic is in the handling of things like setting up channels between stages, handling data passing between them and cancellation (shutdown). I also want to support a layer of abstraction, where I can compose a graph of stages into a single stage. The goal is to have a number of primitive processing stages and allow abstraction and composition to build more complex processing. Basically I could move to a pure interface and associated functions (not methods). That would perhaps be more idiomatic go. It's just a slight shame that a bunch of code which lives to my mind slightly more naturally as a set of methods on a type gets promoted to top-level package functions due to the inabillity to define methods on an interface. But that's probably OK.