uber-node / ringpop-node

Scalable, fault-tolerant application-layer sharding for Node.js applications
http://uber.github.io/ringpop/
MIT License
1.18k stars 146 forks source link

Track potentially wedged requests and cancel them #238

Closed jwolski closed 8 years ago

jwolski commented 8 years ago

This pull requests creates a trackable request object (ClientRequest). Inflight requests (that have not had their callback called) are placed into requestsById in the Client object. There is a background timer (wedgedTimer) that periodically scans for "wedged requests" and cancels the request by preemptively invoking its callback. A wedged requests is canceled if it has been inflight for greater than wedgedRequestTimeout.

Internally, ClientRequest maintains a "state machine" at each step of the TChannel-send process. When a ClientRequest is canceled, its callback will be invoked by Client. The ClientRequest also makes sure that a callback isn't called multiple times by nullifying the callback after its first invocation.

@uber/ringpop