[Groonga-commit] droonga/droonga.org at ec562a3 [gh-pages] Add sub pages of plugin API reference in Japanese

Back to archive index

YUKI Hiroshi null+****@clear*****
Mon Feb 17 20:20:48 JST 2014


YUKI Hiroshi	2014-02-17 20:20:48 +0900 (Mon, 17 Feb 2014)

  New Revision: ec562a31f8ac2b1fd3598ab945afc869a4278f77
  https://github.com/droonga/droonga.org/commit/ec562a31f8ac2b1fd3598ab945afc869a4278f77

  Message:
    Add sub pages of plugin API reference in Japanese

  Added files:
    _po/ja/reference/plugin/adapter/index.po
    _po/ja/reference/plugin/error/index.po
    _po/ja/reference/plugin/matching-pattern/index.po
    ja/reference/plugin/adapter/index.md
    ja/reference/plugin/error/index.md
    ja/reference/plugin/matching-pattern/index.md
  Modified files:
    _po/ja/reference/plugin/index.po
    ja/reference/index.md
    ja/reference/plugin/index.md

  Added: _po/ja/reference/plugin/adapter/index.po (+268 -0) 100644
===================================================================
--- /dev/null
+++ _po/ja/reference/plugin/adapter/index.po    2014-02-17 20:20:48 +0900 (f339b1c)
@@ -0,0 +1,268 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2011-11-20 22:17+0900\n"
+"PO-Revision-Date: 2013-12-25 18:27+0900\n"
+"Last-Translator: Kouhei Sutou <kou �� clear-code.com>\n"
+"Language-Team: Japanese\n"
+"Language: ja\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=1; plural=0;\n"
+
+msgid ""
+"---\n"
+"title: API set for plugins on the adaption phase\n"
+"layout: en\n"
+"---"
+msgstr ""
+"---\n"
+"title: AdaptionフェイズでのプラグインAPI\n"
+"layout: ja\n"
+"---"
+
+msgid ""
+"* TOC\n"
+"{:toc}"
+msgstr ""
+
+msgid "## Abstract {#abstract}"
+msgstr "## 概要 {#abstract}"
+
+msgid ""
+"Each Droonga Engine plugin can have its *adapter*. On the adaption phase, adap"
+"ters can modify both incoming messages (from the Protocol Adapter to the Droon"
+"ga Engine, in other words, they are \"request\"s) and outgoing messages (from th"
+"e Droonga Engine to the Protocol Adapter, in other words, they are \"response\"s"
+")."
+msgstr ""
+
+msgid "### How to define an adapter? {#howto-define}"
+msgstr ""
+
+msgid "For example, here is a sample plugin named \"foo\" with an adapter:"
+msgstr ""
+
+msgid ""
+"~~~ruby\n"
+"require \"droonga/plugin\""
+msgstr ""
+
+msgid ""
+"module Droonga\n"
+"  module Plugins\n"
+"    module FooPlugin\n"
+"      Plugin.registry.register(\"foo\", self)"
+msgstr ""
+
+msgid ""
+"      class Adapter < Droonga::Adapter\n"
+"        # operations to configure this adapter\n"
+"        message.XXXXXX = XXXXXX"
+msgstr ""
+
+msgid ""
+"        def adapt_input(input_message)\n"
+"          # operations to modify incoming messages\n"
+"          input_message.XXXXXX = XXXXXX\n"
+"        end"
+msgstr ""
+
+msgid ""
+"        def adapt_output(output_message)\n"
+"          # operations to modify outgoing messages\n"
+"          output_message.XXXXXX = XXXXXX\n"
+"        end\n"
+"      end\n"
+"    end\n"
+"  end\n"
+"end\n"
+"~~~"
+msgstr ""
+
+msgid "Steps to define an adapter:"
+msgstr ""
+
+msgid ""
+" 1. Define a module for your plugin (ex. `Droonga::Plugin::FooPlugin`) and reg"
+"ister it as a plugin. (required)\n"
+" 2. Define an adapter class (ex. `Droonga::Plugin::FooPlugin::Adapter`) inheri"
+"ting [`Droonga::Adapter`](#classes-Droonga-Adapter). (required)\n"
+" 3. [Configure conditions to apply the adapter](#howto-configure). (required)\n"
+" 4. Define adaption logic for incoming messages as [`#adapt_input`](#classes-D"
+"roonga-Adapter-adapt_input). (optional)\n"
+" 5. Define adaption logic for outgoing messages as [`#adapt_output`](#classes-"
+"Droonga-Adapter-adapt_output). (optional)"
+msgstr ""
+
+msgid ""
+"For more details, see also the [plugin development tutorial](../../../tutorial"
+"/plugin-development/adapter/)."
+msgstr ""
+
+msgid "### How an adapter works? {#how-works}"
+msgstr ""
+
+msgid "An adapter works like following:"
+msgstr ""
+
+msgid ""
+" 1. The Droonga Engine starts.\n"
+"    * A global instance of the adapter class (ex. `Droonga::Plugin::FooPlugin:"
+":Adapter`) is created and it is registered.\n"
+"      * The input pattern and the output pattern are registered.\n"
+"    * The Droonga Engine starts to wait for incoming messages.\n"
+" 2. An incoming message is transferred from the Protocol Adapter to the Droong"
+"a Engine.\n"
+"    Then, the adaption phase (for an incoming message) starts.\n"
+"    * The adapter's [`#adapt_input`](#classes-Droonga-Adapter-adapt_input) is "
+"called, if the message matches to the [input matching pattern](#config).\n"
+"    * The method can modify the given incoming message, via [its methods](#cla"
+"sses-Droonga-InputMessage).\n"
+" 3. After all adapters are applied, the adaption phase for an incoming message"
+" ends, and the message is transferred to the next \"planning\" phase.\n"
+" 4. An outgoing message returns from the previous \"collection\" phase.\n"
+"    Then, the adaption phase (for an outgoing message) starts.\n"
+"    * The adapter's [`#adapt_output`](#classes-Droonga-Adapter-adapt_output) i"
+"s called, if the corresponding incoming message was processed by the adapter a"
+"nd the outgoing message matches to the [output matching pattern](#config).\n"
+"    * The method can modify the given outgoing message, via [its methods](#cla"
+"sses-Droonga-OutputMessage).\n"
+" 5. After all adapters are applied, the adaption phase for an outgoing message"
+" ends, and the outgoing message is transferred to the Protocol Adapter."
+msgstr ""
+
+msgid ""
+"As described above, the Droonga Engine creates only one global instance of the"
+" adapter class for each plugin.\n"
+"You should not keep stateful information for a pair of incoming and outgoing m"
+"essages as an instance variable of the adapter.\n"
+"Instead, you should give stateful information as a part of the incoming messag"
+"e body, and receive it from the body of the corresponding outgoing message."
+msgstr ""
+
+msgid ""
+"Any error raised from the adapter is handled by the Droonga Engine itself. See"
+" also [error handling]."
+msgstr ""
+
+msgid "## Configurations {#config}"
+msgstr ""
+
+msgid ""
+"`input_message.pattern`\n"
+": A [matching pattern] for incoming messages.\n"
+"  Only messages matched to the given patten are processed by [`#adapt_input`]("
+"#classes-Droonga-Adapter-adapt_input)."
+msgstr ""
+
+msgid ""
+"`output_message.pattern`\n"
+": A [matching pattern] for outgoing messages.\n"
+"  Only messages matched to the given patten are processed by [`#adapt_output`]"
+"(#classes-Droonga-Adapter-adapt_output)."
+msgstr ""
+
+msgid "## Classes and methods {#classes}"
+msgstr ""
+
+msgid "### `Droonga::Adapter` {#classes-Droonga-Adapter}"
+msgstr ""
+
+msgid ""
+"This is the common base class of any adapter. Your plugin's adapter class must"
+" inherit the class."
+msgstr ""
+
+msgid "#### `#adapt_input(input_message)` {#classes-Droonga-Adapter-adapt_input}"
+msgstr ""
+
+msgid ""
+"Receives an instance of [`Droonga::InputMessage`](#classes-Droonga-InputMessag"
+"e) corresponding to an incoming message."
+msgstr ""
+
+msgid ""
+"By defualt this method does nothing, so you have to override it like following"
+":"
+msgstr ""
+
+msgid ""
+"~~~ruby\n"
+"module FooPlugin\n"
+"  class Adapter < Droonga::Adapter\n"
+"    def adapt_input(input_message)\n"
+"      input_message.body[\"query\"] = \"fixed query\"\n"
+"    end\n"
+"  end\n"
+"end\n"
+"~~~"
+msgstr ""
+
+msgid "#### `#adapt_output(output_message)` {#classes-Droonga-Adapter-adapt_output}"
+msgstr ""
+
+msgid ""
+"Receives an instance of [`Droonga::OutputMessage`](#classes-Droonga-InputMessa"
+"ge) corresponding to an outgoing message."
+msgstr ""
+
+msgid ""
+"~~~ruby\n"
+"module FooPlugin\n"
+"  class Adapter < Droonga::Adapter\n"
+"    def adapt_output(output_message)\n"
+"      output_message.status_code = StatusCode::OK\n"
+"    end\n"
+"  end\n"
+"end\n"
+"~~~"
+msgstr ""
+
+msgid ""
+"### `Droonga::Plugin::Metadata::AdapterMessage` {#classes-Droonga-Plugin-Metad"
+"ata-AdapterMessage}"
+msgstr ""
+
+msgid "(under construction)"
+msgstr ""
+
+msgid ""
+"#### `#input_pattern`, `#input_pattern=(pattern)` {#classes-Droonga-Plugin-Met"
+"adata-AdapterMessage-input_pattern}"
+msgstr ""
+
+msgid ""
+"#### `#output_pattern`, `#output_pattern=(pattern)` {#classes-Droonga-Plugin-M"
+"etadata-AdapterMessage-output_pattern}"
+msgstr ""
+
+msgid "### `Droonga::InputMessage` {#classes-Droonga-InputMessage}"
+msgstr ""
+
+msgid "#### `#command`, `#command=(command)` {#classes-Droonga-InputMessage-command}"
+msgstr ""
+
+msgid "#### `#body`, `#body=(body)` {#classes-Droonga-InputMessage-body}"
+msgstr ""
+
+msgid "### `Droonga::OutputMessage` {#classes-Droonga-OutputMessage}"
+msgstr ""
+
+msgid ""
+"#### `#status_code`, `#status_code=(status_code)` {#classes-Droonga-OutputMess"
+"age-status_code}"
+msgstr ""
+
+msgid "#### `#errors`, `#errors=(errors)` {#classes-Droonga-OutputMessage-errors}"
+msgstr ""
+
+msgid "#### `#body`, `#body=(body)` {#classes-Droonga-OutputMessage-body}"
+msgstr ""
+
+msgid ""
+"  [matching pattern]: ../matching-pattern/\n"
+"  [error handling]: ../error/"
+msgstr ""

  Added: _po/ja/reference/plugin/error/index.po (+125 -0) 100644
