Add timeout to queries

Moved from GitHub ratel/36

Posted by paulftw:

Probably needs a config option to change the default value too.

danielmai commented :

Does this need work on Dgraph’s end as well to cancel queries done over HTTP?

paulftw commented :

@danielmai Yes, the reason I haven’t touched on this issue is I was told timeout support is coming to dgraph. But that was back in November or so, I haven’t followed up on the implementation.

AFAIK there’s no good way to cancel an HTTP request from the browser / Ratel code, nor there a benefit in doing so.
We opened this feature in order to prevent from becoming unresponsive when users run expensive queries.
Even when a Ratel page is reloaded Dgraph server keeps working on the abandoned query at the expense of all other requests, often resulting in failed health checks