bsl-thor 0.0.2
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/Gemfile +43 -0
- data/LICENSE.txt +20 -0
- data/Manifest +34 -0
- data/README +0 -0
- data/README.rdoc +18 -0
- data/Rakefile +12 -0
- data/app/amqp2sql.rb +107 -0
- data/bsl-thor.gemspec +29 -0
- data/lib/BslThor.rb +13 -0
- data/lib/ThorApplication.rb +139 -0
- data/lib/ThorClient.rb +319 -0
- data/lib/ThorCmd.rb +85 -0
- data/lib/ThorJob.rb +146 -0
- data/lib/ThorMaster.rb +226 -0
- data/lib/ThorNode.rb +203 -0
- data/lib/ThorUtils.rb +40 -0
- data/lib/ThorWorker.rb +58 -0
- data/lib/boot/Boot.rb +72 -0
- data/lib/boot/Client.rb +25 -0
- data/lib/boot/Master.rb +26 -0
- data/lib/boot/Node.rb +16 -0
- data/lib/config/ThorClient.yml.template +12 -0
- data/lib/config/ThorCmd.yml.template +4 -0
- data/lib/config/ThorMaster.yml.template +19 -0
- data/lib/config/ThorNode.yml.template +7 -0
- data/lib/config/ThorWorker.yml.template +4 -0
- data/lib/jobs/Client-0.0.1/main.rb +32 -0
- data/lib/jobs/Master-0.0.1/main.rb +32 -0
- data/lib/jobs/MonitorClient-0.0.1/main.rb +74 -0
- data/lib/jobs/MonitorMaster-0.0.1/main.rb +90 -0
- data/lib/jobs/Node-0.0.1/main.rb +56 -0
- data/lib/models/ThorModelClient.rb +9 -0
- data/lib/models/ThorModelJob.rb +9 -0
- data/lib/models/ThorModelWorker.rb +9 -0
- metadata +132 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../ThorJob.rb')
|
2
|
+
|
3
|
+
module Thor
|
4
|
+
module Jobs
|
5
|
+
class Client < Thor::Job
|
6
|
+
@@AUTHOR = "korczis@gmail.com"
|
7
|
+
@@DESCRIPTION = "Client node"
|
8
|
+
@@LICENSE = "GPL"
|
9
|
+
@@VERSION = "0.0.1"
|
10
|
+
@@SUPPORTED_MSGS = []
|
11
|
+
|
12
|
+
# C-tor
|
13
|
+
def initialize(opts = {})
|
14
|
+
super(opts)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Async runner
|
18
|
+
def run(opts = {})
|
19
|
+
super(opts)
|
20
|
+
|
21
|
+
if(options[:verbose])
|
22
|
+
Bsl::Logger::Log "Thor::Jobs::Client::run()"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Console application main()
|
27
|
+
def main
|
28
|
+
super()
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../ThorJob.rb')
|
2
|
+
|
3
|
+
module Thor
|
4
|
+
module Jobs
|
5
|
+
class Master < Thor::Job
|
6
|
+
@@AUTHOR = "korczis@gmail.com"
|
7
|
+
@@DESCRIPTION = "Master node"
|
8
|
+
@@LICENSE = "GPL"
|
9
|
+
@@VERSION = "0.0.1"
|
10
|
+
@@SUPPORTED_MSGS = []
|
11
|
+
|
12
|
+
# C-tor
|
13
|
+
def initialize(opts = {})
|
14
|
+
super(opts)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Async runner
|
18
|
+
def run(opts = {})
|
19
|
+
super(opts)
|
20
|
+
|
21
|
+
if(options[:verbose])
|
22
|
+
Bsl::Logger::Log "Thor::Jobs::Master::run()"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Console application main()
|
27
|
+
def main
|
28
|
+
super()
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../ThorJob.rb')
|
2
|
+
|
3
|
+
module Thor
|
4
|
+
module Jobs
|
5
|
+
class MonitorClient < Thor::Job
|
6
|
+
@@AUTHOR = "korczis@gmail.com"
|
7
|
+
@@DESCRIPTION = "Monitoring node"
|
8
|
+
@@LICENSE = "GPL"
|
9
|
+
@@VERSION = "0.0.1"
|
10
|
+
@@SUPPORTED_MSGS = []
|
11
|
+
|
12
|
+
# C-tor
|
13
|
+
def initialize(opts = {})
|
14
|
+
super(opts)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Async runner
|
18
|
+
def run(opts = {})
|
19
|
+
super(opts)
|
20
|
+
|
21
|
+
|
22
|
+
if(options[:verbose])
|
23
|
+
Bsl::Logger::Log "Thor::Jobs::MonitorClient::run()"
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
# Construct channel response name
|
28
|
+
channel_response_name = (self.class.name + ".response").downcase
|
29
|
+
if(options[:channel_response] != nil)
|
30
|
+
channel_response_name = options[:channel_response]
|
31
|
+
end
|
32
|
+
|
33
|
+
# Create response channel
|
34
|
+
if(options[:verbose])
|
35
|
+
Bsl::Logger::Log "Creating response channel - '#{channel_response_name}'"
|
36
|
+
end
|
37
|
+
|
38
|
+
channel_response = AMQP::Channel.new(amqp_conn)
|
39
|
+
exchange_response = channel_response.fanout(channel_response_name)
|
40
|
+
|
41
|
+
# Construct channel_request name
|
42
|
+
channel_request_name = (self.class.name + ".request").downcase
|
43
|
+
if(options[:channel_request] != nil)
|
44
|
+
channel_request_name = options[:channel_request]
|
45
|
+
end
|
46
|
+
queue_request_name = channel_request_name + "." + Thor::generate_guid
|
47
|
+
|
48
|
+
# Create channel request
|
49
|
+
if(options[:verbose])
|
50
|
+
Bsl::Logger::Log "Creating request channel - '#{channel_request_name}'"
|
51
|
+
end
|
52
|
+
channel_request = AMQP::Channel.new(amqp_conn)
|
53
|
+
exchange_request = channel_request.fanout(channel_request_name)
|
54
|
+
|
55
|
+
# Create and bind request queue
|
56
|
+
if(options[:verbose])
|
57
|
+
Bsl::Logger::Log "Creating request queue - '#{queue_request_name}'"
|
58
|
+
end
|
59
|
+
channel_request.queue(queue_request_name, :auto_delete => true).bind(exchange_request).subscribe do |payload|
|
60
|
+
if(options[:verbose])
|
61
|
+
Bsl::Logger::Log "Received payload: '#{payload}'"
|
62
|
+
end
|
63
|
+
process_msg(channel_request, exchange_request, payload)
|
64
|
+
exchange_response.publish("Hi!")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# Console application main()
|
69
|
+
def main
|
70
|
+
super()
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../ThorJob.rb')
|
2
|
+
|
3
|
+
module Thor
|
4
|
+
module Jobs
|
5
|
+
class MonitorMaster < Thor::Job
|
6
|
+
@@AUTHOR = "korczis@gmail.com"
|
7
|
+
@@DESCRIPTION = "Monitoring node"
|
8
|
+
@@LICENSE = "GPL"
|
9
|
+
@@VERSION = "0.0.1"
|
10
|
+
@@SUPPORTED_MSGS = []
|
11
|
+
|
12
|
+
# C-tor
|
13
|
+
def initialize(opts = {})
|
14
|
+
super(opts)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Async runner
|
18
|
+
def run(opts = {})
|
19
|
+
super(opts)
|
20
|
+
|
21
|
+
if(options[:verbose])
|
22
|
+
Bsl::Logger::Log "Thor::Jobs::MonitorMaster::run()"
|
23
|
+
end
|
24
|
+
|
25
|
+
# Construct channel_response name
|
26
|
+
channel_response_name = (self.class.name + ".response").downcase
|
27
|
+
if(options[:channel_response] != nil)
|
28
|
+
channel_response_name = options[:channel_response]
|
29
|
+
end
|
30
|
+
queue_response_name = channel_response_name + "." + Thor::generate_guid
|
31
|
+
|
32
|
+
# Create channel response
|
33
|
+
if(options[:verbose])
|
34
|
+
Bsl::Logger::Log "Creating response channel - '#{channel_response_name}'"
|
35
|
+
end
|
36
|
+
channel_response = AMQP::Channel.new(amqp_conn)
|
37
|
+
exchange_response = channel_response.fanout(channel_response_name)
|
38
|
+
|
39
|
+
|
40
|
+
# Create and bind response queue
|
41
|
+
if(options[:verbose])
|
42
|
+
Bsl::Logger::Log "Creating response queue - '#{queue_response_name}'"
|
43
|
+
end
|
44
|
+
channel_response.queue(queue_response_name, :auto_delete => true).bind(exchange_response).subscribe do |payload|
|
45
|
+
if(options[:verbose])
|
46
|
+
Bsl::Logger::Log "Received payload: '#{payload}'"
|
47
|
+
end
|
48
|
+
process_msg(channel_response, exchange_response, payload)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Construct channel request name
|
52
|
+
channel_request_name = (self.class.name + ".request").downcase
|
53
|
+
if(options[:channel_request] != nil)
|
54
|
+
channel_request_name = options[:channel_request]
|
55
|
+
end
|
56
|
+
|
57
|
+
# Create request channel
|
58
|
+
if(options[:verbose])
|
59
|
+
Bsl::Logger::Log "Creating request channel - '#{channel_request_name}'"
|
60
|
+
end
|
61
|
+
channel_request = AMQP::Channel.new(amqp_conn)
|
62
|
+
exchange_request = channel_request.fanout(channel_request_name)
|
63
|
+
|
64
|
+
request_interval = 1
|
65
|
+
if(options[:request_interval])
|
66
|
+
request_interval = options[:request_interval]
|
67
|
+
end
|
68
|
+
|
69
|
+
# Publish
|
70
|
+
if(options[:verbose])
|
71
|
+
Bsl::Logger::Log "Starting publish, interval #{request_interval} sec(s)."
|
72
|
+
end
|
73
|
+
|
74
|
+
EventMachine.add_periodic_timer(request_interval) do
|
75
|
+
payload = {:a => "b"}.to_json
|
76
|
+
if(options[:verbose])
|
77
|
+
Bsl::Logger::Log "Publishing payload: '#{payload}'"
|
78
|
+
end
|
79
|
+
exchange_request.publish(payload)
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
# Console application main()
|
85
|
+
def main
|
86
|
+
super()
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../ThorJob.rb')
|
2
|
+
|
3
|
+
module Thor
|
4
|
+
module Jobs
|
5
|
+
class Node < Thor::Job
|
6
|
+
@@AUTHOR = "korczis@gmail.com"
|
7
|
+
@@DESCRIPTION = "Core node functionality"
|
8
|
+
@@LICENSE = "GPL"
|
9
|
+
@@VERSION = "0.0.1"
|
10
|
+
@@SUPPORTED_MSGS = []
|
11
|
+
|
12
|
+
# C-tor
|
13
|
+
def initialize(opts = {})
|
14
|
+
super(opts)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Async runner
|
18
|
+
def run(opts = {})
|
19
|
+
super(opts)
|
20
|
+
|
21
|
+
if(options[:verbose])
|
22
|
+
Bsl::Logger::Log "Thor::Jobs::Node::run()"
|
23
|
+
end
|
24
|
+
=begin
|
25
|
+
# Construct queue name
|
26
|
+
klass_name = (self.class.name + "s").downcase
|
27
|
+
queue_name = klass_name + "." + Thor::generate_guid
|
28
|
+
|
29
|
+
channel = AMQP::Channel.new(amqp_conn)
|
30
|
+
exchange = channel.fanout(klass_name)
|
31
|
+
|
32
|
+
channel.queue("#{rand(100)}", :auto_delete => true).bind(exchange).subscribe do |payload|
|
33
|
+
# Bsl::Logger::Log "#{payload} => joe"
|
34
|
+
end
|
35
|
+
|
36
|
+
channel.queue("#{rand(100)}", :auto_delete => true).bind(exchange).subscribe do |payload|
|
37
|
+
# Bsl::Logger::Log "#{payload} => aaron"
|
38
|
+
end
|
39
|
+
|
40
|
+
channel.queue("#{rand(100)}", :auto_delete => true).bind(exchange).subscribe do |payload|
|
41
|
+
# Bsl::Logger::Log "#{payload} => bob"
|
42
|
+
end
|
43
|
+
|
44
|
+
EventMachine.add_periodic_timer(0) do
|
45
|
+
exchange.publish("BOS 101, NYK 89").publish("ORL 85, ALT 88")
|
46
|
+
end
|
47
|
+
=end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Console application main()
|
51
|
+
def main
|
52
|
+
super()
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bsl-thor
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Black Snail Labs
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-12-19 00:00:00 Z
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Thor distributed framework
|
22
|
+
email: admin@blacksnaillabs.com
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- LICENSE.txt
|
29
|
+
- README
|
30
|
+
- README.rdoc
|
31
|
+
- lib/BslThor.rb
|
32
|
+
- lib/ThorApplication.rb
|
33
|
+
- lib/ThorClient.rb
|
34
|
+
- lib/ThorCmd.rb
|
35
|
+
- lib/ThorJob.rb
|
36
|
+
- lib/ThorMaster.rb
|
37
|
+
- lib/ThorNode.rb
|
38
|
+
- lib/ThorUtils.rb
|
39
|
+
- lib/ThorWorker.rb
|
40
|
+
- lib/boot/Boot.rb
|
41
|
+
- lib/boot/Client.rb
|
42
|
+
- lib/boot/Master.rb
|
43
|
+
- lib/boot/Node.rb
|
44
|
+
- lib/config/ThorClient.yml.template
|
45
|
+
- lib/config/ThorCmd.yml.template
|
46
|
+
- lib/config/ThorMaster.yml.template
|
47
|
+
- lib/config/ThorNode.yml.template
|
48
|
+
- lib/config/ThorWorker.yml.template
|
49
|
+
- lib/jobs/Client-0.0.1/main.rb
|
50
|
+
- lib/jobs/Master-0.0.1/main.rb
|
51
|
+
- lib/jobs/MonitorClient-0.0.1/main.rb
|
52
|
+
- lib/jobs/MonitorMaster-0.0.1/main.rb
|
53
|
+
- lib/jobs/Node-0.0.1/main.rb
|
54
|
+
- lib/models/ThorModelClient.rb
|
55
|
+
- lib/models/ThorModelJob.rb
|
56
|
+
- lib/models/ThorModelWorker.rb
|
57
|
+
files:
|
58
|
+
- Gemfile
|
59
|
+
- LICENSE.txt
|
60
|
+
- Manifest
|
61
|
+
- README
|
62
|
+
- README.rdoc
|
63
|
+
- Rakefile
|
64
|
+
- app/amqp2sql.rb
|
65
|
+
- lib/BslThor.rb
|
66
|
+
- lib/ThorApplication.rb
|
67
|
+
- lib/ThorClient.rb
|
68
|
+
- lib/ThorCmd.rb
|
69
|
+
- lib/ThorJob.rb
|
70
|
+
- lib/ThorMaster.rb
|
71
|
+
- lib/ThorNode.rb
|
72
|
+
- lib/ThorUtils.rb
|
73
|
+
- lib/ThorWorker.rb
|
74
|
+
- lib/boot/Boot.rb
|
75
|
+
- lib/boot/Client.rb
|
76
|
+
- lib/boot/Master.rb
|
77
|
+
- lib/boot/Node.rb
|
78
|
+
- lib/config/ThorClient.yml.template
|
79
|
+
- lib/config/ThorCmd.yml.template
|
80
|
+
- lib/config/ThorMaster.yml.template
|
81
|
+
- lib/config/ThorNode.yml.template
|
82
|
+
- lib/config/ThorWorker.yml.template
|
83
|
+
- lib/jobs/Client-0.0.1/main.rb
|
84
|
+
- lib/jobs/Master-0.0.1/main.rb
|
85
|
+
- lib/jobs/MonitorClient-0.0.1/main.rb
|
86
|
+
- lib/jobs/MonitorMaster-0.0.1/main.rb
|
87
|
+
- lib/jobs/Node-0.0.1/main.rb
|
88
|
+
- lib/models/ThorModelClient.rb
|
89
|
+
- lib/models/ThorModelJob.rb
|
90
|
+
- lib/models/ThorModelWorker.rb
|
91
|
+
- bsl-thor.gemspec
|
92
|
+
homepage: http://github.com/blacksnaillabs/thor
|
93
|
+
licenses: []
|
94
|
+
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options:
|
97
|
+
- --line-numbers
|
98
|
+
- --inline-source
|
99
|
+
- --title
|
100
|
+
- Bsl-thor
|
101
|
+
- --main
|
102
|
+
- README.rdoc
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
hash: 3
|
111
|
+
segments:
|
112
|
+
- 0
|
113
|
+
version: "0"
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
hash: 11
|
120
|
+
segments:
|
121
|
+
- 1
|
122
|
+
- 2
|
123
|
+
version: "1.2"
|
124
|
+
requirements: []
|
125
|
+
|
126
|
+
rubyforge_project: bsl-thor
|
127
|
+
rubygems_version: 1.8.12
|
128
|
+
signing_key:
|
129
|
+
specification_version: 3
|
130
|
+
summary: Thor distributed framework
|
131
|
+
test_files: []
|
132
|
+
|