[Groonga-commit] droonga/droonga.org at 4466dab [gh-pages] Write about testing with fluent-cat

Back to archive index

Yoji Shidara null+****@clear*****
Mon Feb 3 14:41:04 JST 2014


Yoji Shidara	2014-02-03 14:41:04 +0900 (Mon, 03 Feb 2014)

  New Revision: 4466dab75f0552e787e9bbe07a79695062cb5609
  https://github.com/droonga/droonga.org/commit/4466dab75f0552e787e9bbe07a79695062cb5609

  Message:
    Write about testing with fluent-cat

  Modified files:
    tutorial/plugin-development/input-output/index.md

  Modified: tutorial/plugin-development/input-output/index.md (+60 -0)
===================================================================
--- tutorial/plugin-development/input-output/index.md    2014-02-03 13:45:44 +0900 (df1a9a8)
+++ tutorial/plugin-development/input-output/index.md    2014-02-03 14:41:04 +0900 (e6b7510)
@@ -79,7 +79,67 @@ Let's Droonga get started. Note that you need to specify `./lib` directory in `R
 RUBYLIB=./lib fluentd --config fluentd.conf
 ~~~
 
+## Test
+
+In the previous [tutorial][], we have communicated with `fluent-plugin-droonga` via the protocol adapter built with `expres-droonga`.
+For plugin development, sending requests directly to `fluent-plugin-droonga` can be more handy way to debug. We use `fluent-cat` command for this purpose.
+
+Doing in this way also help us to understand internal structure of Droonga.
+
+In the [tutorial][], we have used `fluent-cat` to setup database schema and import data. Do you remember? Sending search request can be done in the similar way.
+
+First, create a request as a JSON.
+
+search-columbus.json:
+
+~~~json
+{
+  "id": "search:0",
+  "dataset": "Starbucks",
+  "type": "search",
+  "replyTo":"localhost:24224/output",
+  "body": {
+    "queries": {
+      "result": {
+        "source": "Store",
+        "condition": {
+          "query": "Columbus",
+          "matchTo": "_key"
+        },
+        "output": {
+          "elements": [
+            "startTime",
+            "elapsedTime",
+            "count",
+            "attributes",
+            "records"
+          ],
+          "attributes": ["_key"],
+          "limit": -1
+        }
+      }
+    }
+  }
+}
+~~~
+
+This is corresponding to the example to search "Columbus" in the [tutorial][]. Note that the request in `express-droonga` is encapsulated in `"body"` element.
+
+`fluent-cat` expects one line per one JSON object. So we need to use `tr` command to remove line breaks before passing the JSON to `fluent-cat`:
+
+    cat search-columbus.json | tr -d "\n" | fluent-cat starbucks.message
+
+This will output something like below to fluentd's log:
+
+    2014-02-03 14:22:54 +0900 output.message: {"inReplyTo":"search:0","statusCode":200,"type":"search.result","body":{"result":{"count":2,"records":[["2 Columbus Ave. - New York NY  (W)"],["Columbus @ 67th - New York NY  (W)"]]}}}
+
+This is the search result.
+
+If you have [jq][] installed, you can use `jq` instead of `tr`:
+
+    jq -c . search-columbus.json | fluent-cat starbucks.message
 
 
   [tutorial]: ../../
   [overview]: ../../../overview/
+  [jq]: http://stedolan.github.io/jq/
-------------- next part --------------
HTML����������������������������...
Download 



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