Navigation Menu

Skip to content

Commit

Permalink
serf: reduce spread "ensure_serf"
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jan 5, 2015
1 parent c75059c commit 8c083ea
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions lib/droonga/serf.rb
Expand Up @@ -66,20 +66,17 @@ def run_agent(loop)
end

def leave
ensure_serf
run_once("leave")
end

def join(*hosts)
ensure_serf
nodes = hosts.collect do |host|
"#{host}:#{agent_port}"
end
run_once("join", *nodes)
end

def send_query(query, payload)
ensure_serf
options = ["-format", "json"] + additional_options_from_payload(payload)
options += [query, JSON.generate(payload)]
result = run_once("query", *options)
Expand Down Expand Up @@ -111,7 +108,6 @@ def update_cluster_state
end

def current_cluster_state
ensure_serf
nodes = {}
result = run_once("members", "-format", "json")
result[:result] = JSON.parse(result[:result])
Expand All @@ -131,12 +127,10 @@ def current_cluster_state
end

def set_tag(name, value)
ensure_serf
run_once("tags", "-set", "#{name}=#{value}")
end

def delete_tag(name)
ensure_serf
run_once("tags", "-delete", name)
end

Expand Down Expand Up @@ -182,6 +176,7 @@ def find_system_serf
end

def run_once(command, *options)
ensure_serf
command = Command.new(@serf, command,
"-rpc-addr", rpc_address,
*options)
Expand Down

0 comments on commit 8c083ea

Please sign in to comment.