4 ms·
Ok, I think I see what you mean. Well, I think unfortunately my sketchy code examples maybe did not cover the idea in enough detail. What I'm doing in practic
by samuell 11y ago
Ok, I think I see what you mean.
Well, I think unfortunately my sketchy code examples maybe did not cover the idea in enough detail.
What I'm doing in practice is to create different struct types for each type of process I use, which all are of a "base interface" called "process" (mainly for the Run() method, so that the pipeline component can call it).
An example of this in action is shown in this code example on the Go playground: http://play.golang.org/p/voUfPGQulf http://play.golang.org/p/voUfPGQulf
The typing of channels for each process struct type should now enforce what components can be connected together (you will not be able to assign a "string chan" to a "[]byte chan" field, for example).
Did this answer the question, or do you see further problems here?
- catnaroek 11y agoAh, okay. I misunderstood the intention of your original example, then. My bad. In order to prevent further embarrassing myself, I'm going to tell you how I (currently) understand your design, and, if I'm wrong, please tell me: Your "pipeline" isn't actually connecting the processes to each other. You first connect the processes to each other, and only then add them to a "pipeline", whose primary (only?) responsibility is to ensure that each process runs in a different goroutine. This much doesn't really need parametric polymorphism, let alone generalized algebraic data types. However, calling it "pipeline" is kind of misleading, because the actual "piping" (connecting processes to each other) is handled elsewhere. In fact, using your "pipeline" abstraction, you could perfectly well run a bunch of processes that aren't connected to each other at all. Is my understanding correct?
- samuell 11y ago> Your "pipeline" isn't actually connecting the processes to each other. You first connect the processes to each other, and only then add them to a "pipeline", whose primary (only?) responsibility is to ensure that each process runs in a different goroutine. Exactly! > This much doesn't really need parametric polymorphism, let alone generalized algebraic data types. However, calling it "pipeline" is kind of misleading, because the actual "piping" Ah, yes, didn't think about that, but yeah, but that's a good point! I should consider a better name for this ... Thanks for pointing it out!