#!/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 require 'wukong/boot' Wukong.boot!(Settings) 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