Buffer: Composable Buffers for Go
github.com
Buffer: Composable Buffers for Go
1–10 of 15 posts
Re: Buffer: Composable Buffers for Go
#2 // Buffer 32KB to Memory, after that buffer to 100MB chunked files
buf := buffer.NewUnboundedBuffer(32*1024, 100*1024*1024)
pool := NewFilePool(100*1024*1024, "") // "" -- use temp dir
I seem to have a twofold feeling about this code: on one hand I really like the brevity of these statements, but on the other hand it does come at the cost of being rather cryptic: without the comments one can only guess what exactly is going on. To the point that should I want to use this in my own code and make it understandable I'd almost would be forced to either copy the comments as well or else wrap it in a method with another name or. In such cases it probably would have been better if the original API already had done this.Re: Buffer: Composable Buffers for Go
#3// Buffer 32KB to Memory, after that buffer to 100MB chunked files buf := buffer.NewUnboundedBuffer(32*1024, 100*1024*1024) pool := NewFilePool(100*1024*1024, "") // "" -- use temp dir I seem to have a twofold feeling about this code: on one hand I really like the brevity of these statements, but on the other hand it does come at the cost of being rather cryptic: without the comments one can only guess what exactly i…
Re: Buffer: Composable Buffers for Go
#4Re: Buffer: Composable Buffers for Go
#5// Buffer 32KB to Memory, after that buffer to 100MB chunked files buf := buffer.NewUnboundedBuffer(32*1024, 100*1024*1024) pool := NewFilePool(100*1024*1024, "") // "" -- use temp dir I seem to have a twofold feeling about this code: on one hand I really like the brevity of these statements, but on the other hand it does come at the cost of being rather cryptic: without the comments one can only guess what exactly i…
Re: Buffer: Composable Buffers for Go
#6As a relative go newb, I do have a question about this: I thought channels/go routines were already essentially composable buffers. No?
Re: Buffer: Composable Buffers for Go
#7Re: Buffer: Composable Buffers for Go
#8As a relative go newb, I do have a question about this: I thought channels/go routines were already essentially composable buffers. No?
Yes and no. Goroutines are lightweight threads - what other languages might call fibers. Channels are synchronisation primitives designed to work with goroutines but they do indeed provide some buffering. What OP is doing though is creating customisable buffers that allow you to control for memory usage and that are likely designed to replace things like bytes.Buffer rather then buffered channels. Of course I may be…
Re: Buffer: Composable Buffers for Go
#9// Buffer 32KB to Memory, after that buffer to 100MB chunked files buf := buffer.NewUnboundedBuffer(32*1024, 100*1024*1024) pool := NewFilePool(100*1024*1024, "") // "" -- use temp dir I seem to have a twofold feeling about this code: on one hand I really like the brevity of these statements, but on the other hand it does come at the cost of being rather cryptic: without the comments one can only guess what exactly i…
Re: Buffer: Composable Buffers for Go
#10// Buffer 32KB to Memory, after that buffer to 100MB chunked files buf := buffer.NewUnboundedBuffer(32*1024, 100*1024*1024) pool := NewFilePool(100*1024*1024, "") // "" -- use temp dir I seem to have a twofold feeling about this code: on one hand I really like the brevity of these statements, but on the other hand it does come at the cost of being rather cryptic: without the comments one can only guess what exactly i…