# README
go-buffer
go-buffer represents a Generic buffer that asynchronously flushes its contents.
Motivation
Provide generic buffer for user, which is useful for applications that need to aggregate data / write to an external storage before flush it. Compatible with various data types (Container), providing error handling and secure Close.
Features
- Periodic automatic flush
- Manually flush(async/sync)
- Safely Close
- Error Channel for error handling
- Generic Support
Install
go get github.com/Kevinello/go-buffer@latest
⚠️ Retracted versions
Versions released erroneously, Please do not install these versions(retracted versions)
- v0.0.1
- v0.0.2
- v0.1.0
Usage
Project Structure
TODO
- add test and benchmark
Contribution & Support
Feel free to send a pull request if you consider there's something which can be improved. Also, please open up an issue if you run into a problem when using benchvisual or just have a question.
# Functions
NewBuffer creates a buffer in type `T`, and start handling data return the buffer and a error channel for user to handle error from putting data and flushing data
@param container Container[T] @param config Config @return buffer *Buffer[T] @return errChan <-chan error @return err error @author kevineluo @update 2023-03-15 10:38:29.
# Variables
ErrClosed indicates the buffer is closed and can no longer be used.
# Structs
Buffer is a lock-free buffer It would start a background goroutine continuously consume data from channel and write to container When container is "full", it would asynchronously flush data on container by default
@author kevineluo @update 2023-03-15 09:40:02.
Config Buffer Config
@author kevineluo @update 2023-03-15 09:31:54.