@open-node/ticker
log recorder, info and error
Last updated 6 months ago by stonephp .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @open-node/ticker 
SYNC missed versions from official npm registry.

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

Current Tags

  • 0.1.1                                ...           latest (6 months ago)

2 Versions

  • 0.1.1                                ...           6 months ago
  • 0.1.0                                ...           6 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |