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

feat(util-stream): splitStream and headStream utilities #1336

Merged
merged 6 commits into from
Jul 15, 2024

Conversation

kuhe
Copy link
Contributor

@kuhe kuhe commented Jul 12, 2024

  • splitStream splits a stream into two streams using pipe(PassThrough) or tee() depending on Stream type.
  • headStream collects the first N bytes of a stream.

Use case: peek the head of a stream's copy while leaving the 2nd copy of that original stream intact

Use case: obtain a parallel stream for checksumming

@kuhe kuhe requested review from a team as code owners July 12, 2024 20:28
@kuhe kuhe requested a review from sugmanue July 12, 2024 20:28
@kuhe
Copy link
Contributor Author

kuhe commented Jul 15, 2024

I've tested this for memory leaks. As long as the additional split stream reaches reference count 0 it will be garbage collected without needing to explicitly call its destructor or draining it.

@kuhe kuhe merged commit 7cd258f into smithy-lang:main Jul 15, 2024
10 checks passed
@kuhe kuhe deleted the feat/split-stream branch July 15, 2024 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants