Skip to content

How to incorporate buffered channels #38

Answered by destel
maguro asked this question in Q&A
Discussion options

You must be logged in to vote

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. A…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@maguro
Comment options

@destel
Comment options

@maguro
Comment options

@maguro
Comment options

@destel
Comment options

Answer selected by destel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants