README.md in zhong-0.1.4 vs README.md in zhong-0.1.5
- old
+ new
@@ -1,6 +1,6 @@
-# Zhong
+# Zhong [![Build Status](https://travis-ci.org/nickelser/zhong.svg?branch=master)](https://travis-ci.org/nickelser/zhong) [![Code Climate](https://codeclimate.com/github/nickelser/zhong/badges/gpa.svg)](https://codeclimate.com/github/nickelser/zhong) [![Test Coverage](https://codeclimate.com/github/nickelser/zhong/badges/coverage.svg)](https://codeclimate.com/github/nickelser/zhong) [![Gem Version](https://badge.fury.io/rb/zhong.svg)](http://badge.fury.io/rb/zhong)
Useful, reliable distributed cron. Tired of your cron-like scheduler running key jobs twice? Would you like to be able to run your cron server on multiple machines and have it "just work"? Have we got the gem for you.
Zhong uses Redis to acquire exclusive locks on jobs, as well as recording when they last ran. This means that you can rest easy at night, knowing that your customers are getting their monthly Goat Fancy magazine subscriptions and you are rolling around in your piles of money without a care in the world.
@@ -13,37 +13,40 @@
```
## Usage
```ruby
-r = Redis.new
+Zhong.redis = Redis.new(url: ENV["ZHONG_REDIS_URL"])
-Zhong.schedule(redis: r) do |s|
- s.category "stuff" do
- s.every(5.seconds, "foo") { puts "foo" }
- s.every(1.minute, "biz", at: ["**:26", "**:27"]) { puts "biz" }
- s.every(1.week, "baz", at: ["mon 22:45", "wed 23:13"]) { puts "baz" }
- s.every(10.seconds, "boom") { raise "fail" }
+Zhong.schedule do
+ category "stuff" do
+ every 5.seconds, "foo" do
+ puts "foo"
+ end
+
+ every(1.minute, "biz", at: ["**:26", "**:27"]) { puts "biz" }
+ every(1.week, "baz", at: ["mon 22:45", "wed 23:13"]) { puts "baz" }
+ every(10.seconds, "boom") { raise "fail" }
end
- s.category "clutter" do
- s.every(1.second, "compute", if: -> (t) { t.wday == 3 && rand < 0.5 }) do
+ category "clutter" do
+ every(1.second, "compute", if: -> (t) { t.wday == 3 && rand < 0.5 }) do
puts "something happened on wednesday, maybe"
end
end
# note: callbacks that return nil or false will cause event to not run
- s.on(:before_tick) do
+ on(:before_tick) do
puts "ding"
true
end
- s.on(:after_tick) do
+ on(:after_tick) do
puts "dong"
true
end
- s.error_handler do |e, job|
+ error_handler do |e, job|
puts "damn, #{job} messed up: #{e}"
end
end
```