Skip to content

Instantly share code, notes, and snippets.

@kornypoet
Created April 13, 2012 14:47
Show Gist options
  • Save kornypoet/2377390 to your computer and use it in GitHub Desktop.
Save kornypoet/2377390 to your computer and use it in GitHub Desktop.
# The way a wukong script is written regularly:
require 'wukong'
class WukongToFlume < Wukong::Streamer::LineStreamer
def process(body, *args)
# take input, do some processing
processed = body.to_s.reverse
yield [processed]
end
end
Wukong::Script.new(WukongToFlume, nil).run
# Now turn it into a jRuby decorator:
require 'wukong'
# The name of your class must be the camelized file name wukong_to_flume.rb => WukongToFlume
class WukongToFlume < Wukong::Streamer::LineStreamer
# Make sure process method handles *args; expect first to be a String containing event body
def process(body, *args)
# take input, do some processing
processed = body.to_s.reverse
# change yield to return, and make sure to return ONLY an array of strings
# yield [processed]
return [processed]
end
end
# Run line needs to be commented out
# Wukong::Script.new(WukongToFlume, nil).run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment