YUKI Hiroshi
null+****@clear*****
Thu Feb 20 12:29:30 JST 2014
YUKI Hiroshi 2014-02-20 12:29:30 +0900 (Thu, 20 Feb 2014) New Revision: 0d717da0c7adf1d262bde0189f523a64b3c0895f https://github.com/droonga/droonga.org/commit/0d717da0c7adf1d262bde0189f523a64b3c0895f Message: Link to the reference manual from the plugin development tutorial Modified files: tutorial/plugin-development/adapter/index.md Modified: tutorial/plugin-development/adapter/index.md (+22 -3) =================================================================== --- tutorial/plugin-development/adapter/index.md 2014-02-20 11:33:58 +0900 (836becf) +++ tutorial/plugin-development/adapter/index.md 2014-02-20 12:29:30 +0900 (c307303) @@ -200,8 +200,15 @@ lib/droonga/plugins/sample-logger.rb: (snip) ~~~ +The line beginning with `input_message.pattern` is a configuration. +This example defines a plugin for any incoming message with `"type":"search"`. +See the [reference manual's configuration section](../../../reference/plugin/adapter/#config) + (Note: `input_message.pattern` is for Droonga 1.0.0 and later. On Droonga 0.9.9, you have to use a deprecated configuration `message.input_pattern` instead.) +The method `adapt_input` is called for every incoming message matching to the pattern. +The argument `input_message` is a wrapped version of the incoming message. + Restart fluentd: ~~~ @@ -248,7 +255,9 @@ This shows the message is received by our `SampleLoggerPlugin::Adapter` and then ### Modify messages with the plugin -Suppose that we want to restrict the number of records returned in the response, say `1`. What we need to do is set `limit` to be `1` for every request. Update plugin like below: +Suppose that we want to restrict the number of records returned in the response, say `1`. +What we need to do is set `limit` to be `1` for every request. +Update plugin like below: lib/droonga/plugins/sample-logger.rb: @@ -261,6 +270,9 @@ lib/droonga/plugins/sample-logger.rb: (snip) ~~~ +Like above, you can modify the incoming message via methods of the argument `input_message`. +See the [reference manual for the message class](../../../reference/plugin/adapter/#classes-Droonga-InputMessage). + Restart fluentd: ~~~ @@ -323,9 +335,10 @@ lib/droonga/plugins/sample-logger.rb: (snip) module SampleLoggerPlugin Plugin.registry.register("sample-logger", self) - (snip) class Adapter < Droonga::Adapter + (snip) + def adapt_output(output_message) $log.info("SampleLoggerPlugin::Adapter", :message => output_message) end @@ -334,6 +347,9 @@ lib/droonga/plugins/sample-logger.rb: (snip) ~~~ +The method `adapt_output` is called only for outgoing messages triggered by incoming messages processed by the plugin itself. +See the [reference manual for plugin developers](../../../reference/plugin/adapter/) for more details. + ### Run Let's restart fluentd: @@ -398,6 +414,9 @@ lib/droonga/plugins/sample-logger.rb: (snip) ~~~ +Like above, you can modify the outgoing message via methods of the argument `output_message`. +See the [reference manual for the message class](../../../reference/plugin/adapter/#classes-Droonga-OutputMessage). + Restart fluentd: ~~~ @@ -658,7 +677,7 @@ In the way just described, we can use adapter to implement the application speci ## Conclusion -We have learned how to create an addon working around the adaption phase, how to receive and modify messages, both of incoming and outgoing. +We have learned how to create an addon working around the adaption phase, how to receive and modify messages, both of incoming and outgoing. See also the [reference manual](../../../reference/plugin/adapter/) for more details. [basic tutorial]: ../../basic/ -------------- next part -------------- HTML����������������������������...Download