I'm using clojure.async.flow in my application and have created several general-purpose step functions. However, when using these functions in my business logic, I'd like the channel names to be more semantically meaningful for each specific use case.
For example, a predicate step function might output to generic channels named :true and :false. In my actual flow, I'd prefer to rename these to something more contextual like :valid and :invalid (perhaps not the perfect example, but hopefully you understand the reasoning).
To accomplish this, I created a wrapper function (with-named-chans): https://gist.github.com/skallet/eb053b9842ca0c07568518b46ce6cdd4
There are some edge cases I still need to handle. My question is: Is my understanding of flows correct? Should I be using channel renames in my flow configuration like this? If not, why not?
I'd appreciate any feedback. Thanks!
My intuition is that renaming chans is probably not worth it. To me, it feels similar to taking a function like clojure.core/max and renaming the function arguments. It may be helpful to explicitly state some reasons for why you want to rename channels.
My guess is that it's to help with reporting and debugging. For that use case, you can augment reporting and monitoring tools to use more informative names. My guess is that instead of giving more descriptive names to process channels, you may want to provide more descriptive names for [pid port] pairs.