perfectsched 0.8.2 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +5 -0
- data/lib/perfectsched/application/base.rb +44 -0
- data/lib/perfectsched/application/decider.rb +55 -0
- data/lib/perfectsched/application.rb +3 -0
- data/lib/perfectsched/version.rb +1 -1
- data/perfectsched.gemspec +1 -1
- metadata +20 -19
data/ChangeLog
CHANGED
@@ -20,6 +20,50 @@ module PerfectSched
|
|
20
20
|
module Application
|
21
21
|
|
22
22
|
class Base < Runner
|
23
|
+
def self.decider
|
24
|
+
DefaultDecider
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.decider=(decider_klass)
|
28
|
+
(class<<self;self;end).instance_eval do
|
29
|
+
self.__send__(:define_method, :decider) { decider_klass }
|
30
|
+
end
|
31
|
+
decider_klass
|
32
|
+
end
|
33
|
+
|
34
|
+
def initialize(task)
|
35
|
+
super
|
36
|
+
@decider = self.class.decider.new(self)
|
37
|
+
end
|
38
|
+
|
39
|
+
attr_reader :decider
|
40
|
+
|
41
|
+
def run
|
42
|
+
begin
|
43
|
+
return unless before_perform
|
44
|
+
begin
|
45
|
+
perform
|
46
|
+
ensure
|
47
|
+
after_perform
|
48
|
+
end
|
49
|
+
rescue
|
50
|
+
decide! :unexpected_error_raised, :error=>$!
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def before_perform
|
55
|
+
true
|
56
|
+
end
|
57
|
+
|
58
|
+
#def perform
|
59
|
+
#end
|
60
|
+
|
61
|
+
def after_perform
|
62
|
+
end
|
63
|
+
|
64
|
+
def decide!(type, option={})
|
65
|
+
@decider.decide!(type, option)
|
66
|
+
end
|
23
67
|
end
|
24
68
|
|
25
69
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#
|
2
|
+
# PerfectSched
|
3
|
+
#
|
4
|
+
# Copyright (C) 2012 FURUHASHI Sadayuki
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
module PerfectSched
|
20
|
+
module Application
|
21
|
+
|
22
|
+
require 'perfectqueue/application/decider'
|
23
|
+
|
24
|
+
UndefinedDecisionError = PerfectQueue::Application::UndefinedDecisionError
|
25
|
+
|
26
|
+
class Decider
|
27
|
+
def initialize(base)
|
28
|
+
@base = base
|
29
|
+
end
|
30
|
+
|
31
|
+
def schedules
|
32
|
+
@base.schedules
|
33
|
+
end
|
34
|
+
|
35
|
+
def task
|
36
|
+
@base.task
|
37
|
+
end
|
38
|
+
|
39
|
+
def decide!(type, opts={})
|
40
|
+
begin
|
41
|
+
m = method(type)
|
42
|
+
rescue NameError
|
43
|
+
raise UndefinedDecisionError, "Undefined decision #{type} options=#{opt.inspect}"
|
44
|
+
end
|
45
|
+
m.call(type, opts)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class DefaultDecider < Decider
|
50
|
+
# no decisions defined
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
@@ -23,6 +23,9 @@ module PerfectSched
|
|
23
23
|
:Dispatch => 'application/dispatch',
|
24
24
|
:Router => 'application/router',
|
25
25
|
:RouterDSL => 'application/router',
|
26
|
+
:Decider => 'application/decider',
|
27
|
+
:DefaultDecider => 'application/decider',
|
28
|
+
:UndefinedDecisionError => 'application/decider',
|
26
29
|
:Base => 'application/base',
|
27
30
|
}.each_pair {|k,v|
|
28
31
|
autoload k, File.expand_path(v, File.dirname(__FILE__))
|
data/lib/perfectsched/version.rb
CHANGED
data/perfectsched.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.add_dependency "cron-spec", [">= 0.1.2", "<= 0.1.2"]
|
20
20
|
gem.add_dependency "sequel", "~> 3.26.0"
|
21
21
|
gem.add_dependency "tzinfo", "~> 0.3.29"
|
22
|
-
gem.add_dependency "perfectqueue", "~> 0.8.
|
22
|
+
gem.add_dependency "perfectqueue", "~> 0.8.4"
|
23
23
|
gem.add_development_dependency "rake", "~> 0.9.2"
|
24
24
|
gem.add_development_dependency "rspec", "~> 2.10.0"
|
25
25
|
gem.add_development_dependency "simplecov", "~> 0.5.4"
|
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.8.
|
4
|
+
version: 0.8.3
|
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-07-
|
12
|
+
date: 2012-07-07 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cron-spec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70229464188900 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -24,10 +24,10 @@ dependencies:
|
|
24
24
|
version: 0.1.2
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
|
-
version_requirements: *
|
27
|
+
version_requirements: *70229464188900
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: sequel
|
30
|
-
requirement: &
|
30
|
+
requirement: &70229464170100 !ruby/object:Gem::Requirement
|
31
31
|
none: false
|
32
32
|
requirements:
|
33
33
|
- - ~>
|
@@ -35,10 +35,10 @@ dependencies:
|
|
35
35
|
version: 3.26.0
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
|
-
version_requirements: *
|
38
|
+
version_requirements: *70229464170100
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: tzinfo
|
41
|
-
requirement: &
|
41
|
+
requirement: &70229464167060 !ruby/object:Gem::Requirement
|
42
42
|
none: false
|
43
43
|
requirements:
|
44
44
|
- - ~>
|
@@ -46,21 +46,21 @@ dependencies:
|
|
46
46
|
version: 0.3.29
|
47
47
|
type: :runtime
|
48
48
|
prerelease: false
|
49
|
-
version_requirements: *
|
49
|
+
version_requirements: *70229464167060
|
50
50
|
- !ruby/object:Gem::Dependency
|
51
51
|
name: perfectqueue
|
52
|
-
requirement: &
|
52
|
+
requirement: &70229464151880 !ruby/object:Gem::Requirement
|
53
53
|
none: false
|
54
54
|
requirements:
|
55
55
|
- - ~>
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version: 0.8.
|
57
|
+
version: 0.8.4
|
58
58
|
type: :runtime
|
59
59
|
prerelease: false
|
60
|
-
version_requirements: *
|
60
|
+
version_requirements: *70229464151880
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: rake
|
63
|
-
requirement: &
|
63
|
+
requirement: &70229464147920 !ruby/object:Gem::Requirement
|
64
64
|
none: false
|
65
65
|
requirements:
|
66
66
|
- - ~>
|
@@ -68,10 +68,10 @@ dependencies:
|
|
68
68
|
version: 0.9.2
|
69
69
|
type: :development
|
70
70
|
prerelease: false
|
71
|
-
version_requirements: *
|
71
|
+
version_requirements: *70229464147920
|
72
72
|
- !ruby/object:Gem::Dependency
|
73
73
|
name: rspec
|
74
|
-
requirement: &
|
74
|
+
requirement: &70229464141720 !ruby/object:Gem::Requirement
|
75
75
|
none: false
|
76
76
|
requirements:
|
77
77
|
- - ~>
|
@@ -79,10 +79,10 @@ dependencies:
|
|
79
79
|
version: 2.10.0
|
80
80
|
type: :development
|
81
81
|
prerelease: false
|
82
|
-
version_requirements: *
|
82
|
+
version_requirements: *70229464141720
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: simplecov
|
85
|
-
requirement: &
|
85
|
+
requirement: &70229464137960 !ruby/object:Gem::Requirement
|
86
86
|
none: false
|
87
87
|
requirements:
|
88
88
|
- - ~>
|
@@ -90,10 +90,10 @@ dependencies:
|
|
90
90
|
version: 0.5.4
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
|
-
version_requirements: *
|
93
|
+
version_requirements: *70229464137960
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
95
|
name: sqlite3
|
96
|
-
requirement: &
|
96
|
+
requirement: &70229464128900 !ruby/object:Gem::Requirement
|
97
97
|
none: false
|
98
98
|
requirements:
|
99
99
|
- - ~>
|
@@ -101,7 +101,7 @@ dependencies:
|
|
101
101
|
version: 1.3.3
|
102
102
|
type: :development
|
103
103
|
prerelease: false
|
104
|
-
version_requirements: *
|
104
|
+
version_requirements: *70229464128900
|
105
105
|
description: Highly available distributed cron built on RDBMS
|
106
106
|
email: frsyuki@gmail.com
|
107
107
|
executables:
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- lib/perfectsched.rb
|
119
119
|
- lib/perfectsched/application.rb
|
120
120
|
- lib/perfectsched/application/base.rb
|
121
|
+
- lib/perfectsched/application/decider.rb
|
121
122
|
- lib/perfectsched/application/dispatch.rb
|
122
123
|
- lib/perfectsched/application/router.rb
|
123
124
|
- lib/perfectsched/backend.rb
|