Skip to content

Commit

Permalink
Extract method to check the node is writable or not
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Dec 22, 2014
1 parent d1130dd commit 4f2e6e6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/droonga/buffered_forwarder.rb
Expand Up @@ -65,8 +65,7 @@ def forward(message, destination)

buffer = @buffers[node_name] ||= ForwardBuffer.new(node_name, @forwarder)

if @engine_state and
@engine_state.unwritable_node?(node_name)
if writable_node?(node_name)
buffer.add(message, destination)
elsif buffer.empty?
@forwarder.forward(message, destination)
Expand All @@ -79,6 +78,11 @@ def forward(message, destination)
end

private
def writable_node?(node_name)
@engine_state and
@engine_state.unwritable_node?(node_name)
end

def log_tag
"[#{Process.ppid}] buffered-forwarder"
end
Expand Down

0 comments on commit 4f2e6e6

Please sign in to comment.