Navigation Menu

Skip to content

Commit

Permalink
Link to the reference manual from the plugin development tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Feb 20, 2014
1 parent 5dfe123 commit 0d717da
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions tutorial/plugin-development/adapter/index.md
Expand Up @@ -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:

~~~
Expand Down Expand Up @@ -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:

Expand All @@ -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:

~~~
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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:

~~~
Expand Down Expand Up @@ -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/
Expand Down

0 comments on commit 0d717da

Please sign in to comment.