Class: Droonga::DistributionPlanner
- Inherits:
-
Object
- Object
- Droonga::DistributionPlanner
- Includes:
- TSort
- Defined in:
- lib/droonga/distribution_planner.rb
Defined Under Namespace
Classes: CyclicComponentsError, UndefinedInputError
Instance Method Summary collapse
-
#initialize(dispatcher, components) ⇒ DistributionPlanner
constructor
A new instance of DistributionPlanner.
- #plan ⇒ Object
Constructor Details
#initialize(dispatcher, components) ⇒ DistributionPlanner
Returns a new instance of DistributionPlanner.
40 41 42 43 |
# File 'lib/droonga/distribution_planner.rb', line 40 def initialize(dispatcher, components) @dispatcher = dispatcher @components = components end |
Instance Method Details
#plan ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/droonga/distribution_planner.rb', line 45 def plan @dependency = {} @components.each do |component| @dependency[component] = component["inputs"] next unless component["outputs"] component["outputs"].each do |output| @dependency[output] = [component] end end components = [] each_strongly_connected_component do |cs| raise CyclicComponentsError.new(cs) if cs.size > 1 components.concat(cs) unless cs.first.is_a? String end components end |