Giter Site home page Giter Site logo

jobmanager's Introduction

JobManager

Basic job system that can schedule and execute jobs of different types.

Create different job definitions that run asynchronously.

Installation

Clone and Install dependencies using npm

git clone https://github.com/shalev007/JobManager.git .
npm install

Usage

import JobManager from './JobManager/index.js';

// register a function with type and a schedule
JobManager.registerJob('send-notifications', { millisecond: 4000, recurrent: true }, () => {
    console.log(`send-notifications`);
});

// start running jobs
JobManager.run();

// you can add jobs after the jobs started running
JobManager.registerJob('usage-report', { millisecond: 2000, recurrent: true }, () => {
    console.log(`usage-report 1`);
});

// add a job to run immediately
JobManager.registerJob('run once', { millisecond: 0, recurrent: false }, () => {
    console.log(`You'll only see this line once`);
});

// inspect current statistics about the JobManager internals
JobManager.registerJob('show stats', { millisecond: 5000, recurrent: true }, () => {
    console.log(JobManager.inspect());
});

// stop the running jobs
JobManager.registerJob('Stop', { millisecond: 15000, recurrent: false }, () => {
    JobManager.stop();
    console.log(`Stopped Job manager`);
});

// clear all saved jobs and event queue
JobManager.registerJob('Clear', { millisecond: 0, recurrent: false }, () => {
    JobManager.clear();
    console.log(`Cleared Job manager`);
});

Usage

Use Jest.js to test

npm run test

Author

Shalev Avhar

License

MIT

jobmanager's People

Contributors

shalev007 avatar

Watchers

 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.