===================================================================
--- /dev/null
+++ _po/ja/reference/plugin/error/index.po    2014-02-17 20:20:48 +0900 (cb23636)
@@ -0,0 +1,125 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2011-11-20 22:17+0900\n"
+"PO-Revision-Date: 2013-12-25 18:27+0900\n"
+"Last-Translator: Kouhei Sutou <kou �� clear-code.com>\n"
+"Language-Team: Japanese\n"
+"Language: ja\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=1; plural=0;\n"
+
+msgid ""
+"---\n"
+"title: Error handling in plugins\n"
+"layout: en\n"
+"---"
+msgstr ""
+"---\n"
+"title: プラグインでのエラーの扱い\n"
+"layout: ja\n"
+"---"
+
+msgid ""
+"* TOC\n"
+"{:toc}"
+msgstr ""
+
+msgid "## Abstract {#abstract}"
+msgstr "## 概要 {#abstract}"
+
+msgid ""
+"Any unhandled error raised from a plugin is returned as an [error response][] "
+"for the corresponding incoming message, with the status code `500` (means \"int"
+"ernal error\")."
+msgstr ""
+
+msgid ""
+"If you want formatted error information to be returned, then rescue errors and"
+" raise your custom errors inheriting `Droonga::MessageProcessingError` instead"
+" of raw errors."
+msgstr ""
+
+msgid "## Built-in error classes {#builtin-errors}"
+msgstr ""
+
+msgid ""
+"There are some pre-defined error classes used by built-in plugins and the Droo"
+"nga Engine itself."
+msgstr ""
+
+msgid "### `Droonga::NotFound`"
+msgstr ""
+
+msgid ""
+"Means an error which the specified resource is not found in the dataset or any"
+" source. For example:"
+msgstr ""
+
+msgid ""
+"    # the second argument means \"details\" of the error. (optional)\n"
+"    raise Droonga::NotFound.new(\"#{name} is not found!\", :elapsed_time => elap"
+"sed_time)"
+msgstr ""
+
+msgid "### `Droonga::BadRequest`"
+msgstr ""
+
+msgid ""
+"Means any error originated from the incoming message itself, ex. syntax error,"
+" validation error, and so on. For example:"
+msgstr ""
+
+msgid ""
+"    # the second argument means \"details\" of the error. (optional)\n"
+"    raise Droonga::NotFound.new(\"Syntax error in #{query}!\", :detail => detail"
+")"
+msgstr ""
+
+msgid "### `Droonga::MessageProcessingError`"
+msgstr ""
+
+msgid ""
+"Means other unknown error, ex. timed out, file I/O error, and so on. For examp"
+"le:"
+msgstr ""
+
+msgid ""
+"    # the second argument means \"details\" of the error. (optional)\n"
+"    raise Droonga::MessageProcessingError.new(\"busy!\", :elapsed_time => elapse"
+"d_time)"
+msgstr ""
+
+msgid "## Built-in status codes {#builtin-status-codes}"
+msgstr ""
+
+msgid ""
+"You should use following or other status codes as [a matter of principle](../."
+"./message/#error-status)."
+msgstr ""
+
+msgid ""
+"`Droonga::StatusCode::OK`\n"
+": Equals to `200`."
+msgstr ""
+
+msgid ""
+"`Droonga::StatusCode::NOT_FOUND`\n"
+": Equals to `404`."
+msgstr ""
+
+msgid ""
+"`Droonga::StatusCode::BAD_REQUEST`\n"
+": Equals to `400`."
+msgstr ""
+
+msgid ""
+"`Droonga::StatusCode::INTERNAL_ERROR`\n"
+": Equals to `500`."
+msgstr ""
+
+msgid "  [error response]: ../../message/#error"
+msgstr ""

  Modified: _po/ja/reference/plugin/index.po (+3 -1)
