[Groonga-commit] droonga/droonga-engine at fd45fd6 [master] Define LiveNodesListObserver.path

Back to archive index

Kouhei Sutou null+****@clear*****
Mon May 26 17:33:31 JST 2014


Kouhei Sutou	2014-05-26 17:33:31 +0900 (Mon, 26 May 2014)

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

  Message:
    Define LiveNodesListObserver.path

  Modified files:
    lib/droonga/command/serf_event_handler.rb
    lib/droonga/live_nodes_list_observer.rb

  Modified: lib/droonga/command/serf_event_handler.rb (+3 -6)
===================================================================
--- lib/droonga/command/serf_event_handler.rb    2014-05-26 17:28:47 +0900 (6613d9a)
+++ lib/droonga/command/serf_event_handler.rb    2014-05-26 17:33:31 +0900 (890844d)
@@ -68,15 +68,12 @@ module Droonga
         nodes
       end
 
-      def list_file
-        Droonga::Path.state + LiveNodesListObserver::LIST_FILE_NAME
-      end
-
       def output_live_nodes
+        list_path = LiveNodesListObserver.path
         nodes = live_nodes
         file_contents = JSON.pretty_generate(nodes)
-        FileUtils.mkdir_p(list_file.parent.to_s)
-        list_file.open("w") do |file|
+        FileUtils.mkdir_p(list_path.parent.to_s)
+        list_path.open("w") do |file|
           file.write(file_contents)
         end
       end

  Modified: lib/droonga/live_nodes_list_observer.rb (+10 -6)
===================================================================
--- lib/droonga/live_nodes_list_observer.rb    2014-05-26 17:28:47 +0900 (dc5a543)
+++ lib/droonga/live_nodes_list_observer.rb    2014-05-26 17:33:31 +0900 (c080c0c)
@@ -22,6 +22,14 @@ require "droonga/live_nodes_list_loader"
 
 module Droonga
   class LiveNodesListObserver
+    class << self
+      FILE_NAME = "live-nodes.json"
+
+      def path
+        Path.state + FILE_NAME
+      end
+    end
+
     include Loggable
 
     attr_accessor :on_update
@@ -30,6 +38,7 @@ module Droonga
     end
 
     def start
+      path = self.class.path
       file_name = path.to_s
       directory = path.dirname.to_s
       FileUtils.mkdir_p(directory)
@@ -46,13 +55,8 @@ module Droonga
       @listener.stop
     end
 
-    LIST_FILE_NAME = "live-nodes.json"
-
-    def path
-      Droonga::Path.state + LIST_FILE_NAME
-    end
-
     def load_list!
+      path = self.class.path
       loader = LiveNodesListLoader.new(path)
       live_nodes = loader.load
       logger.info("loaded", :path => path.to_s, :live_nodes => live_nodes)
-------------- next part --------------
HTML����������������������������...
Download 



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