Navigation Menu

Skip to content

Commit

Permalink
serf-agent: support on_failure callback
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jan 5, 2015
1 parent 1f6a143 commit 04a6453
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/droonga/serf_agent.rb
Expand Up @@ -30,6 +30,7 @@ class Agent
MAX_N_READ_CHECKS = 10

attr_writer :on_ready
attr_writer :on_failure
def initialize(loop, serf, host, bind_port, rpc_port, *options)
@loop = loop
@serf = serf
Expand All @@ -39,6 +40,7 @@ def initialize(loop, serf, host, bind_port, rpc_port, *options)
@options = options
@pid = nil
@on_ready = nil
@on_failure = nil
@n_ready_checks = 0
end

Expand Down Expand Up @@ -179,7 +181,7 @@ def start_ready_check

on_connect_failed = lambda do
if @n_ready_checks >= MAX_N_READ_CHECKS
# TODO: @on_fail.call if @on_fail
@on_failure.call if @on_failure
else
timer = Coolio::TimerWatcher.new(1)
on_timer = lambda do
Expand Down

0 comments on commit 04a6453

Please sign in to comment.