-
Notifications
You must be signed in to change notification settings - Fork 138
refactor(bitswap/client/internal): close session with Close method instead of context #1011
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
Conversation
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #1011 +/- ##
==========================================
+ Coverage 60.49% 60.55% +0.06%
==========================================
Files 267 268 +1
Lines 33386 33409 +23
==========================================
+ Hits 20196 20232 +36
+ Misses 11514 11502 -12
+ Partials 1676 1675 -1
... and 8 files with indirect coverage changes 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I believe that this is unrelated to blockservice.Session, which is the Session affecting merkledag etc. So this is only bitswap-internal. Sorry for the wall text.
Correct, but sessions are still ephemeral in nature, so your comments may still apply. Also, do we still want to control bitswap session lifetimes with a context to be consistent with how blockservice sessions are handled? I will let this PR sit here for a bit so we and @lidel can think about it more. It is not hight priority. |
f34b764 to
7d89012
Compare
|
@lidel Does a session need to accept a context to maintain retrieval state? |
|
@gammazero yes, context is how we pass state across the stack, search where Lines 202 to 217 in 8b6b1d2
This feels like the least invasive way (optional, no overhead if not in context), but we can change it if there is better way (i did not see it at the time). If we remove context, we need to explicitly pass RetrievalState to session constructor etc. |
|
@lidel Updated to give session retrieval state. |
e3ac76c to
cf77bf2
Compare
- document that sessions manage their own lifecycle - explain automatic cleanup via context.AfterFunc - clarify retrieval state tracking purpose - warn about resource leaks if Close() not called
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm, pushed some comments about Close() being still automated when NewSession(ctx) is used. Feel free to adjust, otherwise ok to merge.
Closes #1009