Class: Droonga::Plugins::Dump::Dumper

Inherits:
AsyncCommand::AsyncHandler show all
Includes:
DatabaseScanner
Defined in:
lib/droonga/plugins/dump.rb

Instance Method Summary collapse

Methods included from DatabaseScanner

#each_index_columns, #each_table, #index_column?, #index_only_table?, #n_columns, #n_records, #n_tables, #reference_table?, #table?, #total_n_objects

Constructor Details

#initialize(context, loop, messenger, request) ⇒ Dumper

Returns a new instance of Dumper.



69
70
71
72
# File 'lib/droonga/plugins/dump.rb', line 69

def initialize(context, loop, messenger, request)
  @context = context
  super(loop, messenger, request)
end

Instance Method Details

#startObject



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/droonga/plugins/dump.rb', line 74

def start
  on_start

  runner = Fiber.new do
    forecast
    dump_schema
    dump_records
    dump_indexes
    on_finish
  end

  timer = Coolio::TimerWatcher.new(0.1, true)
  timer.on_timer do
    if runner.alive?
      begin
        runner.resume
      rescue
        timer.detach
        logger.trace("start: timer detached by unexpected exception",
                     :watcher => timer)
        logger.exception(error_message, $!)
        error(error_name, error_message)
      end
    else
      timer.detach
      logger.trace("start: timer detached by unexpected exception",
                   :watcher => timer)
    end
  end

  @loop.attach(timer)
  logger.trace("start: timer attached",
               :watcher => timer)
end