Kronos

Build Status Coverage Status Gem Version Dependency Status Code Climate

This project allows you to use a scheduler with well defined concepts of runners, storage and tasks. It can work in various storage engines, like memory, redis, disk, database, etc. Also, it supports running in synchronous or asynchronous flows.

Installation

Add this line to your application's Gemfile:

gem 'kronos-ruby', require: ['kronos']

And then execute:

$ bundle

Or install it yourself as:

$ gem install kronos-ruby

Usage

# Define your environment preferences (runner and storage) and register your tasks
Kronos
  .config
  .runner(Kronos::Runner::Synchronous) # or .runner(Kronos::Runner::Asynchronous)
  .storage(Kronos::Storage::InMemory)
  .logger(Kronos::Logger::Stdout) # or .logger(Kronos::Logger::Slack, "Your Slack Webhook URL here")
  .register(:say_good_morning, '8am') { puts 'Good Morning, Team!' }
  .register(:wish_happy_weekend, 'friday, 6pm') { puts 'Happy Weekend, Team!' }
  # ...

# Then start Kronos (This method can be sync or async, acording to the runner you selected)
Kronos.start

Web dashboard

To view Krono's web dashboard, simply mount it into your Rack stack:

mount Kronos::Web::App, at: '/kronos-dashboard'

If you want to protect Kronos dashboard, try using Rack::Auth::Basic:

protected_kronos = Rack::Auth::Basic.new(Kronos::Web::App) do |username, password|
  # Check if username/password tuple is valid
end

mount protected_kronos, at: '/kronos-dashboard'

Developing

  • Clone this repository
  • Run bin/setup to install dependencies
  • You can also run bin/console to start an iteractive console to test Kronos
  • To install this gem onto your local machine, run bundle exec rake install.
  • To release a new version, update lib/version.rb and CHANGELOG.md

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/pdvend/kronos-ruby.

License

The gem is available as open source under the terms of the MIT License.