===================================================================
--- _po/ja/reference/plugin/index.po    2014-02-17 20:15:23 +0900 (e925e36)
+++ _po/ja/reference/plugin/index.po    2014-02-17 20:20:48 +0900 (52f07f4)
@@ -33,5 +33,7 @@ msgstr ""
 
 msgid ""
 " * [API set for the adaption phase](adapter/)\n"
-" * [API set for the handling phase](handler/)"
+" * [API set for the handling phase](handler/)\n"
+" * [Matching pattern for messages](matching-pattern/)\n"
+" * [Error handling](error/)"
 msgstr ""

  Added: _po/ja/reference/plugin/matching-pattern/index.po (+127 -0) 100644
===================================================================
--- /dev/null
+++ _po/ja/reference/plugin/matching-pattern/index.po    2014-02-17 20:20:48 +0900 (44673da)
@@ -0,0 +1,127 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2011-11-20 22:17+0900\n"
+"PO-Revision-Date: 2013-12-25 18:27+0900\n"
+"Last-Translator: Kouhei Sutou <kou �� clear-code.com>\n"
+"Language-Team: Japanese\n"
+"Language: ja\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=1; plural=0;\n"
+
+msgid ""
+"---\n"
+"title: Matching pattern for messages\n"
+"layout: en\n"
+"---"
+msgstr ""
+"---\n"
+"title: メッセージのマッチングパターン\n"
+"layout: ja\n"
+"---"
+
+msgid ""
+"* TOC\n"
+"{:toc}"
+msgstr ""
+
+msgid "## Abstract {#abstract}"
+msgstr "## 概要 {#abstract}"
+
+msgid ""
+"The Droonga Engine provides a tiny language to specify patterns of messages, c"
+"alled *matching pattern*.\n"
+"It is used to specify target messages of various operations, ex. plugins."
+msgstr ""
+
+msgid "## Examples {#examples}"
+msgstr ""
+
+msgid "### Simple matching"
+msgstr ""
+
+msgid "    pattern = [\"type\", :equal, \"search\"]"
+msgstr ""
+
+msgid "This matches to messages like:"
+msgstr ""
+
+msgid ""
+"    {\n"
+"      \"type\": \"search\",\n"
+"      ...\n"
+"    }"
+msgstr ""
+
+msgid "### Matching for a deep target"
+msgstr ""
+
+msgid "    pattern = [\"body.success\", :equal, true]"
+msgstr ""
+
+msgid ""
+"    {\n"
+"      \"type\": \"add.result\",\n"
+"      \"body\": {\n"
+"        \"result\": true\n"
+"      }\n"
+"    }"
+msgstr ""
+
+msgid "Not matches to:"
+msgstr ""
+
+msgid ""
+"    {\n"
+"      \"type\": \"add.result\",\n"
+"      \"body\": {\n"
+"        \"result\": false\n"
+"      }\n"
+"    }"
+msgstr ""
+
+msgid "### Nested patterns"
+msgstr ""
+
+msgid ""
+"    pattern = [\n"
+"                 [\"type\", :equal, \"table_create\"],\n"
+"                 :or,\n"
+"                 [\"type\", :equal, \"column_create\"]\n"
+"              ]"
+msgstr ""
+
+msgid "This matches to both:"
+msgstr ""
+
+msgid ""
+"    {\n"
+"      \"type\": \"table_create\",\n"
+"      ...\n"
+"    }"
+msgstr ""
+
+msgid "and:"
+msgstr ""
+
+msgid ""
+"    {\n"
+"      \"type\": \"column_create\",\n"
+"      ...\n"
+"    }"
+msgstr ""
+
+msgid "## Syntax {#syntax}"
+msgstr ""
+
+msgid ""
+" * `PATTERN` = [`TARGET_PATH`, `OPERATOR`, `ARGUMENTS*`]\n"
+" * `PATTERN` = [`PATTERN, LOGICAL_OPERATOR`, `PATTERN`]\n"
+" * `TARGET_PATH` = `\"COMPONENT(.COMPONENT)*\"`\n"
+" * `OPERATOR` = `:equal`, `:in`, `:include`, `:exist`, `:start_with`\n"
+" * `ARGUMENTS` = ``OBJECT_DEFINED_IN_JSON*`\n"
+" * `LOGICAL_OPERATOR` = `:or`"
+msgstr ""

  Modified: ja/reference/index.md (+2 -2)
