[Groonga-commit] droonga/droonga.org at 17b4d18 [gh-pages] Write abstract for plugin API reference about adaption phase

Back to archive index

YUKI Hiroshi null+****@clear*****
Mon Feb 17 15:53:18 JST 2014


YUKI Hiroshi	2014-02-17 15:53:18 +0900 (Mon, 17 Feb 2014)

  New Revision: 17b4d181cffff726995be83a3bef83b82fb5ef1f
  https://github.com/droonga/droonga.org/commit/17b4d181cffff726995be83a3bef83b82fb5ef1f

  Message:
    Write abstract for plugin API reference about adaption phase

  Added files:
    reference/plugin/adapter/index.md

  Added: reference/plugin/adapter/index.md (+135 -0) 100644
===================================================================
--- /dev/null
+++ reference/plugin/adapter/index.md    2014-02-17 15:53:18 +0900 (ca71723)
@@ -0,0 +1,135 @@
+---
+title: API set for plugins on the adaption phase
+layout: en
+---
+
+* TOC
+{:toc}
+
+
+## Abstract {#abstract}
+
+On the adaption phase, plugins can modify both incoming messages (from the Protocol Adapter to the Droonga Engine, in other words, they are "request"s) and outgoing messages (from the Droonga Engine to the Protocol Adapter, in other words, they are "response"s).
+
+
+## How to define a behavior on the adaption phase? {#howto-define}
+
+For example, here is a sample plugin named "foo":
+
+~~~ruby
+require "droonga/plugin"
+
+module Droonga
+  module Plugins
+    module FooPlugin
+      Plugin.registry.register("foo", self)
+
+      class Adapter < Droonga::Adapter
+        # operations to configure this behavior
+        message.XXXXXX = XXXXXX
+
+        def adapt_input(input_message)
+          # operations to modify incoming messages
+          input_message.XXXXXX = XXXXXX
+        end
+
+        def adapt_output(output_message)
+          # operations to modify outgoing messages
+          output_message.XXXXXX = XXXXXX
+        end
+      end
+    end
+  end
+end
+~~~
+
+Steps to define the behavior on the adaptions phase are:
+
+ 1. Define the module `FooPlugin` and register it as a plugin. (required)
+ 2. Define the class `FooPlugin::Adapter` as a sub class of `Droonga::Adapter`. (required)
+ 3. Configure conditions to apply the plugin. (required)
+ 4. Define adaption logic for incoming messages. (optional)
+ 5. Define adaption logic for outgoing messages. (optional)
+
+For more details, see also the [plugin development tutorial](../../../tutorial/plugin-development/adapter/).
+
+
+## How works a plugin on the adaption phase? {#how-works}
+
+ 1. The Droonga Engine starts.
+    * A global instance of the plugin (ex. `FooPlugin::Adapter`) is created and it is registered.
+    * The Droonga Engine starts to wait for incoming messages.
+ 2. An incoming message is transferred from the Protocol Adapter to the Droonga Engine.
+    Then, the adaption phase (for an incoming message) starts.
+    * The instance of the plugin's `adapt_input` method is called, if the message matches to the input pattern of the plugin.
+    * The method can modify the given incoming message.
+ 3. After all plugins are applied, the adaption phase for an incoming message ends, and the incoming message is transferred to the next "planning" phase.
+ 4. An outgoing message returns from the previous "collection" phase.
+    Then, the adaption phase (for an outgoing message) starts.
+    * The instance of the plugin's `adapt_output` method is called, if the corresponding incoming message was processed by the plugin and the outgoing message matches to the output pattern of the plugin.
+    * The method can modify the given outgoing message.
+ 5. After all plugins are applied, the adaption phase for an outgoing message ends, and the outgoing message is transferred to the Protocol Adapter.
+
+
+## Classes {#classes}
+
+(under construction)
+
+### `Droonga::Adapter` {#classes-Droonga-Adapter}
+
+(under construction)
+
+#### `.message` {#classes-Droonga-Adapter-class-message}
+
+(under construction)
+
+#### `#adapt_input` {#classes-Droonga-Adapter-adapt_input}
+
+(under construction)
+
+#### `#adapt_output` {#classes-Droonga-Adapter-adapt_output}
+
+(under construction)
+
+### `Droonga::Plugin::Metadata::AdapterMessage` {#classes-Droonga-Plugin-Metadata-AdapterMessage}
+
+(under construction)
+
+#### `#input_pattern` {#classes-Droonga-Plugin-Metadata-AdapterMessage-input_pattern}
+
+(under construction)
+
+#### `#output_pattern` {#classes-Droonga-Plugin-Metadata-AdapterMessage-output_pattern}
+
+(under construction)
+
+### `Droonga::InputMessage` {#classes-Droonga-InputMessage}
+
+(under construction)
+
+#### `#command` {#classes-Droonga-InputMessage-command}
+
+(under construction)
+
+#### `#body` {#classes-Droonga-InputMessage-body}
+
+(under construction)
+
+### `Droonga::OutputMessage` {#classes-Droonga-OutputMessage}
+
+(under construction)
+
+#### `#status_code` {#classes-Droonga-OutputMessage-status_code}
+
+(under construction)
+
+#### `#errors` {#classes-Droonga-OutputMessage-errors}
+
+(under construction)
+
+#### `#body` {#classes-Droonga-OutputMessage-body}
+
+(under construction)
+
+
+
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index