Class: Droonga::StepRunner

Inherits:
Object
  • Object
show all
Includes:
Loggable
Defined in:
lib/droonga/step_runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(dataset, plugins) ⇒ StepRunner

Returns a new instance of StepRunner.



24
25
26
27
28
29
30
31
32
33
# File 'lib/droonga/step_runner.rb', line 24

def initialize(dataset, plugins)
  @dataset = dataset
  @definitions = {}
  plugins.each do |name|
    plugin = Plugin.registry[name]
    plugin.single_step_definitions.each do |definition|
      @definitions[definition.name] = definition
    end
  end
end

Instance Method Details

#find(type) ⇒ Object



55
56
57
# File 'lib/droonga/step_runner.rb', line 55

def find(type)
  @definitions[type]
end

#plan(message) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/droonga/step_runner.rb', line 38

def plan(message)
  type = message["type"]
  logger.trace("plan: start",
               :dataset => message["dataset"],
               :type => type)
  definition = find(type)
  if definition.nil?
    raise UnsupportedMessageError.new(:planner, message)
  end
  step = SingleStep.new(@dataset, definition)
  plan = step.plan(message)
  logger.trace("plan: done",
               :dataset => message["dataset"],
               :type => type)
  plan
end

#shutdownObject



35
36
# File 'lib/droonga/step_runner.rb', line 35

def shutdown
end