===================================================================
--- ja/reference/index.md    2014-02-17 20:15:23 +0900 (d62c810)
+++ ja/reference/index.md    2014-02-17 20:20:48 +0900 (ba9e121)
@@ -21,5 +21,5 @@ layout: documents_ja
 [コマンドリファレンス](commands/)
 : Droonga Engineで利用可能な組み込みのコマンドの詳細。
 
-[プラグイン開発](plugin/)
-: Droonga Engine用の独自のプラグインを開発するための公開APIの詳細。
+[Plugin development](plugin/)
+: Describes details of public APIs to develop custom plugins for the Droonga Engine.

  Added: ja/reference/plugin/adapter/index.md (+185 -0) 100644
===================================================================
--- /dev/null
+++ ja/reference/plugin/adapter/index.md    2014-02-17 20:20:48 +0900 (71a0855)
@@ -0,0 +1,185 @@
+---
+title: AdaptionフェイズでのプラグインAPI
+layout: ja
+---
+
+{% comment %}
+##############################################
+  THIS FILE IS AUTOMATICALLY GENERATED FROM
+  "_po/ja/reference/plugin/adapter/index.po"
+  DO NOT EDIT THIS FILE MANUALLY!
+##############################################
+{% endcomment %}
+
+
+* TOC
+{:toc}
+
+
+## 概要 {#abstract}
+
+Each Droonga Engine plugin can have its *adapter*. On the adaption phase, adapters 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 an adapter? {#howto-define}
+
+For example, here is a sample plugin named "foo" with an adapter:
+
+~~~ruby
+require "droonga/plugin"
+
+module Droonga
+  module Plugins
+    module FooPlugin
+      Plugin.registry.register("foo", self)
+
+      class Adapter < Droonga::Adapter
+        # operations to configure this adapter
+        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 an adapter:
+
+ 1. Define a module for your plugin (ex. `Droonga::Plugin::FooPlugin`) and register it as a plugin. (required)
+ 2. Define an adapter class (ex. `Droonga::Plugin::FooPlugin::Adapter`) inheriting [`Droonga::Adapter`](#classes-Droonga-Adapter). (required)
+ 3. [Configure conditions to apply the adapter](#howto-configure). (required)
+ 4. Define adaption logic for incoming messages as [`#adapt_input`](#classes-Droonga-Adapter-adapt_input). (optional)
+ 5. Define adaption logic for outgoing messages as [`#adapt_output`](#classes-Droonga-Adapter-adapt_output). (optional)
+
+For more details, see also the [plugin development tutorial](../../../tutorial/plugin-development/adapter/).
+
+
+### How an adapter works? {#how-works}
+
+An adapter works like following:
+
+ 1. The Droonga Engine starts.
+    * A global instance of the adapter class (ex. `Droonga::Plugin::FooPlugin::Adapter`) is created and it is registered.
+      * The input pattern and the output pattern are 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 adapter's [`#adapt_input`](#classes-Droonga-Adapter-adapt_input) is called, if the message matches to the [input matching pattern](#config).
+    * The method can modify the given incoming message, via [its methods](#classes-Droonga-InputMessage).
+ 3. After all adapters are applied, the adaption phase for an incoming message ends, and the 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 adapter's [`#adapt_output`](#classes-Droonga-Adapter-adapt_output) is called, if the corresponding incoming message was processed by the adapter and the outgoing message matches to the [output matching pattern](#config).
+    * The method can modify the given outgoing message, via [its methods](#classes-Droonga-OutputMessage).
+ 5. After all adapters are applied, the adaption phase for an outgoing message ends, and the outgoing message is transferred to the Protocol Adapter.
+
+As described above, the Droonga Engine creates only one global instance of the adapter class for each plugin.
+You should not keep stateful information for a pair of incoming and outgoing messages as an instance variable of the adapter.
+Instead, you should give stateful information as a part of the incoming message body, and receive it from the body of the corresponding outgoing message.
+
+Any error raised from the adapter is handled by the Droonga Engine itself. See also [error handling].
+
+
+## Configurations {#config}
+
+`input_message.pattern`
+: A [matching pattern] for incoming messages.
+  Only messages matched to the given patten are processed by [`#adapt_input`](#classes-Droonga-Adapter-adapt_input).
+
+`output_message.pattern`
+: A [matching pattern] for outgoing messages.
+  Only messages matched to the given patten are processed by [`#adapt_output`](#classes-Droonga-Adapter-adapt_output).
+
+
+
+## Classes and methods {#classes}
+
+### `Droonga::Adapter` {#classes-Droonga-Adapter}
+
+This is the common base class of any adapter. Your plugin's adapter class must inherit the class.
+
+#### `#adapt_input(input_message)` {#classes-Droonga-Adapter-adapt_input}
+
+Receives an instance of [`Droonga::InputMessage`](#classes-Droonga-InputMessage) corresponding to an incoming message.
+
+By defualt this method does nothing, so you have to override it like following:
+
+~~~ruby
+module FooPlugin
+  class Adapter < Droonga::Adapter
+    def adapt_input(input_message)
+      input_message.body["query"] = "fixed query"
+    end
+  end
+end
+~~~
+
+#### `#adapt_output(output_message)` {#classes-Droonga-Adapter-adapt_output}
+
+Receives an instance of [`Droonga::OutputMessage`](#classes-Droonga-InputMessage) corresponding to an outgoing message.
+
+By defualt this method does nothing, so you have to override it like following:
+
+~~~ruby
+module FooPlugin
+  class Adapter < Droonga::Adapter
+    def adapt_output(output_message)
+      output_message.status_code = StatusCode::OK
+    end
+  end
+end
+~~~
+
+### `Droonga::Plugin::Metadata::AdapterMessage` {#classes-Droonga-Plugin-Metadata-AdapterMessage}
+
+(under construction)
+
+#### `#input_pattern`, `#input_pattern=(pattern)` {#classes-Droonga-Plugin-Metadata-AdapterMessage-input_pattern}
+
+(under construction)
+
+#### `#output_pattern`, `#output_pattern=(pattern)` {#classes-Droonga-Plugin-Metadata-AdapterMessage-output_pattern}
+
+(under construction)
+
+### `Droonga::InputMessage` {#classes-Droonga-InputMessage}
+
+(under construction)
+
+#### `#command`, `#command=(command)` {#classes-Droonga-InputMessage-command}
+
+(under construction)
+
+#### `#body`, `#body=(body)` {#classes-Droonga-InputMessage-body}
+
+(under construction)
+
+### `Droonga::OutputMessage` {#classes-Droonga-OutputMessage}
+
+(under construction)
+
+#### `#status_code`, `#status_code=(status_code)` {#classes-Droonga-OutputMessage-status_code}
+
+(under construction)
+
+#### `#errors`, `#errors=(errors)` {#classes-Droonga-OutputMessage-errors}
+
+(under construction)
+
+#### `#body`, `#body=(body)` {#classes-Droonga-OutputMessage-body}
+
+(under construction)
+
+
+
+  [matching pattern]: ../matching-pattern/
+  [error handling]: ../error/

  Added: ja/reference/plugin/error/index.md (+69 -0) 100644
===================================================================
--- /dev/null
+++ ja/reference/plugin/error/index.md    2014-02-17 20:20:48 +0900 (d475214)
@@ -0,0 +1,69 @@
+---
+title: プラグインでのエラーの扱い
+layout: ja
+---
+
+{% comment %}
+##############################################
+  THIS FILE IS AUTOMATICALLY GENERATED FROM
+  "_po/ja/reference/plugin/error/index.po"
+  DO NOT EDIT THIS FILE MANUALLY!
+##############################################
+{% endcomment %}
+
+
+* TOC
+{:toc}
+
+
+## 概要 {#abstract}
+
+Any unhandled error raised from a plugin is returned as an [error response][] for the corresponding incoming message, with the status code `500` (means "internal error").
+
+If you want formatted error information to be returned, then rescue errors and raise your custom errors inheriting `Droonga::MessageProcessingError` instead of raw errors.
+
+
+## Built-in error classes {#builtin-errors}
+
+There are some pre-defined error classes used by built-in plugins and the Droonga Engine itself.
+
+### `Droonga::NotFound`
+
+Means an error which the specified resource is not found in the dataset or any source. For example:
+
+    # the second argument means "details" of the error. (optional)
+    raise Droonga::NotFound.new("#{name} is not found!", :elapsed_time => elapsed_time)
+
+### `Droonga::BadRequest`
+
+Means any error originated from the incoming message itself, ex. syntax error, validation error, and so on. For example:
+
+    # the second argument means "details" of the error. (optional)
+    raise Droonga::NotFound.new("Syntax error in #{query}!", :detail => detail)
+
+### `Droonga::MessageProcessingError`
+
+Means other unknown error, ex. timed out, file I/O error, and so on. For example:
+
+    # the second argument means "details" of the error. (optional)
+    raise Droonga::MessageProcessingError.new("busy!", :elapsed_time => elapsed_time)
+
+
+## Built-in status codes {#builtin-status-codes}
+
+You should use following or other status codes as [a matter of principle](../../message/#error-status).
+
+`Droonga::StatusCode::OK`
+: Equals to `200`.
+
+`Droonga::StatusCode::NOT_FOUND`
+: Equals to `404`.
+
+`Droonga::StatusCode::BAD_REQUEST`
+: Equals to `400`.
+
+`Droonga::StatusCode::INTERNAL_ERROR`
+: Equals to `500`.
+
+
+  [error response]: ../../message/#error

  Modified: ja/reference/plugin/index.md (+1 -0)
===================================================================
--- ja/reference/plugin/index.md    2014-02-17 20:15:23 +0900 (bad3440)
+++ ja/reference/plugin/index.md    2014-02-17 20:20:48 +0900 (e35c8ef)
@@ -17,3 +17,4 @@ Droonga Engineはプラグインに対して、処理の各段階ごとに異な
  * [API set for the adaption phase](adapter/)
  * [API set for the handling phase](handler/)
  * [Matching pattern for messages](matching-pattern/)
+ * [Error handling](error/)

  Added: ja/reference/plugin/matching-pattern/index.md (+92 -0) 100644
===================================================================
--- /dev/null
+++ ja/reference/plugin/matching-pattern/index.md    2014-02-17 20:20:48 +0900 (8724fe6)
@@ -0,0 +1,92 @@
+---
+title: メッセージのマッチングパターン
+layout: ja
+---
+
+{% comment %}
+##############################################
+  THIS FILE IS AUTOMATICALLY GENERATED FROM
+  "_po/ja/reference/plugin/matching-pattern/index.po"
+  DO NOT EDIT THIS FILE MANUALLY!
+##############################################
+{% endcomment %}
+
+
+* TOC
+{:toc}
+
+
+## 概要 {#abstract}
+
+The Droonga Engine provides a tiny language to specify patterns of messages, called *matching pattern*.
+It is used to specify target messages of various operations, ex. plugins.
+
+
+## Examples {#examples}
+
+### Simple matching
+
+    pattern = ["type", :equal, "search"]
+
+This matches to messages like:
+
+    {
+      "type": "search",
+      ...
+    }
+
+### Matching for a deep target
+
+    pattern = ["body.success", :equal, true]
+
+This matches to messages like:
+
+    {
+      "type": "add.result",
+      "body": {
+        "result": true
+      }
+    }
+
+Not matches to:
+
+    {
+      "type": "add.result",
+      "body": {
+        "result": false
+      }
+    }
+
+### Nested patterns
+
+    pattern = [
+                 ["type", :equal, "table_create"],
+                 :or,
+                 ["type", :equal, "column_create"]
+              ]
+
+This matches to both:
+
+    {
+      "type": "table_create",
+      ...
+    }
+
+and:
+
+    {
+      "type": "column_create",
+      ...
+    }
+
+
+## Syntax {#syntax}
+
+
+ * `PATTERN` = [`TARGET_PATH`, `OPERATOR`, `ARGUMENTS*`]
+ * `PATTERN` = [`PATTERN, LOGICAL_OPERATOR`, `PATTERN`]
+ * `TARGET_PATH` = `"COMPONENT(.COMPONENT)*"`
+ * `OPERATOR` = `:equal`, `:in`, `:include`, `:exist`, `:start_with`
+ * `ARGUMENTS` = ``OBJECT_DEFINED_IN_JSON*`
+ * `LOGICAL_OPERATOR` = `:or`
+
-------------- next part --------------
HTML����������������������������...
Download 



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