what’s the best way to tack on a transducer on to existing channel
this seems to come up a lot for me… I have a function that returns a channel and I want to add a partition operation to it
one way is to make a new channel with that transducer and use pipe
to move items from one channel to other
I’d love to use pipeline
but that seems to consider each item individually in paralel so I don’t know how it plays with the partition operation
Yeah pipe
is probably your best option if it's not parallel
What's the best way to implement debouce/throttle on a channel? As a custom buffer? A transducer? or a go process? I found a few implementations online but am wondering if it logically belongs in one of these more than the others
Not sure if that matters, but a transducer may be executed on a take or on a put, see https://stackoverflow.com/questions/34847872/how-are-transducers-executed-in-core-async-channels
Also this talk is a good watch if you want to understand the internals: https://vimeo.com/100518968
Slides and transcript links in the comments
you could also make your own channel implementation similar to what kinksy is doing in its duplex
channel: https://github.com/pyr/kinsky/blob/a5309073264a1d319d9303a839d9606331560212/src/kinsky/async.clj#L10
cool, thanks for all that!
a few questions for you to ponder about: do you want to throttle on put or on takes? do you want this behaviour to be totally transparent to clients using your channel? which sides or who configures the throttling and how?
oh and are throttling parameters fixed for the duration of the channel or do they need to change during its life?
I'd try first to get by composing existing building blocks: timeout channels, stateful transducers, etc
many of those examples are written before transducers existed btw