Class: Droonga::Distributor

Inherits:
Object
  • Object
show all
Includes:
TSort
Defined in:
lib/droonga/distributor.rb

Defined Under Namespace

Classes: CyclicStepsError, UndefinedInputError

Instance Method Summary collapse

Constructor Details

#initialize(dispatcher, plan) ⇒ Distributor

Returns a new instance of Distributor.



40
41
42
43
44
# File 'lib/droonga/distributor.rb', line 40

def initialize(dispatcher, plan)
  @dispatcher = dispatcher
  @plan = plan
  build_dependencies
end

Instance Method Details

#distributeObject



46
47
48
49
50
51
52
53
54
55
# File 'lib/droonga/distributor.rb', line 46

def distribute
  steps = []
  each_strongly_connected_component do |nodes|
    raise CyclicStepsError.new(nodes) if nodes.size > 1
    nodes.each do |node|
      steps << @step_maps[node] if node.is_a?(Integer)
    end
  end
  @dispatcher.dispatch_steps(steps)
end