server availability status uphold, auto dependency detection
npm i @open-node/ticker --save
const Ticker = require('@open-node/ticker'); const ticker = Ticker(['server1', 'server2', 'server3']); // Upload server1 status with call checkServer1AsyncFn per 2 second ticker.tock(checkServer1AsyncFn, 'server1', 2 * 1000); cosnt server1Availability = ticker.status('server1'); // server1Availability is true or false const fn1IfServer1Availability = ticker.runner(fn1, 'server1'); await fn1IfServer1Availability(); // fn1 be called when server1 is enabled unless fn1 will be wait, unit server1 is enabled
Returns Ticker Instance
read/write status value
Returns boolean server's current status value
Dependency detection runner
hitFn
AsyncFunction detection function return true or falsekey
string server‘s keysleepMS
number two times called interval ms
Returns AsyncFunction detection runner be called by async.forever
For a function add dependency detection
fn
function Orig function, it will be add dependency detectionkey
string dependency server's keysleepMS
number dependency detection interval ms (optional, default100
)
Returns function 返回处理后的函数