refactor(bitswap/client/internal): close session with Close method instead of context#1011
refactor(bitswap/client/internal): close session with Close method instead of context#1011
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:
|
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
lidel
left a comment
There was a problem hiding this comment.
Lgtm, pushed some comments about Close() being still automated when NewSession(ctx) is used. Feel free to adjust, otherwise ok to merge.
Closes #1009