Giter VIP home page Giter VIP logo

bossbat's People

Contributors

kesne avatar minttu avatar tjokimie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

bossbat's Issues

Support cron formats

In addition to the every key (which is a string or ms value), we should support a new cron value on the JobDefinition that can be any cron value. We'll parse it and schedule based on it.

This should help support a wider variety of scheduled jobbing outside of just scheduled intervals.

Cron worker runs multiple times during one second

Cron worker runs multiple times during one second with every minute expression.

The following piece of code demonstrates the issue:

const Bossbat = require('bossbat');
const bossbat = new Bossbat();
let i = 0;

bossbat.hire('work', {
  cron: '*/1 * * * *',
  work: () => {
    console.log('Working...', new Date().toString(), i);
    i++;
  }
});

Output:

Working... Sun Feb 26 2017 14:30:00 GMT+0200 (EET) 0
Working... Sun Feb 26 2017 14:30:00 GMT+0200 (EET) 1
Working... Sun Feb 26 2017 14:30:00 GMT+0200 (EET) 2
Working... Sun Feb 26 2017 14:30:00 GMT+0200 (EET) 3
Working... Sun Feb 26 2017 14:30:00 GMT+0200 (EET) 4
Working... Sun Feb 26 2017 14:30:00 GMT+0200 (EET) 5
Working... Sun Feb 26 2017 14:30:00 GMT+0200 (EET) 6
Working... Sun Feb 26 2017 14:30:00 GMT+0200 (EET) 7
Working... Sun Feb 26 2017 14:30:00 GMT+0200 (EET) 8
Working... Sun Feb 26 2017 14:30:00 GMT+0200 (EET) 9
Working... Sun Feb 26 2017 14:30:01 GMT+0200 (EET) 10
Working... Sun Feb 26 2017 14:31:00 GMT+0200 (EET) 11
Working... Sun Feb 26 2017 14:31:00 GMT+0200 (EET) 12
Working... Sun Feb 26 2017 14:31:00 GMT+0200 (EET) 13
Working... Sun Feb 26 2017 14:31:00 GMT+0200 (EET) 14
Working... Sun Feb 26 2017 14:31:00 GMT+0200 (EET) 15
Working... Sun Feb 26 2017 14:31:00 GMT+0200 (EET) 16
Working... Sun Feb 26 2017 14:31:00 GMT+0200 (EET) 17
Working... Sun Feb 26 2017 14:31:00 GMT+0200 (EET) 18
Working... Sun Feb 26 2017 14:31:00 GMT+0200 (EET) 19
Working... Sun Feb 26 2017 14:31:00 GMT+0200 (EET) 20
Working... Sun Feb 26 2017 14:31:01 GMT+0200 (EET) 21

Expected output:

Working... Sun Feb 26 2017 14:30:00 GMT+0200 (EET) 0
Working... Sun Feb 26 2017 14:31:00 GMT+0200 (EET) 1

The issue occurs only if the runner completes relatively fast (in a couple of milliseconds).

Allow ":" character in job names.

Right now we use some lame split logic that prevents us from using : in job names. Let's fix that so that we can use whatever name we like. We'll need to ensure the logic works for demands as well as scheduled jobs.

If `work()` resolves too quickly, multiple machines execute at the same time.

Consider this code:

this.bossbat.hire('cronjob', {
  every: '1 seconds',
  work: async () => {
    console.log(new Date(), 'Cronjob fired');
    await new Promise(resolve => setTimeout(resolve, 1000)); // This is a workaround that fixes this
  },
});

If the 'await new Promise' wasn't there, multiple machines would execute the same command because the lock was already released before the other server tried to get it.

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.