[Groonga-commit] droonga/fluent-plugin-droonga at 122ffa6 [master] Add table_remove command

Back to archive index

YUKI Hiroshi null+****@clear*****
Wed Jan 22 19:16:15 JST 2014


YUKI Hiroshi	2014-01-22 19:16:15 +0900 (Wed, 22 Jan 2014)

  New Revision: 122ffa690415d722ad63859e34120021916f3593
  https://github.com/droonga/fluent-plugin-droonga/commit/122ffa690415d722ad63859e34120021916f3593

  Message:
    Add table_remove command

  Copied files:
    lib/droonga/plugin/handler/groonga/table_remove.rb
      (from lib/droonga/plugin/distributor/groonga.rb)
  Modified files:
    lib/droonga/plugin/distributor/groonga.rb
    lib/droonga/plugin/handler/groonga.rb
    lib/groonga_command_converter.rb

  Modified: lib/droonga/plugin/distributor/groonga.rb (+8 -0)
===================================================================
--- lib/droonga/plugin/distributor/groonga.rb    2014-01-21 15:12:02 +0900 (ad30ce9)
+++ lib/droonga/plugin/distributor/groonga.rb    2014-01-22 19:16:15 +0900 (e5d8da6)
@@ -29,6 +29,14 @@ module Droonga
       broadcast_all(message)
     end
 
+    command :table_remove
+    def table_remove(message)
+      unless message["dataset"]
+        raise "dataset must be set. FIXME: This error should return client."
+      end
+      broadcast_all(message)
+    end
+
     command :column_create
     def column_create(message)
       broadcast_all(message)

  Modified: lib/droonga/plugin/handler/groonga.rb (+8 -0)
===================================================================
--- lib/droonga/plugin/handler/groonga.rb    2014-01-21 15:12:02 +0900 (73a5927)
+++ lib/droonga/plugin/handler/groonga.rb    2014-01-22 19:16:15 +0900 (dd856f9)
@@ -30,6 +30,13 @@ module Droonga
       messenger.emit(outputs)
     end
 
+    command :table_remove
+    def table_create(message, messenger)
+      command = TableRemove.new(@context)
+      outputs = command.execute(message.request)
+      messenger.emit(outputs)
+    end
+
     command :column_create
     def column_create(message, messenger)
       command = ColumnCreate.new(@context)
@@ -81,4 +88,5 @@ module Droonga
 end
 
 require "droonga/plugin/handler/groonga/table_create"
+require "droonga/plugin/handler/groonga/table_remove"
 require "droonga/plugin/handler/groonga/column_create"

  Copied: lib/droonga/plugin/handler/groonga/table_remove.rb (+19 -14) 51%
===================================================================
--- lib/droonga/plugin/distributor/groonga.rb    2014-01-21 15:12:02 +0900 (ad30ce9)
+++ lib/droonga/plugin/handler/groonga/table_remove.rb    2014-01-22 19:16:15 +0900 (6c590b0)
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2013 Droonga Project
+# Copyright (C) 2014 Droonga Project
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -15,23 +15,28 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-require "droonga/distributor_plugin"
+require "groonga"
+require "groonga/command/table-remove"
 
 module Droonga
-  class GroongaDistributor < Droonga::DistributorPlugin
-    repository.register("groonga", self)
+  class GroongaHandler
+    class TableRemove < Command
+      def process_request(request)
+        command_class = Groonga::Command.find("table_remove")
+        @command = command_class.new("table_remove", request)
 
-    command :table_create
-    def table_create(message)
-      unless message["dataset"]
-        raise "dataset must be set. FIXME: This error should return client."
-      end
-      broadcast_all(message)
-    end
+        name = @command["name"]
+        unless name
+          raise CommandError.new(:status => Status::INVALID_ARGUMENT,
+                                 :message => "Cannot remove anonymous table",
+                                 :result => false)
+        end
 
-    command :column_create
-    def column_create(message)
-      broadcast_all(message)
+        Groonga::Schema.define(:context => @context) do |schema|
+          schema.remove_table(name)
+        end
+        true
+      end
     end
   end
 end

  Modified: lib/groonga_command_converter.rb (+6 -0)
===================================================================
--- lib/groonga_command_converter.rb    2014-01-21 15:12:02 +0900 (449ae79)
+++ lib/groonga_command_converter.rb    2014-01-22 19:16:15 +0900 (2082039)
@@ -35,6 +35,8 @@ module Droonga
         case command.name
         when "table_create"
           yield create_table_create_command(command)
+        when "table_remove"
+          yield create_table_remove_command(command)
         when "column_create"
           yield create_column_create_command(command)
         when "select"
@@ -102,6 +104,10 @@ module Droonga
       create_message("table_create", command.arguments)
     end
 
+    def create_table_remove_command(command)
+      create_message("table_remove", command.arguments)
+    end
+
     def create_column_create_command(command)
       create_message("column_create", command.arguments)
     end
-------------- next part --------------
HTML����������������������������...
Download 



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