Class: Flydata::Source::GenerateSourceDump

Inherits:
Component
  • Object
show all
Defined in:
lib/flydata/source/generate_source_dump.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, dp, options) ⇒ GenerateSourceDump

Returns a new instance of GenerateSourceDump.


13
14
15
16
# File 'lib/flydata/source/generate_source_dump.rb', line 13

def initialize(source, dp, options)
  super(source, options)
  @dp = dp
end

Instance Attribute Details

#dpObject (readonly)

Returns the value of attribute dp


17
18
19
# File 'lib/flydata/source/generate_source_dump.rb', line 17

def dp
  @dp
end

Class Method Details

.inherited(child_class) ⇒ Object


9
10
11
# File 'lib/flydata/source/generate_source_dump.rb', line 9

def self.inherited(child_class)
  Source.register(child_class, self)
end

Instance Method Details

#confirmation_itemsObject

Public Interface: Confirmation items

Returns a hash of items to be shown as the final confirmation before initial sync.

Example: Return value {"host" => "ubertas","port" => 3306}
         will be displayed as
             host: ubertas
             port: 3306

40
41
42
# File 'lib/flydata/source/generate_source_dump.rb', line 40

def confirmation_items
  raise UnsupportedSourceError,  "subclass must implement"
end

#dump(tables, file_path = nil, &src_pos_callback) ⇒ Object

Public Interface: Dump data

tables: An array of tables to be dumped. file_path: A file path string of the dump file to which data is written.

This value may be nil, in which case contents are written to
a pipe to which the caller can access via `io` passed in the
callback.

src_pos_callback: A callback called when the source position of the dump

becomes available. The callback takes the following arguments.
  io: Input IO to the dump.
  src_pos: Source position of the dump

Returns none


67
68
69
# File 'lib/flydata/source/generate_source_dump.rb', line 67

def dump(tables, file_path = nil, &src_pos_callback)
  raise UnsupportedSourceError,  "subclass must implement"
end

#dump_size(tables) ⇒ Object

Public Interface: Dump size

tables: An array of table names to be dumped.

Returns an approximate size of dump in bytes. The value may be a best-effort estimate. It doesn't have to be accurate.


50
51
52
# File 'lib/flydata/source/generate_source_dump.rb', line 50

def dump_size(tables)
  raise UnsupportedSourceError,  "subclass must implement"
end

#run_compatibility_check(dump_dir, backup_dir) ⇒ Object

Public Interface: Run compatibility check

Run whatever check (compatibility, connectivity, privilege, etc) to ensure that initial sync can run without an issue.

dump_dir: A directory path string to the dump directory backup_dir: A directory path string to the backup directory

Raises exception when check fails


28
29
30
# File 'lib/flydata/source/generate_source_dump.rb', line 28

def run_compatibility_check(dump_dir, backup_dir)
  raise UnsupportedSourceError,  "subclass must implement"
end