Sha256: 338668ecc788e694185fb6ae7742158b9b3ce7b921cffff922584b230f53b6ca

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

#!/usr/bin/env ruby
require 'wukong-storm'
require 'configliere'

Settings.use(:commandline)
Settings.define :run,       description: 'Name of the processor or dataflow to use. Defaults to basename of the given path', flag: 'r'
Settings.define :delimiter, description: 'The EOF specifier when returning events', default: '|',                            flag: 't'

def Settings.usage() "usage: #{File.basename($0)} PROCESSOR|FLOW [...--param=value...]" ; end
  
Settings.description = <<'EOF'
wu-storm is a commandline tool for running Wukong processors and flows in
a storm or trident topology.

wu-storm operates over STDIN and STDOUT and has a one-to-one message guarantee.
For example, when using an identity processor, wu-storm, given an event 'foo', will return
'foo|'. The '|' character is the specified End-Of-File delimiter. 

If there is ever a suppressed error in pricessing, or a skipped record for any reason,
wu-storm will still respond with a '|', signifying an empty return event.

If there are multiple messages that have resulted from a single event, wu-storm will return
them newline separated, followed by the delimite, e.g. 'foo\nbar\nbaz|'.
EOF

Settings.resolve!

runnable = Settings.rest.first

case
when runnable.nil?
  Settings.dump_help
  exit(1)  
when Wukong.registry.registered?(runnable.to_sym)
  processor = runnable
when File.exist?(runnable)
  load runnable
  processor = Settings.run || File.basename(runnable, '.rb')
else
  Settings.dump_help
  exit(1)
end

begin
  EM.run do
    Wu::StormRunner.start(processor.to_sym, Settings)
  end
rescue Wu::Error => e
  $stderr.puts e.message
  exit(1)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wukong-storm-0.0.1 bin/wu-storm