Created
April 13, 2012 14:47
-
-
Save kornypoet/2377390 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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