Skip to content

Add Iterator.StringReader() #359

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rsandwick
Copy link

Add Iterator.StringReader() to allow consumers to stream a JSON string without copying to unnecessary buffers.

I fully expect this PR to probably be at least initially rejected, since I have provided neither a reliable means, nor documentation with sufficiently scary warnings, to avoid letting the consumer fail to read the full string, which in turn obviously ruins the state of the Iterator/Decoder.

However, I do think it's a decent starting point toward letting consumers avoid large buffer use in the case that an interesting and streamable large blob happens to be a JSON string in the bytestream. I do think it's at least in the spirit of this library, or I wouldn't be posting a PR at all.

I do also intend to add proper commentary and docs eventually, but it may take me some time to get to it, so if anybody were interested in taking a stab first, I'd be very grateful to hear that in the rejection message for this request :-)

For now, I'm using this in a personal project, and ensuring that I io.Reader.Read(...) through the entire JSON string by being explicit about that, but I thought I'd share this rather than keep it to myself, as it seems to be helpful. Please let me know if an example of how this has proved useful would perhaps lean folks in the direction of including this after all.

@codecov
Copy link

codecov bot commented Apr 20, 2019

Codecov Report

Merging #359 into master will decrease coverage by 0.39%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #359     +/-   ##
=========================================
- Coverage   81.82%   81.43%   -0.4%     
=========================================
  Files          41       42      +1     
  Lines        5008     5036     +28     
=========================================
+ Hits         4098     4101      +3     
- Misses        791      816     +25     
  Partials      119      119
Impacted Files Coverage Δ
iter_str_reader.go 0% <0%> (ø)
reflect_struct_decoder.go 49.16% <0%> (+0.41%) ⬆️

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 0ff49de...054d130. Read the comment docs.

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