Navigation Menu

Skip to content

Commit

Permalink
Make EngineNode's forward buffer easy to replace
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 30, 2015
1 parent 13947af commit 1ac0759
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/droonga/engine_node.rb
Expand Up @@ -36,12 +36,7 @@ def initialize(params)
@state = params[:state]
logger.trace("initialize: start")

@buffer = ForwardBuffer.new(name)
boundary_timestamp = accept_messages_newer_than_timestamp
@buffer.process_messages_newer_than(boundary_timestamp)
@buffer.on_forward = lambda do |message, destination|
output(message, destination)
end
@buffer = create_buffer

@node_name = NodeName.parse(@name)

Expand Down Expand Up @@ -186,6 +181,16 @@ def sender_role
NodeRole.mine
end

def create_buffer
buffer = ForwardBuffer.new(@name)
boundary_timestamp = accept_messages_newer_than_timestamp
buffer.process_messages_newer_than(boundary_timestamp)
buffer.on_forward = lambda do |message, destination|
output(message, destination)
end
buffer
end

def have_unprocessed_messages?
@state and @state["have_unprocessed_messages"]
end
Expand Down

0 comments on commit 1ac0759

Please sign in to comment.