Fork me on GitHub
#core-async
<
2019-12-23
>
roklenarcic11:12:28

what’s the best way to tack on a transducer on to existing channel

roklenarcic11:12:03

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

roklenarcic11:12:31

one way is to make a new channel with that transducer and use pipe to move items from one channel to other

roklenarcic11:12:05

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

jjttjj16:12:42

Yeah pipe is probably your best option if it's not parallel

jjttjj16:12:42

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

fmjrey17:12:54

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

fmjrey17:12:21

Also this talk is a good watch if you want to understand the internals: https://vimeo.com/100518968

fmjrey17:12:50

Slides and transcript links in the comments

fmjrey17:12:25

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

jjttjj17:12:12

cool, thanks for all that!

fmjrey17:12:17

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?

fmjrey17:12:55

oh and are throttling parameters fixed for the duration of the channel or do they need to change during its life?

fmjrey17:12:14

I'd try first to get by composing existing building blocks: timeout channels, stateful transducers, etc

noisesmith20:12:51

many of those examples are written before transducers existed btw