isono 0.2.21 → 0.2.22
Sign up to get free protection for your applications and to get access to all the features.
- data/isono.gemspec +3 -3
- data/lib/isono.rb +1 -0
- data/lib/isono/node_modules/direct_channel.rb +70 -0
- data/lib/isono/runner/rpc_server.rb +1 -0
- data/lib/isono/version.rb +1 -1
- metadata +39 -38
data/isono.gemspec
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "isono"
|
5
|
-
s.version = "0.2.
|
5
|
+
s.version = "0.2.22"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["axsh Ltd.", "Masahiro Fujiwara"]
|
9
|
-
s.date = "2018-
|
9
|
+
s.date = "2018-03-22"
|
10
10
|
s.email = ["dev@axsh.net", "m-fujiwara@axsh.net"]
|
11
11
|
s.executables = ["cli"]
|
12
|
-
s.files = ["LICENSE", "NOTICE", "Rakefile", "isono.gemspec", "lib/
|
12
|
+
s.files = ["LICENSE", "NOTICE", "Rakefile", "isono.gemspec", "lib/ext/shellwords.rb", "lib/isono/amqp_client.rb", "lib/isono/daemonize.rb", "lib/isono/event_delegate_context.rb", "lib/isono/event_observable.rb", "lib/isono/logger.rb", "lib/isono/manifest.rb", "lib/isono/messaging_client.rb", "lib/isono/models/event_log.rb", "lib/isono/models/job_state.rb", "lib/isono/models/node_state.rb", "lib/isono/models/resource_instance.rb", "lib/isono/node.rb", "lib/isono/node_modules/base.rb", "lib/isono/node_modules/data_store.rb", "lib/isono/node_modules/direct_channel.rb", "lib/isono/node_modules/event_channel.rb", "lib/isono/node_modules/event_logger.rb", "lib/isono/node_modules/job_channel.rb", "lib/isono/node_modules/job_collector.rb", "lib/isono/node_modules/job_worker.rb", "lib/isono/node_modules/node_collector.rb", "lib/isono/node_modules/node_heartbeat.rb", "lib/isono/node_modules/rpc_channel.rb", "lib/isono/rack/builder.rb", "lib/isono/rack/data_store.rb", "lib/isono/rack/job.rb", "lib/isono/rack/map.rb", "lib/isono/rack/object_method.rb", "lib/isono/rack/proc.rb", "lib/isono/rack/sequel.rb", "lib/isono/rack/thread_pass.rb", "lib/isono/rack.rb", "lib/isono/resource_manifest.rb", "lib/isono/runner/base.rb", "lib/isono/runner/cli.rb", "lib/isono/runner/rpc_server.rb", "lib/isono/serializer.rb", "lib/isono/thread_pool.rb", "lib/isono/util.rb", "lib/isono/version.rb", "lib/isono.rb", "spec/amqp_client_spec.rb", "spec/event_observable_spec.rb", "spec/file_channel_spec.rb", "spec/job_channel_spec.rb", "spec/logger_spec.rb", "spec/manifest_spec.rb", "spec/node_spec.rb", "spec/resource_loader_spec.rb", "spec/rpc_channel_spec.rb", "spec/spec_helper.rb", "spec/thread_pool_spec.rb", "spec/util_spec.rb", "tasks/load_resource_manifest.rake", "bin/cli"]
|
13
13
|
s.homepage = "http://github.com/axsh/isono"
|
14
14
|
s.require_paths = ["lib"]
|
15
15
|
s.required_ruby_version = Gem::Requirement.new(">= 1.9.2")
|
data/lib/isono.rb
CHANGED
@@ -19,6 +19,7 @@ module Isono
|
|
19
19
|
autoload :Base, 'isono/node_modules/base'
|
20
20
|
autoload :DataStore, 'isono/node_modules/data_store'
|
21
21
|
autoload :EventChannel, 'isono/node_modules/event_channel'
|
22
|
+
autoload :DirectChannel, 'isono/node_modules/direct_channel'
|
22
23
|
autoload :RpcChannel, 'isono/node_modules/rpc_channel'
|
23
24
|
autoload :NodeHeartbeat, 'isono/node_modules/node_heartbeat'
|
24
25
|
autoload :NodeCollector, 'isono/node_modules/node_collector'
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
module Isono
|
4
|
+
module NodeModules
|
5
|
+
class DirectChannel < Base
|
6
|
+
AMQP_EXCHANGE='isono.direct'
|
7
|
+
|
8
|
+
initialize_hook do
|
9
|
+
@amq = node.create_channel
|
10
|
+
@amq.instance_eval {
|
11
|
+
def event_exchange
|
12
|
+
self.direct(AMQP_EXCHANGE, {:auto_delete=>false})
|
13
|
+
end
|
14
|
+
}
|
15
|
+
|
16
|
+
# create the exchange
|
17
|
+
@amq.event_exchange
|
18
|
+
end
|
19
|
+
|
20
|
+
terminate_hook do
|
21
|
+
end
|
22
|
+
|
23
|
+
# @example
|
24
|
+
# publish('ev/event_name', :args=>[1, 2, 3])
|
25
|
+
def publish(evname, opts={})
|
26
|
+
opts = {:args=>[], :sender=>manifest.node_id}.merge(opts)
|
27
|
+
|
28
|
+
body = {
|
29
|
+
:event => evname,
|
30
|
+
:published_at=> Time.now,
|
31
|
+
:sender => opts[:sender],
|
32
|
+
:origin_node => manifest.node_id,
|
33
|
+
:args => opts[:args]
|
34
|
+
}
|
35
|
+
|
36
|
+
EventMachine.schedule {
|
37
|
+
@amq.event_exchange.publish(Serializer.instance.marshal(body),
|
38
|
+
{:key=>"#{evname}"}
|
39
|
+
)
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
def subscribe(evname, &blk)
|
44
|
+
@amq.queue("#{evname}",{:auto_delete=>true}).bind(
|
45
|
+
AMQP_EXCHANGE, :key=>"#{evname}"
|
46
|
+
).subscribe { |data|
|
47
|
+
data = Serializer.instance.unmarshal(data)
|
48
|
+
case blk.arity
|
49
|
+
when 2
|
50
|
+
m = data.delete(:args)
|
51
|
+
blk.call(data, m)
|
52
|
+
when 1
|
53
|
+
blk.call(data[:args])
|
54
|
+
else
|
55
|
+
blk.call
|
56
|
+
end
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
def unsubscribe(evname)
|
61
|
+
EventMachine.schedule {
|
62
|
+
q = @amq.queue("#{evname}",{:auto_delete=>true})
|
63
|
+
q.unsubscribe
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
@@ -159,6 +159,7 @@ module Isono
|
|
159
159
|
|
160
160
|
DEFAULT_MANIFEST = Manifest.new(Dir.pwd) do
|
161
161
|
load_module NodeModules::EventChannel
|
162
|
+
load_module NodeModules::DirectChannel
|
162
163
|
load_module NodeModules::RpcChannel
|
163
164
|
load_module NodeModules::JobWorker
|
164
165
|
load_module NodeModules::JobChannel
|
data/lib/isono/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isono
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.22
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-
|
13
|
+
date: 2018-03-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: amqp
|
@@ -105,59 +105,60 @@ files:
|
|
105
105
|
- NOTICE
|
106
106
|
- Rakefile
|
107
107
|
- isono.gemspec
|
108
|
+
- lib/ext/shellwords.rb
|
109
|
+
- lib/isono/amqp_client.rb
|
110
|
+
- lib/isono/daemonize.rb
|
111
|
+
- lib/isono/event_delegate_context.rb
|
112
|
+
- lib/isono/event_observable.rb
|
113
|
+
- lib/isono/logger.rb
|
108
114
|
- lib/isono/manifest.rb
|
109
|
-
- lib/isono/
|
110
|
-
- lib/isono/
|
111
|
-
- lib/isono/
|
115
|
+
- lib/isono/messaging_client.rb
|
116
|
+
- lib/isono/models/event_log.rb
|
117
|
+
- lib/isono/models/job_state.rb
|
118
|
+
- lib/isono/models/node_state.rb
|
119
|
+
- lib/isono/models/resource_instance.rb
|
120
|
+
- lib/isono/node.rb
|
121
|
+
- lib/isono/node_modules/base.rb
|
112
122
|
- lib/isono/node_modules/data_store.rb
|
123
|
+
- lib/isono/node_modules/direct_channel.rb
|
124
|
+
- lib/isono/node_modules/event_channel.rb
|
125
|
+
- lib/isono/node_modules/event_logger.rb
|
126
|
+
- lib/isono/node_modules/job_channel.rb
|
113
127
|
- lib/isono/node_modules/job_collector.rb
|
114
|
-
- lib/isono/node_modules/base.rb
|
115
|
-
- lib/isono/node_modules/rpc_channel.rb
|
116
128
|
- lib/isono/node_modules/job_worker.rb
|
129
|
+
- lib/isono/node_modules/node_collector.rb
|
117
130
|
- lib/isono/node_modules/node_heartbeat.rb
|
118
|
-
- lib/isono/node_modules/
|
119
|
-
- lib/isono/models/resource_instance.rb
|
120
|
-
- lib/isono/models/job_state.rb
|
121
|
-
- lib/isono/models/node_state.rb
|
122
|
-
- lib/isono/models/event_log.rb
|
123
|
-
- lib/isono/rack.rb
|
124
|
-
- lib/isono/logger.rb
|
125
|
-
- lib/isono/resource_manifest.rb
|
126
|
-
- lib/isono/util.rb
|
127
|
-
- lib/isono/daemonize.rb
|
128
|
-
- lib/isono/runner/rpc_server.rb
|
129
|
-
- lib/isono/runner/base.rb
|
130
|
-
- lib/isono/runner/cli.rb
|
131
|
-
- lib/isono/node.rb
|
132
|
-
- lib/isono/amqp_client.rb
|
133
|
-
- lib/isono/version.rb
|
134
|
-
- lib/isono/event_observable.rb
|
135
|
-
- lib/isono/rack/thread_pass.rb
|
136
|
-
- lib/isono/rack/data_store.rb
|
131
|
+
- lib/isono/node_modules/rpc_channel.rb
|
137
132
|
- lib/isono/rack/builder.rb
|
138
|
-
- lib/isono/rack/
|
133
|
+
- lib/isono/rack/data_store.rb
|
134
|
+
- lib/isono/rack/job.rb
|
139
135
|
- lib/isono/rack/map.rb
|
136
|
+
- lib/isono/rack/object_method.rb
|
140
137
|
- lib/isono/rack/proc.rb
|
141
|
-
- lib/isono/rack/job.rb
|
142
138
|
- lib/isono/rack/sequel.rb
|
143
|
-
- lib/isono/
|
144
|
-
- lib/isono/
|
145
|
-
- lib/isono/
|
139
|
+
- lib/isono/rack/thread_pass.rb
|
140
|
+
- lib/isono/rack.rb
|
141
|
+
- lib/isono/resource_manifest.rb
|
142
|
+
- lib/isono/runner/base.rb
|
143
|
+
- lib/isono/runner/cli.rb
|
144
|
+
- lib/isono/runner/rpc_server.rb
|
146
145
|
- lib/isono/serializer.rb
|
146
|
+
- lib/isono/thread_pool.rb
|
147
|
+
- lib/isono/util.rb
|
148
|
+
- lib/isono/version.rb
|
147
149
|
- lib/isono.rb
|
148
|
-
- lib/ext/shellwords.rb
|
149
|
-
- spec/event_observable_spec.rb
|
150
150
|
- spec/amqp_client_spec.rb
|
151
|
-
- spec/
|
152
|
-
- spec/logger_spec.rb
|
151
|
+
- spec/event_observable_spec.rb
|
153
152
|
- spec/file_channel_spec.rb
|
154
|
-
- spec/spec_helper.rb
|
155
153
|
- spec/job_channel_spec.rb
|
156
|
-
- spec/
|
154
|
+
- spec/logger_spec.rb
|
155
|
+
- spec/manifest_spec.rb
|
157
156
|
- spec/node_spec.rb
|
158
157
|
- spec/resource_loader_spec.rb
|
159
|
-
- spec/
|
158
|
+
- spec/rpc_channel_spec.rb
|
159
|
+
- spec/spec_helper.rb
|
160
160
|
- spec/thread_pool_spec.rb
|
161
|
+
- spec/util_spec.rb
|
161
162
|
- tasks/load_resource_manifest.rake
|
162
163
|
- bin/cli
|
163
164
|
homepage: http://github.com/axsh/isono
|