Navigation Menu

Skip to content

Commit

Permalink
Accept :replica option for scatter and broadcast
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 14, 2015
1 parent a92ace1 commit 9a0163c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 2 additions & 3 deletions lib/droonga/distributed_command_planner.rb
Expand Up @@ -63,7 +63,7 @@ def scatter(record, options={})
"record" => record,
"type" => "scatter",
"outputs" => [],
"replica" => "all",
"replica" => options[:replica] || "all",
"post" => true
}
end
Expand All @@ -75,10 +75,9 @@ def broadcast(options={})
"body" => options[:body] || @source_message["body"],
"type" => "broadcast",
"outputs" => [],
"replica" => "random"
"replica" => options[:replica] || "random"
}
if options[:write]
processor["replica"] = "all"
processor["post"] = true
end
@processor = processor
Expand Down
6 changes: 5 additions & 1 deletion lib/droonga/planner.rb
Expand Up @@ -40,7 +40,11 @@ def scatter(message, record, options={})

def broadcast(message, options={})
planner = DistributedCommandPlanner.new(@dataset, message)
planner.broadcast(:write => options[:write])
broadcast_options = {
:write => options[:write],
}
broadcast_options[:replica] = "all" if options[:write]
planner.broadcast(broadcast_options)
planner.reduce(options[:reduce])
planner.plan
end
Expand Down

0 comments on commit 9a0163c

Please sign in to comment.