perfectsched 0.7.10 → 0.7.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md.html +153 -0
  2. data/lib/perfectsched/version.rb +1 -1
  3. metadata +32 -18
data/README.md.html ADDED
@@ -0,0 +1,153 @@
1
+
2
+ <html>
3
+ <head><title>-</title></head>
4
+ <body>
5
+ <h1>PerfectSched</h1>
6
+
7
+ <p>PerfectSched is a highly available distributed cron built on top of RDBMS.</p>
8
+
9
+ <p>It provides at-least-once semantics; Even if a worker node fails during process a task, the task is retried by another worker.</p>
10
+
11
+ <p>PerfectSched also guarantees that only one worker server processes a task if the server is alive.</p>
12
+
13
+ <p>All you have to consider is implementing idempotent worker programs. It's recommended to use <a href="https://github.com/treasure-data/perfectqueue">PerfectQueue</a> with PerfectSched.</p>
14
+
15
+ <h2>API overview</h2>
16
+
17
+ <p>```ruby</p>
18
+
19
+ <h1>open a schedule collection</h1>
20
+
21
+ <p>PerfectSched.open(config, &amp;block) #=> #<ScheduleCollection></p>
22
+
23
+ <h1>add a schedule</h1>
24
+
25
+ <p>ScheduleCollection#add(task_id, type, options)</p>
26
+
27
+ <h1>poll a scheduled task</h1>
28
+
29
+ <h1>(you don't have to use this method directly. see following sections)</h1>
30
+
31
+ <p>ScheduleCollection#poll #=> #<Task></p>
32
+
33
+ <h1>get data associated with a task</h1>
34
+
35
+ <p>Task#data #=> #<Hash></p>
36
+
37
+ <h1>finish a task</h1>
38
+
39
+ <p>Task#finish!</p>
40
+
41
+ <h1>retry a task</h1>
42
+
43
+ <p>Task#retry!
44
+ ```</p>
45
+
46
+ <p>Example:</p>
47
+
48
+ <p>```ruby</p>
49
+
50
+ <h1>submit a task</h1>
51
+
52
+ <p>PerfectSched.open(config) {|sc|
53
+ data = {'key'=>"value"}
54
+ options = {</p>
55
+
56
+ <pre><code>:cron =&gt; '0 * * * *',
57
+ :delay =&gt; 30,
58
+ :timezone =&gt; 'Asia/Tokyo',
59
+ :next_time =&gt; Time.parse('2013-01-01 00:00:00 +0900').to_i,
60
+ :data =&gt; data,
61
+ </code></pre>
62
+
63
+ <p> }
64
+ sc.submit("sched-id", "type1", options)
65
+ }
66
+ ```</p>
67
+
68
+ <h2>Writing a worker application</h2>
69
+
70
+ <h3>1. Implement PerfectSched::Application::Base</h3>
71
+
72
+ <p>```ruby
73
+ class TestHandler &lt; PerfectSched::Application::Base
74
+ # implement run method
75
+ def run</p>
76
+
77
+ <pre><code># do something ...
78
+ puts "acquired task: #{task.inspect}"
79
+
80
+ # call task.finish!, task.retry! or task.release!
81
+ task.finish!
82
+ </code></pre>
83
+
84
+ <p> end
85
+ end</p>
86
+
87
+ <h3>2. Implement PerfectSched::Application::Dispatch</h3>
88
+
89
+ <p><code>ruby
90
+ class Dispatch &lt; PerfectSched::Application::Dispatch
91
+ # describe routing
92
+ route "type1" =&gt; TestHandler
93
+ route /^regexp-.*$/ =&gt; :TestHandler # String or Regexp =&gt; Class or Symbol
94
+ end
95
+ </code></p>
96
+
97
+ <h3>3. Run the worker</h3>
98
+
99
+ <p>In a launcher script or rake file:</p>
100
+
101
+ <p>```</p>
102
+
103
+ <h1>run PerfectSched::Worker with the dispatcher</h1>
104
+
105
+ <p>system('perfectsched run -I. -rapp/schedules/dispatch Dispatch')
106
+ ```</p>
107
+
108
+ <p>or:</p>
109
+
110
+ <p><code>ruby
111
+ require 'app/schedules/dispatch'
112
+ PerfectSched::Worker.run(Dispatch) {
113
+ # this method is called when the worker process is restarted
114
+ raw = File.read('config/perfectsched.yml')
115
+ yml = YAJL.load(raw)
116
+ yml[ENV['RAILS_ENV'] || 'development']
117
+ }
118
+ </code></p>
119
+
120
+ <h3>Signal handlers</h3>
121
+
122
+ <ul>
123
+ <li><em>TERM,INT,QUIT:</em> shutdown</li>
124
+ <li><em>USR1,HUP:</em> restart</li>
125
+ <li><em>USR2:</em> reopen log files</li>
126
+ </ul>
127
+
128
+
129
+ <h2>Configuration</h2>
130
+
131
+ <ul>
132
+ <li><em>type:</em> backend type (required; see following sections)</li>
133
+ <li><em>log:</em> log file path (default: use stderr)</li>
134
+ <li><em>poll_interval:</em> interval to poll tasks in seconds (default: 1.0 sec)</li>
135
+ <li><em>timezone:</em> default timezone (default: 'UTC')</li>
136
+ <li><em>alive_time:</em> duration to continue a heartbeat request (default: 300 sec)</li>
137
+ <li><em>retry_wait:</em> duration to retry a retried task (default: 300 sec)</li>
138
+ </ul>
139
+
140
+
141
+ <h2>Backend types</h2>
142
+
143
+ <h3>rdb_compat</h3>
144
+
145
+ <p>additional configuration:</p>
146
+
147
+ <ul>
148
+ <li><strong>url:</strong> URL to the RDBMS (example: 'mysql://user:password@host:port/database')</li>
149
+ <li><strong>table:</strong> name of the table to use</li>
150
+ </ul>
151
+
152
+ </body>
153
+ </html>
@@ -1,5 +1,5 @@
1
1
  module PerfectSched
2
2
 
3
- VERSION = '0.7.10'
3
+ VERSION = '0.7.11'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: perfectsched
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.10
4
+ version: 0.7.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-22 00:00:00.000000000Z
12
+ date: 2012-09-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cron-spec
16
- requirement: &70167766607900 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - <=
@@ -24,10 +24,18 @@ dependencies:
24
24
  version: 0.1.2
25
25
  type: :runtime
26
26
  prerelease: false
27
- version_requirements: *70167766607900
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - <=
31
+ - !ruby/object:Gem::Version
32
+ version: 0.1.2
33
+ - - ! '>='
34
+ - !ruby/object:Gem::Version
35
+ version: 0.1.2
28
36
  - !ruby/object:Gem::Dependency
29
37
  name: sequel
30
- requirement: &70167766607160 !ruby/object:Gem::Requirement
38
+ requirement: !ruby/object:Gem::Requirement
31
39
  none: false
32
40
  requirements:
33
41
  - - ~>
@@ -35,21 +43,15 @@ dependencies:
35
43
  version: 3.26.0
36
44
  type: :runtime
37
45
  prerelease: false
38
- version_requirements: *70167766607160
39
- - !ruby/object:Gem::Dependency
40
- name: aws-sdk
41
- requirement: &70167766606680 !ruby/object:Gem::Requirement
46
+ version_requirements: !ruby/object:Gem::Requirement
42
47
  none: false
43
48
  requirements:
44
49
  - - ~>
45
50
  - !ruby/object:Gem::Version
46
- version: 1.1.1
47
- type: :runtime
48
- prerelease: false
49
- version_requirements: *70167766606680
51
+ version: 3.26.0
50
52
  - !ruby/object:Gem::Dependency
51
53
  name: perfectqueue
52
- requirement: &70167766606200 !ruby/object:Gem::Requirement
54
+ requirement: !ruby/object:Gem::Requirement
53
55
  none: false
54
56
  requirements:
55
57
  - - ~>
@@ -57,10 +59,15 @@ dependencies:
57
59
  version: 0.7.0
58
60
  type: :runtime
59
61
  prerelease: false
60
- version_requirements: *70167766606200
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: 0.7.0
61
68
  - !ruby/object:Gem::Dependency
62
69
  name: tzinfo
63
- requirement: &70167766605720 !ruby/object:Gem::Requirement
70
+ requirement: !ruby/object:Gem::Requirement
64
71
  none: false
65
72
  requirements:
66
73
  - - ~>
@@ -68,7 +75,12 @@ dependencies:
68
75
  version: 0.3.29
69
76
  type: :runtime
70
77
  prerelease: false
71
- version_requirements: *70167766605720
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ~>
82
+ - !ruby/object:Gem::Version
83
+ version: 0.3.29
72
84
  description:
73
85
  email: frsyuki@gmail.com
74
86
  executables:
@@ -76,6 +88,7 @@ executables:
76
88
  extensions: []
77
89
  extra_rdoc_files:
78
90
  - ChangeLog
91
+ - README.md.html
79
92
  - README.rdoc
80
93
  files:
81
94
  - bin/perfectsched
@@ -89,6 +102,7 @@ files:
89
102
  - lib/perfectsched/engine.rb
90
103
  - lib/perfectsched/version.rb
91
104
  - ChangeLog
105
+ - README.md.html
92
106
  - README.rdoc
93
107
  - test/backend_test.rb
94
108
  - test/test_helper.rb
@@ -112,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
126
  version: '0'
113
127
  requirements: []
114
128
  rubyforge_project:
115
- rubygems_version: 1.8.12
129
+ rubygems_version: 1.8.23
116
130
  signing_key:
117
131
  specification_version: 3
118
132
  summary: Highly available distributed cron built on RDBMS or SimpleDB