Module: Flydata::Source

Defined in:
lib/flydata/source.rb,
lib/flydata/source/sync.rb,
lib/flydata/source/setup.rb,
lib/flydata/source/errors.rb,
lib/flydata/source/component.rb,
lib/flydata/source/data_entry.rb,
lib/flydata/source/source_pos.rb,
lib/flydata/source/sync_repair.rb,
lib/flydata/source/parse_dump_and_send.rb,
lib/flydata/source/generate_source_dump.rb,
lib/flydata/source/sync_generate_table_ddl.rb

Defined Under Namespace

Classes: Component, DataEntry, GenerateSourceDump, MasterContext, ParseDumpAndSend, Setup, SourcePos, Sync, SyncGenerateTableDdl, SyncRepair, UnsupportedSourceError

Constant Summary collapse

DATA_ENTRY_TYPE_MAP =
{
  "RedshiftMysqlDataEntry" => :source_mysql,
  "RedshiftFileDataEntry" => :source_file,
  "FileDataEntry" => :source_file,
  "RedshiftPostgresqlDataEntry" => :source_postgresql,
  "RedshiftZendeskDataEntry" => :source_zendesk,
  "RedshiftOracleDataEntry" => :source_oracle,
}
COMMAND_SUBDIR =
"command"

Class Method Summary collapse

Class Method Details

.command_dir_pathsObject

Returns require-friendly paths to the source specific command directory.

ex) ["flydata/source_mysql/command", "flydata/source_postgres/command"]


52
53
54
55
56
57
58
59
60
61
# File 'lib/flydata/source.rb', line 52

def self.command_dir_paths
  result = []
  DATA_ENTRY_TYPE_MAP.values.each do |source_key|
    path = File.join(source_dir_path(source_key), COMMAND_SUBDIR)
    if File.exists?(path)
      result << File.join("flydata", source_key.to_s, COMMAND_SUBDIR)
    end
  end
  result
end

.component_class_for(component_sym, de) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/flydata/source.rb', line 29

def self.component_class_for(component_sym, de)
  source_sym = DATA_ENTRY_TYPE_MAP[de['type']]
  unless source_sym
    raise "No source components are available for this data entry"
  end
  @component_classes ||= {}
  component_key = component_key(source_sym, component_sym)
  unless @component_classes.has_key?(component_key)
    require_component(source_sym, component_sym)
    unless @component_classes.has_key?(component_key)
      @component_classes[component_key] = nil
    end
  end
  klass = @component_classes[component_key]
  unless klass
    raise "Component '#{component_sym}' is not defined in source '#{source_sym}'"
  end
  klass
end

.create(de) ⇒ Object



7
8
9
# File 'lib/flydata/source.rb', line 7

def self.create(de)
  MasterContext.new(de)
end

.register(component_class, type_class) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/flydata/source.rb', line 11

def self.register(component_class, type_class)
  @component_classes ||= {}
  source_sym = underscored_source_module_sym(component_class)
  unless source_sym
    raise "Class must must be under a 'SourceXxxx' module"
  end
  component_sym = underscored_class_name_sym(type_class)
  @component_classes[component_key(source_sym, component_sym)] = component_class
end