Kouhei Sutou
null+****@clear*****
Wed May 21 16:59:50 JST 2014
Kouhei Sutou 2014-05-21 16:59:50 +0900 (Wed, 21 May 2014) New Revision: d049f401fac7a529b43976e0cda655da7d52e95f https://github.com/droonga/droonga-engine/commit/d049f401fac7a529b43976e0cda655da7d52e95f Message: Indent Modified files: lib/droonga/command/serf_event_handler.rb Modified: lib/droonga/command/serf_event_handler.rb (+44 -44) =================================================================== --- lib/droonga/command/serf_event_handler.rb 2014-05-21 16:58:42 +0900 (4705008) +++ lib/droonga/command/serf_event_handler.rb 2014-05-21 16:59:50 +0900 (d170f18) @@ -24,62 +24,62 @@ require "droonga/live_nodes_list_observer" module Droonga module Command - class SerfEventHandler - class << self - def run - new.run + class SerfEventHandler + class << self + def run + new.run + end end - end - def initialize - @serf = ENV["SERF"] || Serf.path - @serf_rpc_address = ENV["SERF_RPC_ADDRESS"] || "127.0.0.1:7373" - end + def initialize + @serf = ENV["SERF"] || Serf.path + @serf_rpc_address = ENV["SERF_RPC_ADDRESS"] || "127.0.0.1:7373" + end - def run - parse_event + def run + parse_event - output_live_nodes - true - end + output_live_nodes + true + end - private - def parse_event - @event_name = ENV["SERF_EVENT"] - case @event_name - when "user" - @event_name += ":#{ENV["SERF_USER_EVENT"]}" - when "query" - @event_name += ":#{ENV["SERF_USER_QUERY"]}" + private + def parse_event + @event_name = ENV["SERF_EVENT"] + case @event_name + when "user" + @event_name += ":#{ENV["SERF_USER_EVENT"]}" + when "query" + @event_name += ":#{ENV["SERF_USER_QUERY"]}" + end end - end - def live_nodes - nodes = {} - members = `#{@serf} members -rpc-addr #{@serf_rpc_address}` - members.each_line do |member| - name, address, status, = member.strip.split(/\s+/) - if status == "alive" - nodes[name] = { - "address" => address, - } + def live_nodes + nodes = {} + members = `#{@serf} members -rpc-addr #{@serf_rpc_address}` + members.each_line do |member| + name, address, status, = member.strip.split(/\s+/) + if status == "alive" + nodes[name] = { + "address" => address, + } + end end + nodes end - nodes - end - def list_file - @list_file ||= Droonga.base_path + LiveNodesListObserver::DEFAULT_LIST_PATH - end + def list_file + @list_file ||= Droonga.base_path + LiveNodesListObserver::DEFAULT_LIST_PATH + end - def output_live_nodes - nodes = live_nodes - file_contents = JSON.pretty_generate(nodes) - FileUtils.mkdir_p(list_file.parent.to_s) - File.open(list_file.to_s, "w") do |file| - file.write(file_contents) + def output_live_nodes + nodes = live_nodes + file_contents = JSON.pretty_generate(nodes) + FileUtils.mkdir_p(list_file.parent.to_s) + File.open(list_file.to_s, "w") do |file| + file.write(file_contents) + end end end end - end end -------------- next part -------------- HTML����������������������������... ダウンロード