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

fix: context propagation issue #73

Merged
merged 1 commit into from
Dec 28, 2023
Merged

Conversation

muktihari
Copy link
Owner

The main goals of having context is to cancel the process as soon as we can when the context is canceled or the deadline is exceeded to save resources. This PR should be sufficient to do the logic without altering existing code that much, since it's only one layer above it. Things to note, on Encode for example, when the context is canceled, some bytes written to the io.Writer might be truncated, but it will end with a proper message since we try to stop the process per a single message encoding. It's up to the user to clean up the underlying writer as necessary. If user does not want the file to be truncated, they need to use Encode() instead.

close #72

@muktihari muktihari added the bug Something isn't working label Dec 28, 2023
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (1ea859a) 100.00% compared to head (32a1aec) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##            master       #73   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           27        27           
  Lines         2989      3062   +73     
=========================================
+ Hits          2989      3062   +73     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@muktihari muktihari merged commit 5320f52 into master Dec 28, 2023
1 check passed
@muktihari muktihari deleted the fix/issue-72/context-propagation branch December 28, 2023 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DecodeWithContext and EncodeWithContext's spawned goroutine still running in background
2 participants