-
I need to incorporate buffered channels with the various Rill constructs. Unfortunately, the channels they make, e.g. It would be nice to have sibling methods like
Any suggestions? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hello and thank you for your interest in Rill. The current solution to the problem is to use rill.Buffer function. Like this: batches := rill.Batch(items, 10, 1*time.Second)
batches = rill.Buffer(batches, 100) // adds buffer of size 100 to the pipeline Semantically, it's equivalent to the Batch function returning a buffered channel, though it has a small performance overhead due to context switching. Such overhead would be negligible for I/O-bound workloads. This design is a trade-off I've made to keep the API simpler, safer, and smaller. One aspect of this trade-off is that Rill always creates, manages, and closes output channels on its own, making it harder for users to make mistakes. Another part of this trade-off is that all intermediate channels are unbuffered. One idea I considered is to add optional parameters to most functions. It could look like batches := rill.Batch(items, 10, 1*time.Second, rill.WIthBuffer(100)) This design would also theoretically allow us to remove the "ordered" versions of the functions and enable/disable ordering with an optional parameter. However, I'm still not sure about this. I'm trying to be very careful with API design, and such a change would be backwards incompatible. |
Beta Was this translation helpful? Give feedback.
Hello and thank you for your interest in Rill.
The current solution to the problem is to use rill.Buffer function. Like this:
Semantically, it's equivalent to the Batch function returning a buffered channel, though it has a small performance overhead due to context switching. Such overhead would be negligible for I/O-bound workloads.
This design is a trade-off I've made to keep the API simpler, safer, and smaller. One aspect of this trade-off is that Rill always creates, manages, and closes output channels on its own, making it harder for users to make mistakes. A…