[Groonga-commit] droonga/droonga-engine at eb01df2 [master] serf: extract "serf XXX(not agent)" code as a class

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Jan 5 16:43:29 JST 2015


Kouhei Sutou	2015-01-05 16:43:29 +0900 (Mon, 05 Jan 2015)

  New Revision: eb01df202b5e881d3286cc76c581d59703e3b50e
  https://github.com/droonga/droonga-engine/commit/eb01df202b5e881d3286cc76c581d59703e3b50e

  Message:
    serf: extract "serf XXX(not agent)" code as a class

  Added files:
    lib/droonga/serf_command.rb
  Modified files:
    lib/droonga/serf.rb

  Modified: lib/droonga/serf.rb (+6 -25)
===================================================================
--- lib/droonga/serf.rb    2015-01-05 16:34:51 +0900 (c889be4)
+++ lib/droonga/serf.rb    2015-01-05 16:43:29 +0900 (265828f)
@@ -1,4 +1,4 @@
-# Copyright (C) 2014 Droonga Project
+# Copyright (C) 2014-2015 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,7 +15,6 @@
 
 require "json"
 require "coolio"
-require "open3"
 
 require "droonga/path"
 require "droonga/loggable"
@@ -23,6 +22,7 @@ require "droonga/catalog_loader"
 require "droonga/node_metadata"
 require "droonga/serf_downloader"
 require "droonga/serf_agent"
+require "droonga/serf_command"
 require "droonga/line_buffer"
 require "droonga/safe_file_writer"
 require "droonga/service_installation"
@@ -183,10 +183,10 @@ module Droonga
     end
 
     def run_once(command, *options)
-      process = SerfProcess.new(@serf, command,
-                                "-rpc-addr", rpc_address,
-                                *options)
-      process.run_once
+      command = Command.new(@serf, command,
+                            "-rpc-addr", rpc_address,
+                            *options)
+      command.run
     end
 
     def additional_options_from_payload(payload)
@@ -243,24 +243,5 @@ module Droonga
     def log_tag
       "serf"
     end
-
-    class SerfProcess
-      include Loggable
-
-      def initialize(serf, command, *options)
-        @serf = serf
-        @command = command
-        @options = options
-      end
-
-      def run_once
-        stdout, stderror, status = Open3.capture3(@serf, @command, *@options, :pgroup => true)
-        {
-          :result => stdout,
-          :error  => stderror,
-          :status => status,
-        }
-      end
-    end
   end
 end

  Added: lib/droonga/serf_command.rb (+45 -0) 100644
===================================================================
--- /dev/null
+++ lib/droonga/serf_command.rb    2015-01-05 16:43:29 +0900 (f88942f)
@@ -0,0 +1,45 @@
+# Copyright (C) 2014-2015 Droonga Project
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1 as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+require "open3"
+
+require "droonga/loggable"
+
+module Droonga
+  class Serf
+    class Command
+      include Loggable
+
+      def initialize(serf, command, *options)
+        @serf = serf
+        @command = command
+        @options = options
+      end
+
+      def run
+        stdout, stderror, status = Open3.capture3(@serf, @command, *@options, :pgroup => true)
+        {
+          :result => stdout,
+          :error  => stderror,
+          :status => status,
+        }
+      end
+
+      def log_tag
+        "serf[#{@command}]"
+      end
+    end
+  end
+end
-------------- next part --------------
HTML����������������������������...
Download 



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