Skip to content

server availability status uphold, auto dependency detection

License

Notifications You must be signed in to change notification settings

open-node/ticker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@open-node/ticker

server availability status uphold, auto dependency detection

Build status codecov

Installation

npm i @open-node/ticker --save

Usage

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

Table of Contents

Ticker

Parameters

Returns Ticker Instance

status

read/write status value

Parameters

  • key string server's unique key
  • value boolean? server's status value

Returns boolean server's current status value

tock

Dependency detection runner

Parameters

  • hitFn AsyncFunction detection function return true or false
  • key string server‘s key
  • sleepMS number two times called interval ms

Returns AsyncFunction detection runner be called by async.forever

runner

For a function add dependency detection

Parameters

  • fn function Orig function, it will be add dependency detection
  • key string dependency server's key
  • sleepMS number dependency detection interval ms (optional, default 100)

Returns function 返回处理后的函数

Releases

No releases published

Packages