Coder Social home page Coder Social logo

cron-sched's Introduction

Cron-Sched

Uses the cron library which has "seconds" and eventually "microseconds" resolution:

https://github.com/adarqui/cron

Original:

https://github.com/MichaelXavier/cron

TODO:

Alot todo.. Mainly:

  • Synchronize clock the "0th" second & minute
  • Add a schedM (collect results from every cb)
  • Maybe use async to make sure we 'end gracefully'

Info

data Sched = Sched {
 _tick :: Int,
 _limit :: Integer,
 _schedule :: CronSchedule
} deriving (Show)

sched will create a scheduler that will 'fire' every tick. If the schedule matches, it will fire off a thread for every io action passed in the 'acts' list. If a > 0 limit is supplied, it will be decremented every time there is a schedule match; once it hits 0, sched will return. Passing (-1) for "limit" will cause sched to run forever.

The cron syntax has an added "seconds" cron field:

* * * * *
s m hr d mon yr

Some library examples:

sched defaultSecond [print "fi",print "fo",print "fum"]
sched defaultMinute [print "fi",print "fo",print "fum"]
sched (fromRight $ fromString secondTick 10 "* * * * * *") [print "fi",print "fo",print "fum"]
sched (fromRight $ fromString secondTick 5 "*/2 * * * * *") [print "fi",print "fo",print "fum"]
sched (fromRight $ fromString minuteTick 1 "* * * * * *") [print "fi",print "fo",print "fum"]

Some quick examples:

./.cabal-sandbox/bin/exec 1000000 -1 "*/2 * * * * *"

cron-sched's People

Contributors

adarqui 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.