[Groonga-commit] droonga/fluent-plugin-droonga at 4ec9065 [master] Support add operation.

Back to archive index

Daijiro MORI null+****@clear*****
Fri Sep 6 17:11:30 JST 2013


Daijiro MORI	2013-09-06 17:11:30 +0900 (Fri, 06 Sep 2013)

  New Revision: 4ec90651108977aeaddd9531ca1fde875064f5f3
  https://github.com/droonga/fluent-plugin-droonga/commit/4ec90651108977aeaddd9531ca1fde875064f5f3

  Message:
    Support add operation.

  Modified files:
    lib/droonga/adapter.rb

  Modified: lib/droonga/adapter.rb (+32 -10)
===================================================================
--- lib/droonga/adapter.rb    2013-09-06 16:27:37 +0900 (ed76b37)
+++ lib/droonga/adapter.rb    2013-09-06 17:11:30 +0900 (7dc22f5)
@@ -19,16 +19,17 @@ require "droonga/handler"
 
 module Droonga
   class Adapter < Droonga::Handler
-    Droonga::HandlerPlugin.register("adapter", self)
-
-    command :table_create
-    def table_create(request)
-      broadcast_all(request)
-    end
-
-    command :column_create
-    def column_create(request)
-      broadcast_all(request)
+    def scatter_all(request, key)
+      message = [{
+        "command"=> envelope["type"],
+        "dataset"=> envelope["dataset"],
+        "body"=> request,
+        "key"=> key,
+        "type"=> "scatter",
+        "replica"=> "all",
+        "post"=> true
+      }]
+      post(message, "proxy")
     end
 
     def broadcast_all(request)
@@ -43,4 +44,25 @@ module Droonga
       post(message, "proxy")
     end
   end
+
+  class BasicAdapter < Adapter
+    Droonga::HandlerPlugin.register("adapter", self)
+
+    command :table_create
+    def table_create(request)
+      broadcast_all(request)
+    end
+
+    command :column_create
+    def column_create(request)
+      broadcast_all(request)
+    end
+
+    command :add
+    def add(request)
+      # TOOD: update event must be serialized in the primary node
+      key = request["key"] || rand.to_s
+      scatter_all(request, key)
+    end
+  end
 end
-------------- next part --------------
HTML����������������������������...
Download 



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