wukong-storm 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,58 +0,0 @@
1
- module Wukong
2
- module Storm
3
-
4
- # A driver to connect events passed in over STDIN to STDOUT.
5
- # Differs from the vanilla Wukong::Local::LocalDriver in some
6
- # Storm-specific ways.
7
- class StormDriver < EM::P::LineAndTextProtocol
8
- include DriverMethods
9
-
10
- attr_accessor :dataflow, :settings
11
-
12
- def self.start(label, settings = {})
13
- EM.attach($stdin, self, label, settings)
14
- end
15
-
16
- def initialize(label, settings)
17
- super
18
- @settings = settings
19
- @dataflow = construct_dataflow(label, settings)
20
- @messages = []
21
- end
22
-
23
- def post_init
24
- setup_dataflow
25
- end
26
-
27
- def receive_line line
28
- driver.send_through_dataflow(line)
29
- send_messages
30
- rescue => e
31
- raise Wukong::Error.new(e)
32
- EM.stop
33
- end
34
-
35
- def send_messages
36
- # message newline message newline message delimiter
37
- # message newline message newline message newline delimiter newline
38
- @messages.each do |message|
39
- $stdout.write(message)
40
- $stdout.write("\n")
41
- end
42
- $stdout.write(settings.delimiter)
43
- $stdout.write("\n")
44
- $stdout.flush
45
- @messages.clear
46
- end
47
-
48
- def unbind
49
- EM.stop
50
- end
51
-
52
- def setup() ; end
53
- def process(record) @messages << record ; end
54
- def stop() ; end
55
-
56
- end
57
- end
58
- end
@@ -1,40 +0,0 @@
1
- require_relative('driver')
2
-
3
- module Wukong
4
- module Storm
5
-
6
- # Implements the runner for wu-storm.
7
- class StormRunner < Wukong::Local::LocalRunner
8
-
9
- include Wukong::Logging
10
-
11
- usage "PROCESSOR|FLOW"
12
-
13
- description <<-EOF.gsub(/^ {8}/,'')
14
- wu-storm is a commandline tool for running Wukong processors and flows
15
- in a storm or trident topology.
16
-
17
- wu-storm operates over STDIN and STDOUT and has a one-to-one message
18
- guarantee. For example, when using an identity processor, wu-storm,
19
- given an event 'foo', will return 'foo|'. The '|' character is the
20
- specified End-Of-File delimiter.
21
-
22
- If there is ever a suppressed error in pricessing, or a skipped record
23
- for any reason, wu-storm will still respond with a '|', signifying an
24
- empty return event.
25
-
26
- If there are multiple messages that have resulted from a single event,
27
- wu-storm will return them newline separated, followed by the
28
- delimiter, e.g. 'foo\nbar\nbaz|'.
29
- EOF
30
-
31
- # :nodoc:
32
- def driver
33
- StormDriver
34
- end
35
-
36
- end
37
- end
38
- end
39
-
40
-