tengine_core 0.5.39 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -37
- data/Gemfile.lock +59 -61
- data/README.md +8 -6
- data/bin/create_indexes_for_tengine_core +18 -0
- data/bin/tengined +3 -3
- data/examples/list.txt +36 -0
- data/examples/uc08_if_both_a_and_b_occurs.rb +7 -1
- data/examples/uc20_fire_with_properties.rb +19 -0
- data/examples/uc21_fire_with_same_key.rb +23 -0
- data/examples/uc22_fire_with_source_name.rb +17 -0
- data/examples/uc23_fire_with_level.rb +19 -0
- data/examples/uc24_fire_with_level_key.rb +19 -0
- data/examples/uc30_local_variables.rb +28 -0
- data/examples/uc31_instance_variables.rb +35 -0
- data/examples/uc32_class_variables.rb +20 -0
- data/examples/uc33_statics.rb +20 -0
- data/examples2/uc30_local_variables.rb +55 -0
- data/examples2/uc31_instance_variables.rb +46 -0
- data/examples2/uc32_class_variables.rb +22 -0
- data/examples2/uc33_statics.rb +23 -0
- data/lib/tengine/core/bootstrap.rb +1 -1
- data/lib/tengine/core/config/atd.rb +0 -3
- data/lib/tengine/core/config/core.rb +21 -20
- data/lib/tengine/core/config/heartbeat_watcher.rb +0 -3
- data/lib/tengine/core/driveable.rb +34 -12
- data/lib/tengine/core/driver.rb +22 -9
- data/lib/tengine/core/dsl_evaluator.rb +2 -15
- data/lib/tengine/core/dsl_filter_def.rb +40 -0
- data/lib/tengine/core/dsl_loader.rb +1 -1
- data/lib/tengine/core/event.rb +44 -29
- data/lib/tengine/core/event/finder.rb +1 -1
- data/lib/tengine/core/event_exception_reportable.rb +7 -10
- data/lib/tengine/core/event_wrapper.rb +1 -1
- data/lib/tengine/core/find_by_name.rb +1 -1
- data/lib/tengine/core/handler.rb +14 -4
- data/lib/tengine/core/handler_path.rb +1 -1
- data/lib/tengine/core/heartbeat_watcher.rb +3 -2
- data/lib/tengine/core/kernel.rb +22 -6
- data/lib/tengine/core/mongoid_fix.rb +2 -1
- data/lib/tengine/core/mutex.rb +22 -8
- data/lib/tengine/core/optimistic_lock.rb +6 -6
- data/lib/tengine/core/safe_updatable.rb +24 -26
- data/lib/tengine/core/schedule.rb +2 -2
- data/lib/tengine/core/scheduler.rb +5 -4
- data/lib/tengine/core/session.rb +14 -0
- data/lib/tengine/core/session_wrapper.rb +20 -4
- data/lib/tengine/core/setting.rb +3 -3
- data/lib/tengine/rspec/extension.rb +6 -8
- metadata +156 -171
- data/.document +0 -5
- data/.rspec +0 -1
- data/Rakefile +0 -44
- data/VERSION +0 -1
- data/lib/tengine/core/connection_test/.gitignore +0 -1
- data/spec/factories/tengine_core_drivers.rb +0 -10
- data/spec/factories/tengine_core_events.rb +0 -14
- data/spec/factories/tengine_core_handler_paths.rb +0 -9
- data/spec/factories/tengine_core_handlers.rb +0 -9
- data/spec/factories/tengine_core_sessions.rb +0 -9
- data/spec/mongoid.yml +0 -35
- data/spec/spec_helper.rb +0 -48
- data/spec/support/mongo_index_key_log.rb +0 -91
- data/spec/tengine/core/bootstrap_spec.rb +0 -278
- data/spec/tengine/core/bugfix/bind_dsl_file_in_multi_byte_dir_spec.rb +0 -21
- data/spec/tengine/core/bugfix/enabled_on_activation_spec.rb +0 -112
- data/spec/tengine/core/bugfix/receive_event_spec.rb +0 -133
- data/spec/tengine/core/bugfix/use_dsl_version_method.rb +0 -12
- data/spec/tengine/core/bugfix/use_dsl_version_method_spec.rb +0 -28
- data/spec/tengine/core/bugfix/use_event_in_handler_dsl.rb +0 -11
- data/spec/tengine/core/bugfix//351/235/236ACSII/343/201/256/343/203/206/343/202/231/343/202/243/343/203/254/343/202/257/343/203/210/343/203/252/345/220/215/source_location_encoding.rb +0 -35
- data/spec/tengine/core/bugfix//351/235/236ACSII/343/201/256/343/203/206/343/202/231/343/202/243/343/203/254/343/202/257/343/203/210/343/203/252/345/220/215//351/235/236ASCII/343/201/256/343/203/225/343/202/241/343/202/244/343/203/253/345/220/215_dsl.rb +0 -38
- data/spec/tengine/core/bugfix//351/235/236ACSII/343/201/256/343/203/207/343/202/243/343/203/254/343/202/257/343/203/210/343/203/252/345/220/215/source_location_encoding.rb +0 -35
- data/spec/tengine/core/bugfix//351/235/236ACSII/343/201/256/343/203/207/343/202/243/343/203/254/343/202/257/343/203/210/343/203/252/345/220/215//351/235/236ASCII/343/201/256/343/203/225/343/202/241/343/202/244/343/203/253/345/220/215_dsl.rb +0 -38
- data/spec/tengine/core/config/atd_spec.rb +0 -62
- data/spec/tengine/core/config/core_spec.rb +0 -479
- data/spec/tengine/core/config/heartbeat_watcher_spec.rb +0 -62
- data/spec/tengine/core/config/syntax_error_in_erb.yml.erb +0 -13
- data/spec/tengine/core/config/wrong_category_name.yml.erb +0 -13
- data/spec/tengine/core/config/wrong_field_name.yml.erb +0 -12
- data/spec/tengine/core/config/wrong_yaml.yml.erb +0 -13
- data/spec/tengine/core/config_spec/another_port.yml +0 -54
- data/spec/tengine/core/config_spec/config_with_dir_absolute_load_path.yml +0 -16
- data/spec/tengine/core/config_spec/config_with_dir_relative_load_path.yml +0 -16
- data/spec/tengine/core/config_spec/config_with_file_absolute_load_path.yml +0 -16
- data/spec/tengine/core/config_spec/config_with_file_relative_load_path.yml +0 -16
- data/spec/tengine/core/config_spec/log_config_spec.rb +0 -245
- data/spec/tengine/core/driveable_spec.rb +0 -240
- data/spec/tengine/core/driver_spec.rb +0 -159
- data/spec/tengine/core/dsl_loader_spec.rb +0 -172
- data/spec/tengine/core/dsls/uc08_if_both_a_and_b_occurs_spec.rb +0 -35
- data/spec/tengine/core/dsls/uc10_if_the_event_occurs_at_the_server_spec.rb +0 -58
- data/spec/tengine/core/dsls/uc50_commit_event_at_first_spec.rb +0 -29
- data/spec/tengine/core/dsls/uc52_commit_event_after_all_handler_submit_spec.rb +0 -33
- data/spec/tengine/core/dsls/uc52_never_commit_event_unless_all_handler_submit_spec.rb +0 -38
- data/spec/tengine/core/dsls/uc53_submit_outside_of_handler_spec.rb +0 -37
- data/spec/tengine/core/dsls/uc60_event_in_handler_spec.rb +0 -31
- data/spec/tengine/core/dsls/uc61_event_outside_of_handler_spec.rb +0 -37
- data/spec/tengine/core/dsls/uc62_session_in_driver_spec.rb +0 -36
- data/spec/tengine/core/dsls/uc63_session_outside_of_driver_spec.rb +0 -35
- data/spec/tengine/core/dsls/uc64_safety_countup_spec.rb +0 -134
- data/spec/tengine/core/dsls/uc70_driver_enabled_on_activation_spec.rb +0 -39
- data/spec/tengine/core/dsls/uc71_driver_disabled_on_activation_spec.rb +0 -36
- data/spec/tengine/core/dsls/uc72_setup_eventmachine_spec.rb +0 -39
- data/spec/tengine/core/dsls/uc80_raise_io_error_spec.rb +0 -53
- data/spec/tengine/core/dsls/uc81_raise_runtime_error_spec.rb +0 -49
- data/spec/tengine/core/event/finder_spec.rb +0 -136
- data/spec/tengine/core/event_exception_reportable_spec.rb +0 -33
- data/spec/tengine/core/event_spec.rb +0 -161
- data/spec/tengine/core/event_wrapper_spec.rb +0 -35
- data/spec/tengine/core/handler_path_spec.rb +0 -87
- data/spec/tengine/core/handler_spec.rb +0 -190
- data/spec/tengine/core/heartbeat_watcher_spec.rb +0 -131
- data/spec/tengine/core/io_to_logger_spec.rb +0 -30
- data/spec/tengine/core/kernel_spec.rb +0 -902
- data/spec/tengine/core/mongodb_spec.rb +0 -12
- data/spec/tengine/core/mongoid_fix_spec.rb +0 -52
- data/spec/tengine/core/mutex_spec.rb +0 -201
- data/spec/tengine/core/optimistic_lock_spec.rb +0 -55
- data/spec/tengine/core/scheculer_spec.rb +0 -121
- data/spec/tengine/core/selectable_attr_spec.rb +0 -30
- data/spec/tengine/core/session_spec.rb +0 -104
- data/spec/tengine/core/setting_spec.rb +0 -79
- data/spec/tengine/core_spec.rb +0 -13
- data/spec/tengine_spec.rb +0 -14
- data/tengine_core.gemspec +0 -251
- data/tmp/log/.gitignore +0 -1
- data/tmp/tengined_status/.gitignore +0 -1
data/Gemfile
CHANGED
@@ -1,40 +1,4 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
source "http://rubygems.org"
|
3
3
|
|
4
|
-
|
5
|
-
# Example:
|
6
|
-
# gem "activesupport", ">= 2.3.5"
|
7
|
-
|
8
|
-
gem "activesupport", "~> 3.1.0"
|
9
|
-
gem "activemodel" , "~> 3.1.0"
|
10
|
-
|
11
|
-
gem "selectable_attr", "~> 0.3.15"
|
12
|
-
|
13
|
-
gem "bson" , "~> 1.5.2"
|
14
|
-
gem "bson_ext", "~> 1.5.2"
|
15
|
-
gem "mongo" , "~> 1.5.2"
|
16
|
-
|
17
|
-
gem "mongoid", "~> 2.3.3"
|
18
|
-
|
19
|
-
gem "tengine_support", "~> 0.3.27"
|
20
|
-
gem "tengine_event", "~> 0.4.9"
|
21
|
-
|
22
|
-
gem "daemons", "~> 1.1.4"
|
23
|
-
|
24
|
-
# Add dependencies to develop your gem here.
|
25
|
-
# Include everything needed to run rake, tests, features, etc.
|
26
|
-
group :development do
|
27
|
-
gem "rspec", "~> 2.6.0"
|
28
|
-
gem "factory_girl", "~> 2.1.2"
|
29
|
-
gem "yard", "~> 0.7.2"
|
30
|
-
gem "bundler", "~> 1.1.3"
|
31
|
-
gem "jeweler", "~> 1.6.4"
|
32
|
-
# gem "rcov", ">= 0"
|
33
|
-
gem "simplecov", "~> 0.5.3"
|
34
|
-
gem "ZenTest", "~> 4.6.2"
|
35
|
-
|
36
|
-
# for markdown
|
37
|
-
gem 'rdiscount'
|
38
|
-
gem 'kramdown'
|
39
|
-
|
40
|
-
end
|
4
|
+
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,24 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
tengine_core (1.1.0)
|
5
|
+
activemodel (>= 3.1.0)
|
6
|
+
activesupport (>= 3.1.0)
|
7
|
+
daemons (~> 1.1.4)
|
8
|
+
mongoid (~> 3.0.0)
|
9
|
+
selectable_attr (~> 0.3.15)
|
10
|
+
tengine_event (~> 1.1.0)
|
11
|
+
tengine_support (~> 1.1.0)
|
12
|
+
|
1
13
|
GEM
|
2
14
|
remote: http://rubygems.org/
|
3
15
|
specs:
|
4
|
-
ZenTest (4.
|
5
|
-
activemodel (3.
|
6
|
-
activesupport (= 3.
|
16
|
+
ZenTest (4.8.2)
|
17
|
+
activemodel (3.2.8)
|
18
|
+
activesupport (= 3.2.8)
|
7
19
|
builder (~> 3.0.0)
|
20
|
+
activesupport (3.2.8)
|
8
21
|
i18n (~> 0.6)
|
9
|
-
activesupport (3.1.4)
|
10
22
|
multi_json (~> 1.0)
|
11
23
|
amq-client (0.8.7)
|
12
24
|
amq-protocol (>= 0.8.4)
|
@@ -16,80 +28,66 @@ GEM
|
|
16
28
|
amq-client (~> 0.8.7)
|
17
29
|
amq-protocol (~> 0.8.4)
|
18
30
|
eventmachine
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
daemons (1.1.8)
|
31
|
+
autotest (4.4.6)
|
32
|
+
ZenTest (>= 4.4.1)
|
33
|
+
builder (3.0.4)
|
34
|
+
daemons (1.1.9)
|
24
35
|
diff-lcs (1.1.3)
|
25
|
-
eventmachine (0.
|
26
|
-
factory_girl (
|
27
|
-
activesupport
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
systemu (>= 2.4.0)
|
37
|
-
mongo (1.5.2)
|
38
|
-
bson (= 1.5.2)
|
39
|
-
mongoid (2.3.5)
|
40
|
-
activemodel (~> 3.1.0)
|
41
|
-
mongo (~> 1.3)
|
36
|
+
eventmachine (1.0.0)
|
37
|
+
factory_girl (3.3.0)
|
38
|
+
activesupport (>= 3.0.0)
|
39
|
+
i18n (0.6.1)
|
40
|
+
kramdown (0.14.0)
|
41
|
+
macaddr (1.6.1)
|
42
|
+
systemu (~> 2.5.0)
|
43
|
+
mongoid (3.0.15)
|
44
|
+
activemodel (~> 3.1)
|
45
|
+
moped (~> 1.1)
|
46
|
+
origin (~> 1.0)
|
42
47
|
tzinfo (~> 0.3.22)
|
43
|
-
|
48
|
+
moped (1.3.1)
|
49
|
+
multi_json (1.3.6)
|
50
|
+
origin (1.0.11)
|
44
51
|
rake (0.9.2.2)
|
45
52
|
rdiscount (1.6.8)
|
46
|
-
rspec (2.
|
47
|
-
rspec-core (~> 2.
|
48
|
-
rspec-expectations (~> 2.
|
49
|
-
rspec-mocks (~> 2.
|
50
|
-
rspec-core (2.
|
51
|
-
rspec-expectations (2.
|
52
|
-
diff-lcs (~> 1.1.
|
53
|
-
rspec-mocks (2.
|
54
|
-
selectable_attr (0.3.
|
53
|
+
rspec (2.10.0)
|
54
|
+
rspec-core (~> 2.10.0)
|
55
|
+
rspec-expectations (~> 2.10.0)
|
56
|
+
rspec-mocks (~> 2.10.0)
|
57
|
+
rspec-core (2.10.1)
|
58
|
+
rspec-expectations (2.10.0)
|
59
|
+
diff-lcs (~> 1.1.3)
|
60
|
+
rspec-mocks (2.10.1)
|
61
|
+
selectable_attr (0.3.17)
|
55
62
|
i18n
|
56
|
-
simplecov (0.
|
57
|
-
multi_json (~> 1.0
|
63
|
+
simplecov (0.6.4)
|
64
|
+
multi_json (~> 1.0)
|
58
65
|
simplecov-html (~> 0.5.3)
|
59
66
|
simplecov-html (0.5.3)
|
60
|
-
systemu (2.5.
|
61
|
-
tengine_event (
|
67
|
+
systemu (2.5.2)
|
68
|
+
tengine_event (1.1.0)
|
62
69
|
activesupport (>= 3.0.0)
|
63
70
|
amqp (~> 0.8.0)
|
64
|
-
tengine_support (
|
71
|
+
tengine_support (~> 1.1.0)
|
65
72
|
uuid (~> 2.3.4)
|
66
|
-
tengine_support (
|
73
|
+
tengine_support (1.1.0)
|
67
74
|
activesupport (>= 3.0.0)
|
68
|
-
tzinfo (0.3.
|
75
|
+
tzinfo (0.3.35)
|
69
76
|
uuid (2.3.5)
|
70
77
|
macaddr (~> 1.0)
|
71
|
-
yard (0.
|
78
|
+
yard (0.8.2.1)
|
72
79
|
|
73
80
|
PLATFORMS
|
74
81
|
ruby
|
75
82
|
|
76
83
|
DEPENDENCIES
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
bson (~> 1.5.2)
|
81
|
-
bson_ext (~> 1.5.2)
|
82
|
-
bundler (~> 1.1.3)
|
83
|
-
daemons (~> 1.1.4)
|
84
|
-
factory_girl (~> 2.1.2)
|
85
|
-
jeweler (~> 1.6.4)
|
84
|
+
autotest
|
85
|
+
bundler
|
86
|
+
factory_girl (~> 3.3.0)
|
86
87
|
kramdown
|
87
|
-
|
88
|
-
mongoid (~> 2.3.3)
|
88
|
+
rake (~> 0.9.2.2)
|
89
89
|
rdiscount
|
90
|
-
rspec (~> 2.
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
tengine_support (~> 0.3.27)
|
95
|
-
yard (~> 0.7.2)
|
90
|
+
rspec (~> 2.10.0)
|
91
|
+
simplecov (~> 0.6.4)
|
92
|
+
tengine_core!
|
93
|
+
yard (~> 0.8.1)
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# tengine_core
|
2
2
|
|
3
|
-
|
3
|
+
Tengine frameworkとは、分散環境のリソース・マネジメントとジョブ制御を統括的に扱う運用エンジンです。
|
4
|
+
Tengine frameworkを利用することで"動的に変化するデータセンター(Programmable DataCenter)"を実現することができます。
|
5
|
+
|
4
6
|
|
5
7
|
## 概要
|
6
8
|
|
@@ -15,10 +17,10 @@ tengineはデータセンター運用のためのフレームワークおよび
|
|
15
17
|
## インストールとセットアップ
|
16
18
|
### インストール
|
17
19
|
|
18
|
-
*
|
20
|
+
* RabbitMQのインストール
|
19
21
|
* MongoDBのインストール
|
20
22
|
|
21
|
-
gem install tengine_core
|
23
|
+
gem install tengine_core
|
22
24
|
|
23
25
|
### セットアップ
|
24
26
|
|
@@ -32,11 +34,11 @@ tengineはデータセンター運用のためのフレームワークおよび
|
|
32
34
|
|
33
35
|
DSLを使用するためのAPIについては以下のモジュールのAPIを参照してください。
|
34
36
|
[Tengine::Core::DslLoader](Tengine/Core/DslLoader.html)
|
35
|
-
[Tengine::Core::
|
37
|
+
[Tengine::Core::DslEvaluator](Tengine/Core/DslEvaluator.html)
|
36
38
|
|
37
39
|
|
38
40
|
## Contributing to tengine_core
|
39
|
-
|
41
|
+
|
40
42
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
41
43
|
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
42
44
|
* Fork the project
|
@@ -51,4 +53,4 @@ tengine_event is distributed under the MPL2.0 or LGPLv3 or the dual license of M
|
|
51
53
|
|
52
54
|
## Copyright
|
53
55
|
|
54
|
-
Copyright (c) 2012 Groovenauts, Inc.
|
56
|
+
Copyright (c) 2012 Groovenauts, Inc.
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
# Use to create indexes. Sample is below.
|
5
|
+
# create_indexes_for_tengine_core localhost:27017/tengine_production
|
6
|
+
#
|
7
|
+
# Default options
|
8
|
+
# hostname localhost
|
9
|
+
# port 27017
|
10
|
+
# database tengine_production
|
11
|
+
#
|
12
|
+
require 'tengine_support'
|
13
|
+
require 'tengine_core'
|
14
|
+
|
15
|
+
include Tengine::Support::Mongoid
|
16
|
+
|
17
|
+
target = File.expand_path('../lib', File.dirname(__FILE__))
|
18
|
+
Tengine::Support::Mongoid.create_indexes(target, ARGV.shift)
|
data/bin/tengined
CHANGED
@@ -171,9 +171,9 @@ run do
|
|
171
171
|
require 'mongoid'
|
172
172
|
require File.expand_path('./lib/tengine_core', tengined_root)
|
173
173
|
require 'tengine/core/mongoid_fix'
|
174
|
-
Mongoid.
|
175
|
-
|
176
|
-
|
174
|
+
Mongoid.configure do |c|
|
175
|
+
c.send :load_configuration, config[:db]
|
176
|
+
end
|
177
177
|
require 'amqp'
|
178
178
|
Mongoid.logger = AMQP::Session.logger = Tengine.logger
|
179
179
|
Tengine::Core::MethodTraceable.disabled = !@__config__[:verbose] # Tengine::Core::Bootstrapが動く前に設定しないと余計なログが出ます
|
data/examples/list.txt
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
01 最もシンプルなイベントハンドラ
|
2
|
+
02 イベントが発生したら新たなイベントを発火する
|
3
|
+
03 一つのイベントに対して処理Aと処理Bを実行する
|
4
|
+
|
5
|
+
08 イベントAとイベントBが発生したら処理を実行する
|
6
|
+
|
7
|
+
10 特定のサーバからのイベントが発生した場合のみ処理を実行する
|
8
|
+
|
9
|
+
20 :properties指定で発火する
|
10
|
+
21 :key指定で発火する
|
11
|
+
22 :source_name指定で発火する
|
12
|
+
23 :level指定で発火する
|
13
|
+
24 :level_key指定で発火する
|
14
|
+
|
15
|
+
30: ローカル変数を参照する
|
16
|
+
31: インスタンス変数を参照する
|
17
|
+
32: クラス変数を参照する
|
18
|
+
33: 定数を参照する
|
19
|
+
|
20
|
+
50 ack_policy(:at_first, ...) の例
|
21
|
+
51 ack_policy(:at_first_submit, ...) の例
|
22
|
+
52 ack_policy(:after_all_handler_submit, ...) でACKを返す例
|
23
|
+
53 ack_policy(:after_all_handler_submit, ...) でACKを返さない例
|
24
|
+
|
25
|
+
60 eventメソッドを使って受け取ったイベントを取得する
|
26
|
+
61 eventメソッドをハンドラ外で使用して例外が発生する例
|
27
|
+
62 ドライバ内では sessionメソッドで取得できるセッションに対してupdateメソッドを使ってドライバのセッションに情報を格納できる
|
28
|
+
63 sessionメソッドをドライバ外で使用して例外が発生する例
|
29
|
+
64 driver62と違って、複数のプロセスが同時に数を数えても正しく+1していきます
|
30
|
+
|
31
|
+
70 アクティベーション時にイベントドライバを有効な状態にする例
|
32
|
+
71 アクティベーション時にイベントドライバを無効な状態にする例
|
33
|
+
72 アクティベーション時にEventMachineの初期化を行う例
|
34
|
+
|
35
|
+
80 イベントハンドリング中にIOErrorが発生するハンドラ
|
36
|
+
81 イベントハンドリング中にRuntimeErrorが発生するハンドラ
|
@@ -4,8 +4,14 @@ require 'tengine/core'
|
|
4
4
|
driver :driver08 do
|
5
5
|
|
6
6
|
# イベントAとイベントBが発生したら処理を実行する
|
7
|
-
on :event08_a & :
|
7
|
+
on :event08_a & :event08_b do
|
8
8
|
puts "handler08"
|
9
9
|
end
|
10
10
|
|
11
|
+
# イベントAとイベントBが発生したら処理を実行する
|
12
|
+
on :event08_c do
|
13
|
+
puts "clear session"
|
14
|
+
session.clear!
|
15
|
+
end
|
16
|
+
|
11
17
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'tengine/core'
|
4
|
+
|
5
|
+
driver :driver20 do
|
6
|
+
|
7
|
+
# イベントが発生したら:propertiesを指定してイベントを発火する
|
8
|
+
on:event20_1 do
|
9
|
+
puts "handler20_1"
|
10
|
+
fire(:event20_2, :properties => {:foo => 'bar', :baz => 1})
|
11
|
+
end
|
12
|
+
|
13
|
+
on:event20_2 do
|
14
|
+
puts event[:foo].inspect
|
15
|
+
puts event[:baz].inspect
|
16
|
+
puts event.properties.inspect
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'tengine/core'
|
4
|
+
|
5
|
+
driver :driver21 do
|
6
|
+
|
7
|
+
# イベントが発生したら:propertiesを指定してイベントを発火する
|
8
|
+
on:event21_1 do
|
9
|
+
puts "handler21_1"
|
10
|
+
fire(:event21_2, :key => "event21_2-key" + Time.now.strftime("%Y/%m/%d %H:%M"))
|
11
|
+
end
|
12
|
+
|
13
|
+
# 日時分まで同じ時刻ならば、一度目の fireでは正しくイベントが処理されて、
|
14
|
+
# 標準出力に handler21_2 と出力されますが、
|
15
|
+
# 2度目以降は、キーが重複しているため処理されず以下のようなエラーメッセージが出力されます。
|
16
|
+
#
|
17
|
+
# 2012-05-15T22:57:07+09:00 WARN failed to store an event.
|
18
|
+
# [Mongo::OperationFailure] 11000: E11000 duplicate key error index: tengine_production.tengine_core_events.$key_1 dup key: { : "event21_2-key2012/05/15 22:57" }
|
19
|
+
on:event21_2 do
|
20
|
+
puts "handler21_2"
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'tengine/core'
|
4
|
+
|
5
|
+
driver :driver22 do
|
6
|
+
|
7
|
+
# イベントが発生したら:source_nameを指定してイベントを発火する
|
8
|
+
on:event22_1 do
|
9
|
+
puts "handler22_1"
|
10
|
+
fire(:event22_2, :source_name => "test_source01")
|
11
|
+
end
|
12
|
+
|
13
|
+
on:event22_2 do
|
14
|
+
puts event.source_name # test_source01
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'tengine/core'
|
4
|
+
|
5
|
+
driver :driver23 do
|
6
|
+
|
7
|
+
# イベントが発生したら:propertiesを指定してイベントを発火する
|
8
|
+
on:event23 do
|
9
|
+
puts "handler23"
|
10
|
+
fire(:event23_1, :level => 1)
|
11
|
+
end
|
12
|
+
|
13
|
+
on(:event23_1){ puts "handler23_1"; fire(:event23_2, :level => 2) }
|
14
|
+
on(:event23_2){ puts "handler23_2"; fire(:event23_3, :level => 3) }
|
15
|
+
on(:event23_3){ puts "handler23_3"; fire(:event23_4, :level => 4) }
|
16
|
+
on(:event23_4){ puts "handler23_4"; fire(:event23_5, :level => 5) }
|
17
|
+
on(:event23_5){ puts "handler23_5"; fire(:event23_6, :level => 6) } # [ArgumentError] Invalid level 6. It must be one of [0, 1, 2, 3, 4, 5]
|
18
|
+
on(:event23_6){ puts "handler23_6" }
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'tengine/core'
|
4
|
+
|
5
|
+
driver :driver24 do
|
6
|
+
|
7
|
+
# イベントが発生したら:propertiesを指定してイベントを発火する
|
8
|
+
on:event24 do
|
9
|
+
puts "handler24"
|
10
|
+
fire(:event24_0, :level_key => :debug)
|
11
|
+
end
|
12
|
+
|
13
|
+
on(:event24_0){ puts "handler24_0"; fire(:event24_1, :level_key => :info) }
|
14
|
+
on(:event24_1){ puts "handler24_1"; fire(:event24_2, :level_key => :warn) }
|
15
|
+
on(:event24_2){ puts "handler24_2"; fire(:event24_3, :level_key => :error) }
|
16
|
+
on(:event24_3){ puts "handler24_3"; fire(:event24_4, :level_key => :fatal) }
|
17
|
+
on(:event24_4){ puts "handler24_4"; fire(:event24_5, :level_key => :urgent) } # [ArgumentError] Invalid level_key :urgent. It must be one of [:gr_heartbeat, :debug, :info, :warn, :error, :fatal]
|
18
|
+
on(:event24_5){ puts "handler24_5" }
|
19
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'tengine/core'
|
3
|
+
|
4
|
+
# driverメソッドによるドライバ定義でローカル変数を使用する例。
|
5
|
+
#
|
6
|
+
# Rubyの通常のブロックと同じように、ブロックの外で定義されたローカル変数は
|
7
|
+
# ブロック内からアクセス可能です。
|
8
|
+
|
9
|
+
# lvar1の定義
|
10
|
+
lvar1 = "outside of driver"
|
11
|
+
|
12
|
+
driver :driver30 do
|
13
|
+
|
14
|
+
# lvar2の定義
|
15
|
+
lvar2 = "outside of handler"
|
16
|
+
puts "#{__FILE__}##{__LINE__}"
|
17
|
+
# lvar1へのアクセス
|
18
|
+
puts lvar1 # => outside of driver
|
19
|
+
|
20
|
+
on:event30 do
|
21
|
+
puts "#{__FILE__}##{__LINE__}"
|
22
|
+
# lvar1へのアクセス
|
23
|
+
puts lvar1 # => outside of driver
|
24
|
+
# lvar2へのアクセス
|
25
|
+
puts lvar2 # => outside of handler
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|