zhong 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +44 -3
- data/lib/zhong/every.rb +1 -1
- data/lib/zhong/version.rb +1 -1
- data/test/test_every.rb +12 -0
- data/zhong.gemspec +1 -1
- metadata +2 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d80018119a8dad42610c1bf9736cf81eff5e91a7
|
4
|
+
data.tar.gz: d0ebedc85aedfc21e15c3c324525e5a497f56e1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6245f44c4154dcb1c93e08bcc4801b177ac66f33f6531e89d437bf6926c283a777c58cef5514daad6b488c557e2fa5e524423abe48c35812e53c4c917a5fbf38
|
7
|
+
data.tar.gz: 4f9ea33e8d62cca027a0c8383fa0a2683a6a2a8a477090842fb41b7fa484b8139b1ac904f313900bb6f57eb28dc219b011d04915eec7329a25963521774dc3ba
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## 0.2.3
|
2
|
+
|
3
|
+
- Much improved documentation, and executable file naming (thank you Antoine Augusti!)
|
4
|
+
- Fixes to the time parsing & to_s (thank you Antoine Augusti!)
|
5
|
+
|
1
6
|
## 0.2.2
|
2
7
|
|
3
8
|
- Re-licensed as LGPL, as I lifted Sidekiq-web code to power Zhong web (thanks Mike Perham for the great gem and the code!)
|
data/README.md
CHANGED
@@ -4,6 +4,7 @@ Useful, reliable distributed cron. Tired of your cron-like scheduler running key
|
|
4
4
|
|
5
5
|
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.
|
6
6
|
|
7
|
+
:tangerine: Battle-tested at [Instacart](https://www.instacart.com/opensource)
|
7
8
|
# Installation
|
8
9
|
|
9
10
|
Add this line to your application’s Gemfile:
|
@@ -14,6 +15,9 @@ gem 'zhong'
|
|
14
15
|
|
15
16
|
## Usage
|
16
17
|
|
18
|
+
### Zhong schedule
|
19
|
+
Create a definition file, let's call it `zhong.rb`:
|
20
|
+
|
17
21
|
```ruby
|
18
22
|
Zhong.redis = Redis.new(url: ENV["ZHONG_REDIS_URL"])
|
19
23
|
|
@@ -75,18 +79,55 @@ Zhong.schedule do
|
|
75
79
|
end
|
76
80
|
```
|
77
81
|
|
82
|
+
This file only describes what should be the schedule. Nothing will be executed
|
83
|
+
until we actually run
|
84
|
+
```ruby
|
85
|
+
Zhong.start
|
86
|
+
```
|
87
|
+
after describing the Zhong schedule.
|
88
|
+
|
89
|
+
### Zhong cron process
|
90
|
+
|
91
|
+
You can run the cron process that will execute your code from the definitions
|
92
|
+
in the `zhong.rb` file by running:
|
93
|
+
```sh
|
94
|
+
zhong zhong.rb
|
95
|
+
```
|
96
|
+
|
78
97
|
## Web UI
|
79
98
|
|
80
99
|
Zhong comes with a web application that can display jobs, their last run and
|
81
100
|
enable/disable them.
|
82
101
|
|
83
|
-
|
102
|
+
This is a Sinatra application that requires at least `v2.0.0`. You can add to your Gemfile
|
103
|
+
```ruby
|
104
|
+
gem 'sinatra', "~>2.0"
|
105
|
+
```
|
106
|
+
|
107
|
+
It can be protected by HTTP basic authentication by
|
108
|
+
setting the following environment variables:
|
109
|
+
- `ZHONG_WEB_USERNAME`: the username
|
110
|
+
- `ZHONG_WEB_PASSWORD`: the password
|
84
111
|
|
85
|
-
|
112
|
+
You'll need to load the Zhong schedule to be able to see jobs in the web UI, typically
|
113
|
+
by requiring your `zhong.rb` definition file.
|
86
114
|
|
115
|
+
### Rails
|
116
|
+
Load the Zhong schedule by creating an initializer at `config/initializers/zhong.rb`,
|
117
|
+
with the following content:
|
118
|
+
```ruby
|
119
|
+
require "#{Rails.root}/zhong.rb"
|
120
|
+
```
|
121
|
+
|
122
|
+
Add the following to your `config/routes.rb`:
|
87
123
|
```ruby
|
88
124
|
require 'zhong/web'
|
89
|
-
|
125
|
+
|
126
|
+
Rails.application.routes.draw do
|
127
|
+
# Other routes here...
|
128
|
+
|
129
|
+
mount Zhong::Web, at: "/zhong"
|
130
|
+
end
|
90
131
|
```
|
91
132
|
|
92
133
|
## History
|
data/lib/zhong/every.rb
CHANGED
data/lib/zhong/version.rb
CHANGED
data/test/test_every.rb
CHANGED
@@ -77,6 +77,18 @@ class TestEvery < Minitest::Test
|
|
77
77
|
assert_equal time_in_day(0, 0, 7, 10), every.next_at(time_in_day(0, 0, 0, 10))
|
78
78
|
end
|
79
79
|
|
80
|
+
def test_to_s
|
81
|
+
assert_equal "3 minutes", Zhong::Every.parse(3.minute).to_s
|
82
|
+
assert_equal "3 hours", Zhong::Every.parse(3.hour).to_s
|
83
|
+
assert_equal "1 hour", Zhong::Every.parse(1.hour).to_s
|
84
|
+
assert_equal "3 days", Zhong::Every.parse(3.day).to_s
|
85
|
+
assert_equal "3 weeks", Zhong::Every.parse(3.week).to_s
|
86
|
+
assert_equal "3 months", Zhong::Every.parse(3.month).to_s
|
87
|
+
assert_equal "1 month", Zhong::Every.parse(1.month).to_s
|
88
|
+
assert_equal "3 years", Zhong::Every.parse(3.year).to_s
|
89
|
+
assert_equal "3 decades", Zhong::Every.parse(30.years).to_s
|
90
|
+
end
|
91
|
+
|
80
92
|
def test_invalid_string_foo
|
81
93
|
assert_raises Zhong::Every::FailedToParse do
|
82
94
|
Zhong::Every.parse("foo")
|
data/zhong.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0")
|
18
18
|
spec.bindir = "bin"
|
19
|
-
spec.executables =
|
19
|
+
spec.executables = ["zhong"]
|
20
20
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zhong
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Elser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: suo
|
@@ -216,8 +216,6 @@ description: Reliable, distributed cron.
|
|
216
216
|
email:
|
217
217
|
- nick.elser@gmail.com
|
218
218
|
executables:
|
219
|
-
- console
|
220
|
-
- setup
|
221
219
|
- zhong
|
222
220
|
extensions: []
|
223
221
|
extra_rdoc_files: []
|