-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overwrite old data #19
Comments
Why do you think it does not overwrite old data? Since It is a ringbuffer, it should be reuse the buffer. |
In err = r.setErr(err, true)
if r.block && (err == ErrIsFull || err == ErrTooMuchDataToWrite) {
...
if r.block && wrote > 0 {
r.writeCond.Broadcast()
}
return wrote, r.setErr(err, true) Also, I am testing with hclog which can write to both stderr and a End of logs on stderr:
logs in ringbuffer:
Note by the timestamp, etc. that ringbuffer contains the first logs until it is full. If it is circular, it should contain the last logs. |
I find this package useful in several scenarios. Now I am looking to maintain a rolling log buffer. But I realized that this ring buffer does not overwrite old data like the traditional definition of a ring/circular buffer.
It is simple to implement a Writer wrapper to do this. For example, simply reading some bytes from the read end if needed. But I will have to ensure concurrency because although the buffer's functions are thread-safe, calling them separately are not.
But before I do, I want to confirm that overwriting data is not supported at this time. Or is there a mode I can set that allows this functionality?
The text was updated successfully, but these errors were encountered: