marmot

A tasks scheduler, using periods, times and channels scheduler
0.1.1 released

marmot

Marmot is a scheduler, use it to schedule tasks.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      marmot:
        github: erdnaxeli/marmot
    
  2. Run shards install

Usage

require "marmot"

repetitions

# This task will repeat every 15 minutes.
repeat_task = Marmot.repeat(15.minutes) { puts Time.local }
# This task will run every day at 15:28:43, and will cancel the previous task.
Marmot.cron(hour: 15, minute: 28, second: 43) do
  puts "It is 15:28:43: #{Time.local}"
  repeat_task.cancel
end

times = 0
# This task will run every 10 seconds and will cancel itself after 10 runs.
Marmot.repeat(10.seconds) do |task|
  times += 1
  puts "#{times} times"
  task.cancel if times = 10
end

# Start the scheduler.
Marmot.run

Development

Don't forget to run the test.

As they deal with timing, they could fail if your computer is busy. Do not hesitate to run then many times if that happens.

Contributing

  1. Fork it (https://github.com/erdnaxeli/marmot/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

marmot:
  github: erdnaxeli/marmot
  version: ~> 0.1.1
License MIT
Crystal 0.35.1

Authors

Dependencies 0

Development Dependencies 1

  • ameba ~>0.13.2
    {'github' => 'crystal-ameba/ameba', 'version' => '~>0.13.2'}

Dependents 0

Last synced .
search fire star recently