rflow 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.
- checksums.yaml +4 -4
- data/bin/rflow +13 -3
- data/example/http_extensions.rb +2 -2
- data/lib/rflow/components.rb +1 -0
- data/lib/rflow/components/log.rb +34 -0
- data/lib/rflow/daemon_process.rb +15 -4
- data/lib/rflow/version.rb +1 -1
- data/rflow.gemspec +1 -0
- data/schema/log.avsc +11 -0
- data/spec/rflow/message/data/log_spec.rb +42 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b847e06bbad6d47e7cd74314add6f499c99c8bc9
|
4
|
+
data.tar.gz: f707f01ec81e823d8c08711bf747f1a57b6a15a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5791ba65d956750314d374c00fb21bafcaa152a356331d41134929befaf9488f7519da287b796833430300f5f5aafb892465648ee54a6b8acdc3c1503181427
|
7
|
+
data.tar.gz: bf9ebdb5eac95bd3307f86b54d23b872cd6365fd32db98daa962cd5c109f404c8bf3a9d3ebcc36d5b0c12fb7223b1c8d55b61e62678484fd12f5ca6292ac58e4
|
data/bin/rflow
CHANGED
@@ -4,6 +4,11 @@
|
|
4
4
|
# startup cases (version and help) that don't need it
|
5
5
|
require 'optparse'
|
6
6
|
|
7
|
+
if Process::Sys.geteuid == 0
|
8
|
+
STDERR.puts "Error: RFlow will not run as root."
|
9
|
+
exit 1
|
10
|
+
end
|
11
|
+
|
7
12
|
options = {
|
8
13
|
:daemonize => true,
|
9
14
|
:startup_log_level => :INFO,
|
@@ -186,17 +191,22 @@ end
|
|
186
191
|
options[:extensions_file_paths].each do |extensions_file_path|
|
187
192
|
RFlow.logger.info "Loading #{extensions_file_path}"
|
188
193
|
unless File.readable? extensions_file_path
|
189
|
-
RFlow.logger.fatal "Extensions file ('#{Dir.getwd}') '#{extensions_file_path}' not
|
194
|
+
RFlow.logger.fatal "Extensions file ('#{Dir.getwd}') '#{extensions_file_path}' not readable\n#{option_parser.help}"
|
195
|
+
exit 1
|
196
|
+
end
|
197
|
+
begin
|
198
|
+
load extensions_file_path
|
199
|
+
rescue Exception => e
|
200
|
+
RFlow.logger.fatal "Error running rflow: #{e.class}: #{e.message}, because: #{e.backtrace}"
|
190
201
|
exit 1
|
191
202
|
end
|
192
|
-
load extensions_file_path
|
193
203
|
end
|
194
204
|
|
195
205
|
# Start the flow
|
196
206
|
begin
|
197
207
|
RFlow.run! options[:config_database_path], options[:daemonize]
|
198
208
|
rescue Exception => e
|
199
|
-
RFlow.logger.fatal "Error running rflow: #{e.class}: #{e.message}"
|
209
|
+
RFlow.logger.fatal "Error running rflow: #{e.class}: #{e.message}, because: #{e.backtrace}"
|
200
210
|
exit(1)
|
201
211
|
end
|
202
212
|
|
data/example/http_extensions.rb
CHANGED
@@ -102,7 +102,7 @@ class HTTPServer < RFlow::Component
|
|
102
102
|
return unless message.data_type_name == 'HTTPResponse'
|
103
103
|
|
104
104
|
RFlow.logger.debug 'Received a HTTPResponse message, determining if its mine'
|
105
|
-
my_events = message.provenance.find_all {|processing_event| processing_event.component_instance_uuid ==
|
105
|
+
my_events = message.provenance.find_all {|processing_event| processing_event.component_instance_uuid == uuid}
|
106
106
|
RFlow.logger.debug "Found #{my_events.size} processing events from me"
|
107
107
|
|
108
108
|
# Attempt to send the data to each context match
|
@@ -136,7 +136,7 @@ class HTTPServer < RFlow::Component
|
|
136
136
|
def process_http_request
|
137
137
|
RFlow.logger.debug "Received a full HTTP request from #{client_ip}:#{client_port}"
|
138
138
|
|
139
|
-
processing_event = RFlow::Message::ProcessingEvent.new(server.
|
139
|
+
processing_event = RFlow::Message::ProcessingEvent.new(server.uuid, Time.now.utc)
|
140
140
|
|
141
141
|
request_message = RFlow::Message.new('HTTPRequest')
|
142
142
|
request_message.data.path = @http_request_uri
|
data/lib/rflow/components.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
class RFlow
|
2
|
+
module Components
|
3
|
+
module Log
|
4
|
+
module Extensions
|
5
|
+
module LogExtension
|
6
|
+
def self.extended(base_data)
|
7
|
+
base_data.data_object ||= {'timestamp' => 0, 'level' => 'INFO', 'text' => ''}
|
8
|
+
end
|
9
|
+
|
10
|
+
def timestamp; data_object['timestamp']; end
|
11
|
+
def timestamp=(new_timestamp); data_object['timestamp'] = new_timestamp; end
|
12
|
+
def level; data_object['level']; end
|
13
|
+
def level=(new_level); data_object['level'] = new_level; end
|
14
|
+
def text; data_object['text']; end
|
15
|
+
def text=(new_text); data_object['text'] = new_text; end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
SCHEMA_DIRECTORY = ::File.expand_path(::File.join(::File.dirname(__FILE__), '..', '..', '..', 'schema'))
|
20
|
+
|
21
|
+
SCHEMA_FILES = {
|
22
|
+
'log.avsc' => 'RFlow::Message::Data::Log',
|
23
|
+
}
|
24
|
+
|
25
|
+
SCHEMA_FILES.each do |file_name, data_type_name|
|
26
|
+
schema_string = ::File.read(::File.join(SCHEMA_DIRECTORY, file_name))
|
27
|
+
RFlow::Configuration.add_available_data_type data_type_name, 'avro', schema_string
|
28
|
+
end
|
29
|
+
|
30
|
+
RFlow::Configuration.add_available_data_extension('RFlow::Message::Data::Log',
|
31
|
+
RFlow::Components::Log::Extensions::LogExtension)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/rflow/daemon_process.rb
CHANGED
@@ -111,9 +111,15 @@ class RFlow
|
|
111
111
|
|
112
112
|
def handle_signals
|
113
113
|
['SIGTERM', 'SIGINT', 'SIGQUIT', 'SIGCHLD'].each do |signal|
|
114
|
-
trap_signal(signal) do
|
114
|
+
trap_signal(signal) do |return_code|
|
115
|
+
exit_status = if signal == 'SIGCHLD'
|
116
|
+
pid, status = Process.wait2
|
117
|
+
status.exitstatus
|
118
|
+
else
|
119
|
+
0
|
120
|
+
end
|
115
121
|
shutdown! signal
|
116
|
-
exit!
|
122
|
+
exit! exit_status
|
117
123
|
end
|
118
124
|
end
|
119
125
|
|
@@ -136,11 +142,12 @@ class RFlow
|
|
136
142
|
|
137
143
|
def trap_signal(signal)
|
138
144
|
# Log4r and traps don't mix, so we need to put it in another thread
|
145
|
+
return_code = $?
|
139
146
|
context = clone_logging_context
|
140
147
|
Signal.trap signal do
|
141
148
|
Thread.new do
|
142
149
|
apply_logging_context context
|
143
|
-
yield
|
150
|
+
yield return_code
|
144
151
|
end.join
|
145
152
|
end
|
146
153
|
end
|
@@ -155,7 +162,11 @@ class RFlow
|
|
155
162
|
def signal_subprocesses(signal)
|
156
163
|
subprocesses.reject {|p| p.pid.nil? }.each do |p|
|
157
164
|
RFlow.logger.info "Signaling #{p.name} with #{signal}"
|
158
|
-
|
165
|
+
begin
|
166
|
+
Process.kill(signal, p.pid)
|
167
|
+
rescue Errno::ESRCH
|
168
|
+
# process already died and was waited for, ignore
|
169
|
+
end
|
159
170
|
end
|
160
171
|
end
|
161
172
|
|
data/lib/rflow/version.rb
CHANGED
data/rflow.gemspec
CHANGED
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
19
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
20
20
|
s.require_paths = ['lib']
|
21
|
+
s.bindir = 'bin'
|
21
22
|
|
22
23
|
s.add_dependency 'uuidtools', '~> 2.1'
|
23
24
|
s.add_dependency 'log4r', '~> 1.1'
|
data/schema/log.avsc
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rflow/components/log'
|
3
|
+
|
4
|
+
class RFlow
|
5
|
+
class Message
|
6
|
+
class Data
|
7
|
+
describe 'Log Avro Schema' do
|
8
|
+
let(:schema) { Configuration.available_data_types['RFlow::Message::Data::Log']['avro'] }
|
9
|
+
|
10
|
+
it 'should load the schema' do
|
11
|
+
expect(schema).not_to be_nil
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should support assignment of properties' do
|
15
|
+
message = RFlow::Message.new('RFlow::Message::Data::Log')
|
16
|
+
timestamp = Time.now.to_i
|
17
|
+
message.data.timestamp = timestamp
|
18
|
+
message.data.level = 'INFO'
|
19
|
+
message.data.text = 'message'
|
20
|
+
|
21
|
+
result = decode_avro(schema, encode_avro(schema, message.data.to_hash))
|
22
|
+
expect(result['timestamp']).to eq timestamp
|
23
|
+
expect(result['level']).to eq 'INFO'
|
24
|
+
expect(result['text']).to eq 'message'
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should encode and decode an object' do
|
28
|
+
log = {'timestamp' => Time.now.to_i, 'level' => 'LOGLEVEL', 'text' => 'Log message'}
|
29
|
+
|
30
|
+
expect { encode_avro(schema, log) }.to_not raise_error
|
31
|
+
encoded = encode_avro(schema, log)
|
32
|
+
|
33
|
+
expect { decode_avro(schema, encoded) }.to_not raise_error
|
34
|
+
decoded = decode_avro(schema, encoded)
|
35
|
+
|
36
|
+
expect(decoded).to eq(log)
|
37
|
+
expect(decoded['text']).to eq(log['text'])
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Stoneham
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-08-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: uuidtools
|
@@ -215,6 +215,7 @@ files:
|
|
215
215
|
- lib/rflow/components.rb
|
216
216
|
- lib/rflow/components/clock.rb
|
217
217
|
- lib/rflow/components/integer.rb
|
218
|
+
- lib/rflow/components/log.rb
|
218
219
|
- lib/rflow/components/raw.rb
|
219
220
|
- lib/rflow/components/replicate.rb
|
220
221
|
- lib/rflow/components/ruby_proc_filter.rb
|
@@ -242,6 +243,7 @@ files:
|
|
242
243
|
- lib/rflow/shard.rb
|
243
244
|
- lib/rflow/version.rb
|
244
245
|
- rflow.gemspec
|
246
|
+
- schema/log.avsc
|
245
247
|
- schema/message.avsc
|
246
248
|
- schema/raw.avsc
|
247
249
|
- schema/tick.avsc
|
@@ -253,6 +255,7 @@ files:
|
|
253
255
|
- spec/rflow/forward_to_input_port_spec.rb
|
254
256
|
- spec/rflow/forward_to_output_port_spec.rb
|
255
257
|
- spec/rflow/logger_spec.rb
|
258
|
+
- spec/rflow/message/data/log_spec.rb
|
256
259
|
- spec/rflow/message/data/raw_spec.rb
|
257
260
|
- spec/rflow/message/data_spec.rb
|
258
261
|
- spec/rflow/message_spec.rb
|
@@ -278,7 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
278
281
|
version: '0'
|
279
282
|
requirements: []
|
280
283
|
rubyforge_project:
|
281
|
-
rubygems_version: 2.
|
284
|
+
rubygems_version: 2.2.2
|
282
285
|
signing_key:
|
283
286
|
specification_version: 4
|
284
287
|
summary: A Ruby flow-based programming framework
|
@@ -291,9 +294,9 @@ test_files:
|
|
291
294
|
- spec/rflow/forward_to_input_port_spec.rb
|
292
295
|
- spec/rflow/forward_to_output_port_spec.rb
|
293
296
|
- spec/rflow/logger_spec.rb
|
297
|
+
- spec/rflow/message/data/log_spec.rb
|
294
298
|
- spec/rflow/message/data/raw_spec.rb
|
295
299
|
- spec/rflow/message/data_spec.rb
|
296
300
|
- spec/rflow/message_spec.rb
|
297
301
|
- spec/rflow_spec.rb
|
298
302
|
- spec/spec_helper.rb
|
299
|
-
has_rdoc:
|