Replies: 2 comments
-
I wonder if we should have used the context passed into the If anyone else thinks they would use this please let me know. |
Beta Was this translation helpful? Give feedback.
-
The problem is that But... now there's https://pkg.go.dev/net/http#NewRequestWithContext. Although Ideally The remaining question is: should |
Beta Was this translation helpful? Give feedback.
-
At the moment, there isn't a great way to "cancel" a request if a given context is canceled.
The solution I'm using in my project is:
This way, I open streams as follows...
...and have them reset on either return or when the context is canceled.
But it would be nice to have an official way to do this. Either upstream this function or add something to the interface like:
Which would behave like
SetDeadline
but with contexts. Now that go hascontext.AfterFunc
, this is actually possible without having to spawn a new goroutine. This can also be done at the network stream layer instead of at the transport stream layer, which should make it a minimally breaking change.Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions