americanas-tech / restQL-golang

Microservice query language and platform
http://restql.b2w.io/
MIT License
17 stars 8 forks source link

Implement support for request cancellation #32

Closed caiorcferreira closed 4 years ago

caiorcferreira commented 4 years ago

This PR introduces a watching mechanism for TCP connection in order to halt the query execution when the client disconnects.

T achieve this we use a system call expose by the syscall package names syscall.Recvfrom. A basic explanation using Go can be found on this StackOverflow answer and a more in-depth one here.

This feature was validated on macOS and Linux Alpine, but not on Windows.

Also, the implementation is designed over the HTTP/1.1 limitation that a connection handles only one HTTP request at a time. In order to support HTTP/2, we will need to change the context indexes handling inside middleware.ConnManager.