perfectsched 0.7.11 → 0.7.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/ChangeLog CHANGED
@@ -1,4 +1,9 @@
1
1
 
2
+ == 2012-02-21 version 0.7.12
3
+
4
+ * RDBBackend: added MySQL's SSL support
5
+
6
+
2
7
  == 2012-02-21 version 0.7.10
3
8
 
4
9
  * Fixed NullBackend#modify_checked
@@ -3,12 +3,24 @@ module PerfectSched
3
3
 
4
4
 
5
5
  class RDBBackend < Backend
6
- def initialize(uri, table)
6
+ def initialize(uri, table, config={})
7
7
  super()
8
8
  require 'sequel'
9
+ require 'uri'
9
10
  @uri = uri
10
11
  @table = table
11
- @db = Sequel.connect(@uri)
12
+
13
+ u = URI.parse(url)
14
+ options = {
15
+ max_connections: 1,
16
+ user: u.user,
17
+ password: u.password,
18
+ host: u.host,
19
+ port: u.port ? u.port.to_i : 3306
20
+ }
21
+ options[:sslca] = config[:sslca] if config[:sslca]
22
+ @db = Sequel.mysql2(db_name, options)
23
+
12
24
  #init_db(@uri.split('//',2)[0])
13
25
  connect {
14
26
  # connection test
@@ -1,5 +1,5 @@
1
1
  module PerfectSched
2
2
 
3
- VERSION = '0.7.11'
3
+ VERSION = '0.7.12'
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.11
4
+ version: 0.7.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-19 00:00:00.000000000 Z
12
+ date: 2014-04-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cron-spec
@@ -88,7 +88,6 @@ executables:
88
88
  extensions: []
89
89
  extra_rdoc_files:
90
90
  - ChangeLog
91
- - README.md.html
92
91
  - README.rdoc
93
92
  files:
94
93
  - bin/perfectsched
@@ -102,7 +101,6 @@ files:
102
101
  - lib/perfectsched/engine.rb
103
102
  - lib/perfectsched/version.rb
104
103
  - ChangeLog
105
- - README.md.html
106
104
  - README.rdoc
107
105
  - test/backend_test.rb
108
106
  - test/test_helper.rb
@@ -126,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
124
  version: '0'
127
125
  requirements: []
128
126
  rubyforge_project:
129
- rubygems_version: 1.8.23
127
+ rubygems_version: 1.8.24
130
128
  signing_key:
131
129
  specification_version: 3
132
130
  summary: Highly available distributed cron built on RDBMS or SimpleDB
data/README.md.html DELETED
@@ -1,153 +0,0 @@
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>