pipeline_toolkit 1.1.0 → 1.2.0
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/LICENSE.markdown +1 -1
- data/README.markdown +38 -19
- data/bin/msg_generator +3 -4
- data/bin/msg_push +3 -4
- data/bin/msg_sink +3 -7
- data/bin/msg_subscribe +3 -4
- data/lib/pipeline_toolkit.rb +5 -5
- data/lib/pipeline_toolkit/amqp/abstract.rb +81 -78
- data/lib/pipeline_toolkit/amqp/reader.rb +55 -52
- data/lib/pipeline_toolkit/amqp/writer.rb +42 -39
- data/lib/pipeline_toolkit/{commands/msg_generator/cli.rb → cli/msg_generator_cli.rb} +6 -5
- data/lib/pipeline_toolkit/{commands/msg_push/cli.rb → cli/msg_push_cli.rb} +16 -8
- data/lib/pipeline_toolkit/cli/msg_sink_cli.rb +28 -0
- data/lib/pipeline_toolkit/{commands/msg_subscribe/cli.rb → cli/msg_subscribe_cli.rb} +23 -14
- data/lib/pipeline_toolkit/cucumber.rb +5 -3
- data/lib/pipeline_toolkit/cucumber/amqp.rb +1 -1
- data/lib/pipeline_toolkit/cucumber/in_out_process.rb +50 -0
- data/lib/pipeline_toolkit/cucumber/machine.rb +44 -26
- data/lib/pipeline_toolkit/cucumber/machine_steps.rb +15 -9
- data/lib/pipeline_toolkit/cucumber/{msg_sub_machine.rb → msg_sub_process.rb} +5 -5
- data/lib/pipeline_toolkit/handlers/message_handler.rb +43 -39
- data/lib/pipeline_toolkit/message_coder.rb +38 -25
- data/lib/pipeline_toolkit/message_command.rb +167 -157
- data/lib/pipeline_toolkit/message_generator.rb +22 -18
- data/lib/pipeline_toolkit/message_pusher.rb +46 -47
- data/lib/pipeline_toolkit/message_sink.rb +9 -5
- data/lib/pipeline_toolkit/message_subscriber.rb +190 -183
- data/lib/pipeline_toolkit/monitoring/monitor_server.rb +64 -109
- data/lib/pipeline_toolkit/util/hash_ext.rb +8 -0
- data/lib/pipeline_toolkit/util/indifferent_hash.rb +10 -0
- data/lib/pipeline_toolkit/{socket_util.rb → util/socket_util.rb} +1 -1
- metadata +25 -115
- data/lib/pipeline_toolkit/commands/msg_sink/cli.rb +0 -41
- data/lib/pipeline_toolkit/open_hash.rb +0 -24
@@ -2,123 +2,78 @@
|
|
2
2
|
require 'erb'
|
3
3
|
require 'evma_httpserver'
|
4
4
|
|
5
|
-
module
|
5
|
+
module PipelineToolkit
|
6
|
+
module Monitoring # :nodoc:
|
6
7
|
|
7
|
-
##
|
8
|
-
# The http server to monitor the pipeline and report the results.
|
9
|
-
#
|
10
|
-
class MonitorServer < EM::Connection
|
11
|
-
include EM::HttpServer
|
12
|
-
|
13
8
|
##
|
14
|
-
#
|
9
|
+
# The http server to monitor the pipeline and report the results.
|
15
10
|
#
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
# @
|
23
|
-
end
|
24
|
-
|
25
|
-
def post_init
|
26
|
-
super
|
27
|
-
no_environment_strings
|
28
|
-
end
|
29
|
-
|
30
|
-
def process_http_request
|
31
|
-
response = EM::DelegatedHttpResponse.new(self)
|
32
|
-
response.status = 200
|
33
|
-
response.content_type 'text/html'
|
34
|
-
# if ((@http_content_type =~ content_type_regex) == 0)
|
11
|
+
class MonitorServer < EM::Connection
|
12
|
+
include EM::HttpServer
|
13
|
+
|
14
|
+
##
|
15
|
+
# Initialize a new intance
|
16
|
+
#
|
17
|
+
# @param message_subscriber<MessageSubscriber> The message subscriber
|
35
18
|
#
|
36
|
-
|
37
|
-
|
19
|
+
def initialize(message_subscriber, options = {})
|
20
|
+
DefaultLogger.init_logger(options)
|
21
|
+
@options = options
|
22
|
+
@message_subscriber = message_subscriber
|
23
|
+
@html_template = ERB.new(File.read(File.dirname(__FILE__) + "/monitor.erb"))
|
24
|
+
end
|
38
25
|
|
39
|
-
|
40
|
-
|
26
|
+
def post_init
|
27
|
+
super
|
28
|
+
no_environment_strings
|
29
|
+
end
|
30
|
+
|
31
|
+
def process_http_request
|
32
|
+
response = EM::DelegatedHttpResponse.new(self)
|
33
|
+
response.status = 200
|
34
|
+
|
35
|
+
case @http_path_info
|
36
|
+
when /.json$/
|
37
|
+
process_json(response)
|
38
|
+
else
|
39
|
+
process_html(response)
|
40
|
+
end
|
41
|
+
|
42
|
+
response.send_response
|
43
|
+
end
|
41
44
|
|
42
|
-
|
45
|
+
private
|
46
|
+
|
47
|
+
def process_json(response)
|
48
|
+
response.content_type 'application/json'
|
49
|
+
result = {
|
50
|
+
:pid => @message_subscriber.process_id,
|
51
|
+
:host => @message_subscriber.hostname,
|
52
|
+
:structure => @message_subscriber.structure,
|
53
|
+
:throughput => @message_subscriber.mps,
|
54
|
+
:uptime => @message_subscriber.uptime
|
55
|
+
}
|
56
|
+
response.content = result.to_json
|
57
|
+
end
|
58
|
+
|
59
|
+
def process_html(response)
|
60
|
+
response.content_type 'text/html'
|
61
|
+
response.content = @html_template.result(@message_subscriber.get_binding)
|
62
|
+
end
|
63
|
+
|
64
|
+
##
|
65
|
+
# Build a regex to check the content_type request header
|
66
|
+
#
|
67
|
+
def content_type_regex
|
68
|
+
case options[:content_type]
|
69
|
+
when "json"
|
70
|
+
@content_type_regex = /^(text|application)\/json/
|
71
|
+
else
|
72
|
+
@content_type_regex = /^(text|application)\/html/
|
73
|
+
end
|
74
|
+
end
|
43
75
|
|
44
|
-
def html_template
|
45
|
-
<<-EOL
|
46
|
-
<!DOCTYPE HTML>
|
47
|
-
<html lang="en-NZ">
|
48
|
-
<head>
|
49
|
-
<title>Message Probe</title>
|
50
|
-
<meta charset="UTF-8">
|
51
|
-
<style type="text/css">
|
52
|
-
body {
|
53
|
-
background: black;
|
54
|
-
color: #80c0c0;
|
55
|
-
}
|
56
|
-
h1 {
|
57
|
-
font: 12pt Monospace;
|
58
|
-
text-align:center;
|
59
|
-
}
|
60
|
-
table {
|
61
|
-
font: 10pt Monospace;
|
62
|
-
margin-left:auto;
|
63
|
-
margin-right:auto;
|
64
|
-
text-align:right;
|
65
|
-
}
|
66
|
-
.page {
|
67
|
-
position:relative;
|
68
|
-
top: 20%;
|
69
|
-
# border-style:solid;
|
70
|
-
# border-width:5px;
|
71
|
-
width: 400px;
|
72
|
-
margin-left:auto;
|
73
|
-
margin-right:auto;
|
74
|
-
}
|
75
|
-
</style>
|
76
|
-
</head>
|
77
|
-
<body>
|
78
|
-
<div class=page>
|
79
|
-
<h1>
|
80
|
-
<span class="name">#{@message_subscriber.name}</span>
|
81
|
-
</h1>
|
82
|
-
<table>
|
83
|
-
<tr>
|
84
|
-
<td>Structure:</td>
|
85
|
-
<td>
|
86
|
-
<span class="queue_in">#{@message_subscriber.queue_name}</span> -> <span class="queues_out">#{@message_subscriber.queues_out}</span>
|
87
|
-
</td>
|
88
|
-
</tr>
|
89
|
-
<tr>
|
90
|
-
<td>Throughput:</td>
|
91
|
-
<td>
|
92
|
-
<span class="mps">#{@message_subscriber.mps.to_i}</span>
|
93
|
-
</td>
|
94
|
-
</tr>
|
95
|
-
<tr>
|
96
|
-
<td>Uptime:</td>
|
97
|
-
<td>
|
98
|
-
<span class="uptime">#{(Time.now - @message_subscriber.start_time).to_i / 60}mins</span>
|
99
|
-
</td>
|
100
|
-
</tr>
|
101
|
-
</table>
|
102
|
-
</div>
|
103
|
-
</body>
|
104
|
-
</html>
|
105
|
-
EOL
|
106
76
|
end
|
107
77
|
|
108
|
-
##
|
109
|
-
# Build a regex to check the content_type request header
|
110
|
-
#
|
111
|
-
def content_type_regex
|
112
|
-
case options[:content_type]
|
113
|
-
when "json"
|
114
|
-
@content_type_regex = /^(text|application)\/json/
|
115
|
-
when "xml"
|
116
|
-
@content_type_regex = /^(text|application)\/xml/
|
117
|
-
else
|
118
|
-
@content_type_regex = /^(text|application)\/html/
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
78
|
end
|
123
|
-
|
124
79
|
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 1
|
7
|
-
-
|
7
|
+
- 2
|
8
8
|
- 0
|
9
|
-
version: 1.
|
9
|
+
version: 1.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Aisha Fenton
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-23 00:00:00 +12:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -23,7 +23,7 @@ dependencies:
|
|
23
23
|
prerelease: false
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- -
|
26
|
+
- - ~>
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
segments:
|
29
29
|
- 0
|
@@ -37,12 +37,12 @@ dependencies:
|
|
37
37
|
prerelease: false
|
38
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- -
|
40
|
+
- - ~>
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
segments:
|
43
43
|
- 1
|
44
|
-
-
|
45
|
-
version: "1.
|
44
|
+
- 16
|
45
|
+
version: "1.16"
|
46
46
|
type: :runtime
|
47
47
|
version_requirements: *id002
|
48
48
|
- !ruby/object:Gem::Dependency
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
prerelease: false
|
51
51
|
requirement: &id003 !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ~>
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
segments:
|
56
56
|
- 0
|
@@ -64,7 +64,7 @@ dependencies:
|
|
64
64
|
prerelease: false
|
65
65
|
requirement: &id004 !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ~>
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
segments:
|
70
70
|
- 0
|
@@ -78,7 +78,7 @@ dependencies:
|
|
78
78
|
prerelease: false
|
79
79
|
requirement: &id005 !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- -
|
81
|
+
- - ~>
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
segments:
|
84
84
|
- 1
|
@@ -92,7 +92,7 @@ dependencies:
|
|
92
92
|
prerelease: false
|
93
93
|
requirement: &id006 !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- -
|
95
|
+
- - ~>
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
segments:
|
98
98
|
- 0
|
@@ -102,111 +102,19 @@ dependencies:
|
|
102
102
|
type: :runtime
|
103
103
|
version_requirements: *id006
|
104
104
|
- !ruby/object:Gem::Dependency
|
105
|
-
name:
|
105
|
+
name: cucumber
|
106
106
|
prerelease: false
|
107
107
|
requirement: &id007 !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
|
-
- -
|
110
|
-
- !ruby/object:Gem::Version
|
111
|
-
segments:
|
112
|
-
- 2
|
113
|
-
- 0
|
114
|
-
- 0
|
115
|
-
- beta
|
116
|
-
- 2
|
117
|
-
version: 2.0.0.beta.2
|
118
|
-
type: :development
|
119
|
-
version_requirements: *id007
|
120
|
-
- !ruby/object:Gem::Dependency
|
121
|
-
name: rspec-core
|
122
|
-
prerelease: false
|
123
|
-
requirement: &id008 !ruby/object:Gem::Requirement
|
124
|
-
requirements:
|
125
|
-
- - ">="
|
126
|
-
- !ruby/object:Gem::Version
|
127
|
-
segments:
|
128
|
-
- 2
|
129
|
-
- 0
|
130
|
-
- 0
|
131
|
-
- beta
|
132
|
-
- 2
|
133
|
-
version: 2.0.0.beta.2
|
134
|
-
type: :development
|
135
|
-
version_requirements: *id008
|
136
|
-
- !ruby/object:Gem::Dependency
|
137
|
-
name: rspec-expectations
|
138
|
-
prerelease: false
|
139
|
-
requirement: &id009 !ruby/object:Gem::Requirement
|
140
|
-
requirements:
|
141
|
-
- - ">="
|
142
|
-
- !ruby/object:Gem::Version
|
143
|
-
segments:
|
144
|
-
- 2
|
145
|
-
- 0
|
146
|
-
- 0
|
147
|
-
- beta
|
148
|
-
- 2
|
149
|
-
version: 2.0.0.beta.2
|
150
|
-
type: :development
|
151
|
-
version_requirements: *id009
|
152
|
-
- !ruby/object:Gem::Dependency
|
153
|
-
name: rspec-mocks
|
154
|
-
prerelease: false
|
155
|
-
requirement: &id010 !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - ">="
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
segments:
|
160
|
-
- 2
|
161
|
-
- 0
|
162
|
-
- 0
|
163
|
-
- beta
|
164
|
-
- 2
|
165
|
-
version: 2.0.0.beta.2
|
166
|
-
type: :development
|
167
|
-
version_requirements: *id010
|
168
|
-
- !ruby/object:Gem::Dependency
|
169
|
-
name: yard
|
170
|
-
prerelease: false
|
171
|
-
requirement: &id011 !ruby/object:Gem::Requirement
|
172
|
-
requirements:
|
173
|
-
- - ">="
|
109
|
+
- - ~>
|
174
110
|
- !ruby/object:Gem::Version
|
175
111
|
segments:
|
176
112
|
- 0
|
113
|
+
- 8
|
177
114
|
- 5
|
178
|
-
|
179
|
-
version: 0.5.3
|
180
|
-
type: :development
|
181
|
-
version_requirements: *id011
|
182
|
-
- !ruby/object:Gem::Dependency
|
183
|
-
name: cucumber
|
184
|
-
prerelease: false
|
185
|
-
requirement: &id012 !ruby/object:Gem::Requirement
|
186
|
-
requirements:
|
187
|
-
- - ">="
|
188
|
-
- !ruby/object:Gem::Version
|
189
|
-
segments:
|
190
|
-
- 0
|
191
|
-
- 6
|
192
|
-
- 3
|
193
|
-
version: 0.6.3
|
194
|
-
type: :development
|
195
|
-
version_requirements: *id012
|
196
|
-
- !ruby/object:Gem::Dependency
|
197
|
-
name: aruba
|
198
|
-
prerelease: false
|
199
|
-
requirement: &id013 !ruby/object:Gem::Requirement
|
200
|
-
requirements:
|
201
|
-
- - ">="
|
202
|
-
- !ruby/object:Gem::Version
|
203
|
-
segments:
|
204
|
-
- 0
|
205
|
-
- 1
|
206
|
-
- 7
|
207
|
-
version: 0.1.7
|
115
|
+
version: 0.8.5
|
208
116
|
type: :development
|
209
|
-
version_requirements: *
|
117
|
+
version_requirements: *id007
|
210
118
|
description: |-
|
211
119
|
Command line tools for processing messages by constructing a pipeline of workers.
|
212
120
|
AMQP and Unix pipes are used to construct the pipeline. Messages are simple Hashes
|
@@ -227,16 +135,17 @@ files:
|
|
227
135
|
- lib/pipeline_toolkit/amqp/abstract.rb
|
228
136
|
- lib/pipeline_toolkit/amqp/reader.rb
|
229
137
|
- lib/pipeline_toolkit/amqp/writer.rb
|
230
|
-
- lib/pipeline_toolkit/
|
231
|
-
- lib/pipeline_toolkit/
|
232
|
-
- lib/pipeline_toolkit/
|
233
|
-
- lib/pipeline_toolkit/
|
138
|
+
- lib/pipeline_toolkit/cli/msg_generator_cli.rb
|
139
|
+
- lib/pipeline_toolkit/cli/msg_push_cli.rb
|
140
|
+
- lib/pipeline_toolkit/cli/msg_sink_cli.rb
|
141
|
+
- lib/pipeline_toolkit/cli/msg_subscribe_cli.rb
|
234
142
|
- lib/pipeline_toolkit/cucumber.rb
|
235
143
|
- lib/pipeline_toolkit/cucumber/amqp.rb
|
236
144
|
- lib/pipeline_toolkit/cucumber/amqp_steps.rb
|
145
|
+
- lib/pipeline_toolkit/cucumber/in_out_process.rb
|
237
146
|
- lib/pipeline_toolkit/cucumber/machine.rb
|
238
147
|
- lib/pipeline_toolkit/cucumber/machine_steps.rb
|
239
|
-
- lib/pipeline_toolkit/cucumber/
|
148
|
+
- lib/pipeline_toolkit/cucumber/msg_sub_process.rb
|
240
149
|
- lib/pipeline_toolkit/default_logger.rb
|
241
150
|
- lib/pipeline_toolkit/handlers/message_handler.rb
|
242
151
|
- lib/pipeline_toolkit/message_coder.rb
|
@@ -246,8 +155,9 @@ files:
|
|
246
155
|
- lib/pipeline_toolkit/message_sink.rb
|
247
156
|
- lib/pipeline_toolkit/message_subscriber.rb
|
248
157
|
- lib/pipeline_toolkit/monitoring/monitor_server.rb
|
249
|
-
- lib/pipeline_toolkit/
|
250
|
-
- lib/pipeline_toolkit/
|
158
|
+
- lib/pipeline_toolkit/util/hash_ext.rb
|
159
|
+
- lib/pipeline_toolkit/util/indifferent_hash.rb
|
160
|
+
- lib/pipeline_toolkit/util/socket_util.rb
|
251
161
|
- LICENSE.markdown
|
252
162
|
- README.markdown
|
253
163
|
has_rdoc: true
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'trollop'
|
3
|
-
|
4
|
-
Signal.trap('INT') do
|
5
|
-
# puts "\nStopping"
|
6
|
-
# TODO: complete signal trap interrupt
|
7
|
-
end
|
8
|
-
|
9
|
-
Signal.trap('TERM') do
|
10
|
-
# puts "\nStopping"
|
11
|
-
# TODO: complete signal trap terminate
|
12
|
-
end
|
13
|
-
|
14
|
-
module Commands # :nodoc:
|
15
|
-
module MsgSink
|
16
|
-
class CLI
|
17
|
-
def self.execute(stdout, arguments=[])
|
18
|
-
|
19
|
-
opts = Trollop::options do
|
20
|
-
banner <<-EOL
|
21
|
-
Message Sink
|
22
|
-
------------------
|
23
|
-
TODO: description
|
24
|
-
|
25
|
-
Usage:
|
26
|
-
msg_sink [options]
|
27
|
-
|
28
|
-
Examples:
|
29
|
-
msg_sink
|
30
|
-
|
31
|
-
Options:
|
32
|
-
EOL
|
33
|
-
|
34
|
-
opt :env, "The environment to run (development, production)", :default => "development", :short => :e
|
35
|
-
end
|
36
|
-
|
37
|
-
MessageSink.new(opts).start
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|