Navigation Menu

Skip to content

Commit

Permalink
Extract logic to get destinations from steps
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Jun 26, 2014
1 parent 9864287 commit ad2342c
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions lib/droonga/dispatcher.rb
Expand Up @@ -170,28 +170,31 @@ def dispatch(message, destination)

def dispatch_steps(steps)
id = @engine_state.generate_id
destinations = {}
steps.each do |step|
dataset = @catalog.dataset(step["dataset"])
if dataset
target_nodes = nil
target_nodes = @engine_state.live_nodes unless write_step?(step)
routes = dataset.get_routes(step, target_nodes)
routes = dataset.get_routes(step, @engine_state.live_nodes)
step["routes"] = routes
else
step["routes"] ||= [id]
end
routes = step["routes"]
routes.each do |route|
destinations[farm_path(route)] = true
end
end
dispatch_message = { "id" => id, "steps" => steps }
destinations.each_key do |destination|
get_destinations(steps).each do |destination|
dispatch(dispatch_message, destination)
end
end

def get_destinations(steps)
destinations = {}
steps.each do |step|
step["routes"].each do |route|
destinations[farm_path(route)] = true
end
end
destinations.keys
end

def process_local_message(local_message)
task = local_message["task"]
slice_name = task["route"]
Expand Down

0 comments on commit ad2342c

Please sign in to comment.