JSPM

@open-node/ticker

0.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 9
  • Score
    100M100P100Q36730F
  • License MIT

log recorder, info and error

Package Exports

  • @open-node/ticker

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@open-node/ticker) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@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 返回处理后的函数