Yoji Shidara
null+****@clear*****
Wed Feb 5 16:45:06 JST 2014
Yoji Shidara 2014-02-05 16:45:06 +0900 (Wed, 05 Feb 2014) New Revision: 41aacf2ca0d25ae949678d3f217d9d7bf962e09b https://github.com/droonga/droonga.org/commit/41aacf2ca0d25ae949678d3f217d9d7bf962e09b Message: Write OutputAdapter instructions Modified files: tutorial/plugin-development/input-output/index.md Modified: tutorial/plugin-development/input-output/index.md (+84 -0) =================================================================== --- tutorial/plugin-development/input-output/index.md 2014-02-05 16:13:57 +0900 (80c752d) +++ tutorial/plugin-development/input-output/index.md 2014-02-05 16:45:06 +0900 (b4366db) @@ -215,7 +215,91 @@ Note that `count` is still `2` because `limit` does not affect `count`. See [sea ## OutputAdapter +In this section, we are going to create an `OutputAdapter`. +### Directory structure + +`OutputAdapterPlugin` should be placed in directory `lib/droonga/plugin/output_adapter/` directory. + +~~~ +engine +├── catalog.json +├── fluentd.conf +└── lib + └── droonga + └── plugin + └── output_adapter +~~~ + + +### Create a plugin + +Put a plugin code into `output_adapter` directory. + +lib/droonga/plugin/output_adapter/example.rb: + +~~~ruby +module Droonga + class ExampleOutputAdapterPlugin < Droonga::OutputAdapterPlugin + repository.register("example", self) + end +end +~~~ + +This plugin does nothing except registering itself to Droonga. + +### Activate plugin with `catalog.json` + +You need to update `catalog.json` to activate your plugin. +Insert following at the last part of `catalog.json` in order to make `"output_adapter"` become a key of the top level hash: + +catalog.json: + +~~~ +(snip) + }, + "input_adapter": { + "plugins": ["example", "groonga"] + }, + "output_adapter": { + "plugins": ["example", "crud", "groonga"] + }, + "collector": { + "plugins": ["basic", "search"] + }, + "distributor": { + "plugins": ["search", "crud", "groonga", "watch"] + } +} +~~~ + +### Run + +Let's get fluentd started: + +~~~ +RUBYLIB=./lib fluentd --config fluentd.conf +~~~ + +We expect that nothing should be changed. + +### Log messages incoming to OutputAdapter + +~~~ +module Droonga + class ExampleOutputAdapterPlugin < Droonga::OutputAdapterPlugin + repository.register("example", self) + + command "search" => :adapt_result, + :patterns => [["replyTo.type", :equal, "search.result"]] + def adapt_result(output_message) + $log.info "ExampleOutputAdapterPlugin", :message => output_message + end + end +end +~~~ + +### Modify results with OutputAdapter [tutorial]: ../../ [overview]: ../../../overview/ -------------- next part -------------- HTML����������������������������...Download