Yoji Shidara
null+****@clear*****
Thu Jan 30 17:40:30 JST 2014
Yoji Shidara 2014-01-30 17:40:30 +0900 (Thu, 30 Jan 2014) New Revision: 3533d11bb1fb65dc6003a81c53dd4562e2caa710 https://github.com/droonga/droonga.org/commit/3533d11bb1fb65dc6003a81c53dd4562e2caa710 Message: Describe how to add an empty InputAdapterPlugin Modified files: tutorial/plugin-development/index.md Modified: tutorial/plugin-development/index.md (+61 -0) =================================================================== --- tutorial/plugin-development/index.md 2014-01-30 16:26:25 +0900 (5e40b42) +++ tutorial/plugin-development/index.md 2014-01-30 17:40:30 +0900 (7c3621b) @@ -12,6 +12,9 @@ layout: en Learning steps to develop a Droonga plugin by yourself. +## Precondition + +* You must complete [tutorial][]. ## Plugin @@ -46,4 +49,62 @@ CollectorPlugin In this tutorial, we focus on InputAdapterPlugin. This is the most "basic" plugin, so it will help you to understand the overview of Droonga plugin development. + +## Directory Structure + +Assume that we are going to add `InputAdapterPlugin` to the system built in [tutorial][]. In that tutorial, Groonga engine was placed under `engine` directory. + +Plugins need to be placed in an appropriate directory. For example, `InputAdapterPlugin` should be placed under `lib/droonga/plugin/input_adapter/` directory. Let's create the directory: + + # cd engine + # mkdir -p lib/droonga/plugin/input_adapter + +After creating the directory, the directory structure should be like this: + +``` +engine +├── catalog.json +├── fluentd.conf +└── lib + └── droonga + └── plugin + └── input_adapter +``` + +Put a plugin code into `input_adapter` plugin. + +lib/droonga/plugin/input_adapter/example.rb: + +```ruby +module Droonga + class ExampleInputAdapter < Droonga::InputAdapterPlugin + repository.register("example", self) + end +end +``` + +This plugin does nothing except registering itself to Droonga. + +You need to update `catalog.json` to activate your plugin: + +catalog.json: +``` +(snip) + }, + "options": { + "plugins": ["example"] + } +} +``` + +Add `"example"` to `"plugins"` section. + +Let's Droonga get started. Note that you need to specify `./lib` directory in `RUBYLIB` environment variable in order to make ruby possible to find your plugin. + +``` +RUBYLIB=./lib fluentd --config fluentd.conf +``` + + + [tutorial]: ../ [overview]: ../../overview/ -------------- next part -------------- HTML����������������������������... Download