Coder Social home page Coder Social logo

ticker's Introduction

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

ticker's People

Contributors

zhaoxiongfei avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.