YUKI Hiroshi
null+****@clear*****
Fri Feb 28 16:02:20 JST 2014
YUKI Hiroshi 2014-02-28 16:02:20 +0900 (Fri, 28 Feb 2014) New Revision: 8942d12dae8dc46b61464269db622ac5a2bfb2b3 https://github.com/droonga/droonga.org/commit/8942d12dae8dc46b61464269db622ac5a2bfb2b3 Message: Update descriptions around handler plugin Modified files: reference/plugin/handler/index.md Modified: reference/plugin/handler/index.md (+12 -8) =================================================================== --- reference/plugin/handler/index.md 2014-02-28 16:01:02 +0900 (d1bdddb) +++ reference/plugin/handler/index.md 2014-02-28 16:02:20 +0900 (a49f8f1) @@ -10,7 +10,7 @@ layout: en ## Abstract {#abstract} Each Droonga Engine plugin can have its *handler*. -On the handling phase, handlers can process any incoming message and output various messages (ex. a "response" for a "request") as you like. +On the handling phase, handlers can process a request and return a result. ### How to define a handler? {#howto-define} @@ -21,14 +21,18 @@ For example, here is a sample plugin named "foo" with a handler: require "droonga/plugin" module Droonga::Plugins::FooPlugin - Plugin.registry.register("foo", self) + extend Plugin + register("foo") - class Handler < Droonga::Handler - # operations to configure this handler - XXXXXX = XXXXXX + define_single_step do |step| + step.name = "foo" + step.handler = :Handler + step.collector = Collectors::And + end - def handle(message, messenger) - # operations to process incoming messages + class Handler < Droonga::Handler + def handle(message) + # operations to process a request end end end @@ -37,8 +41,8 @@ end Steps to define a handler: 1. Define a module for your plugin (ex. `Droonga::Plugins::FooPlugin`) and register it as a plugin. (required) + 2. Define a "single step" corresponding to the Configure conditions for the handler. (required) 2. Define a handler class (ex. `Droonga::Plugins::FooPlugin::Handler`) inheriting [`Droonga::Handler`](#classes-Droonga-Handler). (required) - 3. [Configure conditions for the handler](#howto-configure). (required) 4. Define handling logic for incoming messages as [`#handle`](#classes-Droonga-Handler-handle). (optional) See also the [plugin development tutorial](../../../tutorial/plugin-development/handler/). -------------- next part -------------- HTML����������������������������... Download