Class: Restforce::DB::TaskManager

Inherits:
Object
  • Object
show all
Includes:
Loggable
Defined in:
lib/restforce/db/task_manager.rb

Overview

Restforce::DB::TaskManager defines the run sequence and invocation of each of the Restforce::DB::Task subclasses during a single processing loop for the top-level Worker object.

Instance Method Summary collapse

Methods included from Loggable

included

Constructor Details

#initialize(runner, logger: nil) ⇒ TaskManager

Public: Initialize a new Restforce::DB::TaskManager for a given runner state.

runner - A Restforce::DB::Runner for a specific period of time. logger - A Logger object (optional).



32
33
34
35
36
# File 'lib/restforce/db/task_manager.rb', line 32

def initialize(runner, logger: nil)
  @runner = runner
  @logger = logger
  @changes = Hash.new { |h, k| h[k] = Accumulator.new }
end

Instance Method Details

#performObject

Public: Run each of the sync tasks in a defined order for the supplied runner’s current state.

Returns nothing.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/restforce/db/task_manager.rb', line 42

def perform
  Registry.each do |mapping|
    run("CLEANING RECORDS", Cleaner, mapping)
    run("ATTACHING RECORDS", Attacher, mapping)
    run("PROPAGATING RECORDS", Initializer, mapping)
    run("COLLECTING CHANGES", Collector, mapping)
  end

  # NOTE: We can only perform the synchronization after all record changes
  # have been aggregated, so this second loop is necessary.
  Registry.each do |mapping|
    run("UPDATING ASSOCIATIONS", Associator, mapping)
    run("APPLYING CHANGES", Synchronizer, mapping)
  end
end