Skip to content

Commit

Permalink
Update descriptions around handler plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Feb 28, 2014
1 parent e3472eb commit 8942d12
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions reference/plugin/handler/index.md
Expand Up @@ -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}
Expand All @@ -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
Expand All @@ -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/).
Expand Down

0 comments on commit 8942d12

Please sign in to comment.