Class: Hekenga::MasterProcess

Inherits:
Object
  • Object
show all
Defined in:
lib/hekenga/master_process.rb

Instance Method Summary collapse

Constructor Details

#initialize(migration) ⇒ MasterProcess

Returns a new instance of MasterProcess.



6
7
8
# File 'lib/hekenga/master_process.rb', line 6

def initialize(migration)
  @migration = migration
end

Instance Method Details

#recover!Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/hekenga/master_process.rb', line 23

def recover!
  Hekenga.log "Recovering migration #{@migration.to_key}: #{@migration.description}"
  @migration.tasks.each.with_index do |task, idx|
    recover_task(task, idx)
    report_while_active(task, idx) if @active_thread
  rescue Hekenga::TaskFailedError
    return false
  ensure
    @active_thread = nil
  end
  true
end

#run!Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/hekenga/master_process.rb', line 10

def run!
  Hekenga.log "Launching migration #{@migration.to_key}: #{@migration.description}"
  @migration.tasks.each.with_index do |task, idx|
    launch_task(task, idx)
    report_while_active(task, idx)
  rescue Hekenga::TaskFailedError
    return false
  ensure
    @active_thread = nil
  end
  true
end