This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Based on http://bit.ly/215MBZ | |
| function FailureDetector(ws) { | |
| // ws stands for window size. | |
| // How many heartbeat intervals we keep track of. | |
| this.ws = ws || 100; | |
| this.window = []; | |
| this.last = null; | |
| } | |
| exports.FailureDetector = FailureDetector; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local function out_of_range(i,n) | |
| if type(i) == 'number' then | |
| if i > 0 and i <= n then return true | |
| else error('out of range',3) | |
| end | |
| else | |
| error 'cannot index array by non-number type' | |
| end | |
| end |
NewerOlder