Skip to content
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

zapcore: Add Buffered Writer #961

Merged
merged 74 commits into from
Jun 8, 2021
Merged

zapcore: Add Buffered Writer #961

merged 74 commits into from
Jun 8, 2021

Conversation

abhinav
Copy link
Collaborator

@abhinav abhinav commented Jun 8, 2021

Add a BufferedWriteSyncer that buffers writes in memory before flushing
them to the underlying WriteSyncer at some interval or when a
configured amount of data has been buffered -- whichever comes first.


This is a copy of #952 (which itself is a fork of #782) because it was
accidentally merged instead of squashed, and wasn't yet fully reviewed.

@abhinav abhinav mentioned this pull request Jun 8, 2021
@abhinav abhinav requested a review from prashantv June 8, 2021 17:57
@codecov
Copy link

codecov bot commented Jun 8, 2021

Codecov Report

Merging #961 (ac5b8ad) into master (cfe34dc) will increase coverage by 0.06%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #961      +/-   ##
==========================================
+ Coverage   98.12%   98.18%   +0.06%     
==========================================
  Files          44       45       +1     
  Lines        1975     2041      +66     
==========================================
+ Hits         1938     2004      +66     
  Misses         29       29              
  Partials        8        8              
Impacted Files Coverage Δ
zapcore/buffered_write_syncer.go 100.00% <100.00%> (ø)
zaptest/observer/observer.go 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cfe34dc...ac5b8ad. Read the comment docs.

These methods should not panic if called without `Write` first (which is
what starts the background goroutine).
Writing `BufferedWriteSyncer{WriteSyncer: ...}` is a mouthful. Let's
go for something short and obvious like:

```
package io

type LimitedReader struct {
    R Reader // underlying reader
    N int64  // max bytes remaining
}
```
zapcore/buffered_write_syncer.go Outdated Show resolved Hide resolved
zapcore/buffered_write_syncer.go Outdated Show resolved Hide resolved
zapcore/buffered_write_syncer.go Outdated Show resolved Hide resolved
@abhinav abhinav merged commit aa3e73e into master Jun 8, 2021
@abhinav abhinav deleted the buffered-writer branch June 8, 2021 23:51
@akshayjshah
Copy link
Contributor

This is awesome! Glad to see that buffering finally made it in :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants