richardartoul / nola

MIT License
74 stars 6 forks source link

Propagate context deadlines over RPCs #82

Closed richardartoul closed 1 year ago

richardartoul commented 1 year ago

We lose the context deadlines when we go over the network with the HTTP client. We should propagate it as a header

aratz-lasa commented 1 year ago

I realized that there is no need to add explicit timeouts in the header. Currently, we already perform HTTP requests with timeouts on the client side. Therefore, on the server side, instead of creating a separate context with timeout, we can leverage the Context that is attached to every http.Request. By using the request's context, when the timeout is reached, the client will automatically cancel the HTTP connection. As a result, the corresponding request context on the server side will also be canceled, ensuring timely termination of the request processing. This approach allows us to utilize the existing request context and its built-in cancellation mechanism, rather than creating a separate timeout value.

aratz-lasa commented 1 year ago

PS: https://github.com/golang/go/issues/19562#issuecomment-286830094