feat: allow tracking state across requests in tokio_thread#950
feat: allow tracking state across requests in tokio_thread#950thomaseizinger wants to merge 2 commits intogetsentry:masterfrom
tokio_thread#950Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #950 +/- ##
==========================================
- Coverage 73.81% 73.65% -0.16%
==========================================
Files 64 64
Lines 7538 7515 -23
==========================================
- Hits 5564 5535 -29
- Misses 1974 1980 +6 |
szokeasaurusrex
left a comment
There was a problem hiding this comment.
Thanks for the contribution!
I have some thoughts here:
- As #949 makes the
TransportThreadpublic, this change to thenewfunction is now an API-breaking change. I think we should instead keep thenewfunction's signature unchanged, and instead, add a new function called something likenew_with_statethat allows for a state to be passed to thesendfunction. - We should add some tests for this functionality.
Well, has it been released already? If it hasn't been released yet then we could just consider this to be the new API? I am happy to introduce a new constructor as well though, if you think it is worth having both! |
What would you like to have tested? The type-system enforces a lot here. Happy to add tests though if you see additional risk here. |
Description
Due to limitations in how
asyncblocks interact with closures, it is impossible to borrow something from outside of a closure into anasyncblock. A custom transport implementation may want to track state for the lifetime of the thread, in addition to the rate limiter.We make this possible by adding another
stateargument.Issues
Related: #949
Reminders
feat:,fix:,ref:,meta:, etc.)