Coder Social home page Coder Social logo

kevguy / cogsworth Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cdaringe/cogsworth

0.0 2.0 0.0 4.14 MB

easy & capable job scheduling for node & the browser

Home Page: https://cdaringe.github.io/cogsworth

License: MIT License

JavaScript 100.00%

cogsworth's Introduction

cogsworth

easy & capable scheduling for node & the browser

Codeship Status for cdaringe/cogsworth

cogsworth

what

a scheduling suite. use it to:

  • load events, recurrences, or intervals into the system
  • have the system emit an event or call a function when a scheduled event is triggered

for example,

  • "make an API call every 10 minutes"
  • "run a backup every month"
  • "call my sister every 20 seconds"

it ships with:

  • a Scheduler
    • inspired by the all-to-rad Java Quartz scheduler
  • a microservice
    • an easy plug-n-play REST API to load & interact with schedule ticks
  • various extendable scheduling primatives used by the scheduler, such as the Trigger, Schedule, & Storage interfaces (with base classes).

demo

see the docsite

usage

var Scheduler = require('cogsworth-scheduler')
var TriggerRrule = require('cogsworth-trigger-rrule') // e.g. iCal

// create a scheduler & a schedule
var scheduler = new Scheduler()
var schedule = {
  id: 'best_schedule',
  trigger: new TriggerRrule({
    rrule: 'FREQ=SECONDLY;COUNT=5'
  })
}

// add the schedule, start the scheduler, and watch the events stream thru
scheduler.addSchedule(schedule)
.then(scheduler.start.bind(scheduler))
.then(function (observable) {
  observable.subscribe(function logEvent (schedule) {
    console.log(schedule.id, schedule.event.date)
    // best_schedule 2017-07-10T07:26:38.082Z
    // best_schedule 2017-07-10T07:26:39.000Z
    // best_schedule 2017-07-10T07:26:40.000Z
    // best_schedule 2017-07-10T07:26:41.000Z
    // best_schedule 2017-07-10T07:26:42.000Z
  })
})

some users may not care for the observable syntax, and may use the following instead:

var scheduler = new Scheduler({
  onTick: function (schedule) {
    console.log(schedule.id, schedule.event.date)
  }
})
scheduler.addSchedule(...).then(scheduler.start.bind(scheduler))

this is a boring example with only one schedule. add as many schedules as you desire!

cogsworth's People

Contributors

cdaringe avatar greenkeeper[bot] avatar renovate-bot 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.