continuity 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/Gemfile +14 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +62 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/continuity.gemspec +71 -0
- data/examples/worker.rb +17 -0
- data/lib/continuity.rb +5 -0
- data/lib/continuity/cron_entry.rb +91 -0
- data/lib/continuity/periodic_entry.rb +22 -0
- data/lib/continuity/redis_backend.rb +79 -0
- data/lib/continuity/scheduler.rb +78 -0
- data/test/helper.rb +34 -0
- data/test/redis.conf +421 -0
- data/test/test_cron_entry.rb +191 -0
- data/test/test_periodic_entry.rb +109 -0
- data/test/test_race_issues.rb +62 -0
- data/test/test_redis_backend.rb +146 -0
- data/test/test_scheduler.rb +55 -0
- metadata +136 -0
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'continuity'
|
4
|
+
|
5
|
+
include Continuity
|
6
|
+
|
7
|
+
describe Scheduler do
|
8
|
+
before do
|
9
|
+
@backend = MiniTest::Mock.new
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "do_jobs" do
|
13
|
+
describe "cron job '0 0 * * * *'" do
|
14
|
+
before do
|
15
|
+
@scheduler = Scheduler.new(@backend)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should run every hour" do
|
19
|
+
job_run = false
|
20
|
+
@scheduler.cron("0 0 * * * *") do
|
21
|
+
job_run = true
|
22
|
+
end
|
23
|
+
|
24
|
+
time = Time.parse("2010-12-20 08:00:00").to_i
|
25
|
+
@scheduler.do_jobs(time..time)
|
26
|
+
|
27
|
+
job_run.must_equal true
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "maybe schedule" do
|
33
|
+
before do
|
34
|
+
@scheduler = Scheduler.new_using_redis(redis_clean)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should call a passed in block with the range scheduled" do
|
38
|
+
range = nil
|
39
|
+
@scheduler.maybe_schedule do |r|
|
40
|
+
range = r
|
41
|
+
end
|
42
|
+
assert range
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should call #on_schedule blocks" do
|
46
|
+
range = nil
|
47
|
+
@scheduler.on_schedule do |r|
|
48
|
+
range = r
|
49
|
+
end
|
50
|
+
|
51
|
+
@scheduler.maybe_schedule
|
52
|
+
assert range
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
metadata
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: continuity
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bob Potter
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: redis
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.3.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.3.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: jeweler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.8.7
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.8.7
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Distributed scheduling of jobs
|
84
|
+
email: bobby.potter@gmail.com
|
85
|
+
executables: []
|
86
|
+
extensions: []
|
87
|
+
extra_rdoc_files:
|
88
|
+
- LICENSE.txt
|
89
|
+
- README.rdoc
|
90
|
+
files:
|
91
|
+
- .document
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.rdoc
|
95
|
+
- Rakefile
|
96
|
+
- VERSION
|
97
|
+
- continuity.gemspec
|
98
|
+
- examples/worker.rb
|
99
|
+
- lib/continuity.rb
|
100
|
+
- lib/continuity/cron_entry.rb
|
101
|
+
- lib/continuity/periodic_entry.rb
|
102
|
+
- lib/continuity/redis_backend.rb
|
103
|
+
- lib/continuity/scheduler.rb
|
104
|
+
- test/helper.rb
|
105
|
+
- test/redis.conf
|
106
|
+
- test/test_cron_entry.rb
|
107
|
+
- test/test_periodic_entry.rb
|
108
|
+
- test/test_race_issues.rb
|
109
|
+
- test/test_redis_backend.rb
|
110
|
+
- test/test_scheduler.rb
|
111
|
+
homepage: http://github.com/bpot/continuity
|
112
|
+
licenses:
|
113
|
+
- MIT
|
114
|
+
metadata: {}
|
115
|
+
post_install_message:
|
116
|
+
rdoc_options: []
|
117
|
+
require_paths:
|
118
|
+
- lib
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - '>='
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - '>='
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
requirements: []
|
130
|
+
rubyforge_project:
|
131
|
+
rubygems_version: 2.0.2
|
132
|
+
signing_key:
|
133
|
+
specification_version: 4
|
134
|
+
summary: Allows you to distribute job scheduling across a number of processes
|
135
|
+
test_files: []
|
136
|
+
has_rdoc:
|