Class: Flydata::Source::Sync

Inherits:
Component show all
Defined in:
lib/flydata/source/sync.rb

Constant Summary collapse

SOURCE_TABLE_LISTS_KEYS =

Public Interface: Table lists

Returns lists of tables in a hash. The following lists will be returned

"tables" : An array of tables currently in sync (valid tables append-only & valid tables full-sync)
"new_tables" : An array of tables for which no generate_table_ddl has been run yet
"invalid_tables" : An array of tables that had an issue starting sync
"tables_append_only" : An array of tables whose sync type is append-only
"invalid_tables_append_only" : An array of append-only tables that had an issue starting sync
%w(
  tables
  new_tables
  invalid_tables
  tables_append_only
  invalid_tables_append_only
)

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Component

#initialize

Constructor Details

This class inherits a constructor from Flydata::Source::Component

Class Method Details

.inherited(child_class) ⇒ Object

subclass has to define these constant variables SOURCE_PREFERENCE_NAME = ‘xxxxx_data_entry_preference’



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

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

Instance Method Details

#data_serversObject

Public Interface: Data Servers

Returns a comma separated list of data servers to which the agent sends data



58
59
60
# File 'lib/flydata/source/sync.rb', line 58

def data_servers
  de[self.class::SOURCE_PREFERENCE_NAME]['data_servers']
end

#forwarderObject

Public Interface: Forwarder

Returns a forwarder type in string. Values are ‘tcpforwarder’ or ‘sslforwarder’.



65
66
67
# File 'lib/flydata/source/sync.rb', line 65

def forwarder
  de[self.class::SOURCE_PREFERENCE_NAME]['forwarder']
end

#setupObject

Public Interface: Set up data source

Called right after the source instance is created. Perform one-time setup which is necessary to initialize the source for sync (and sync only)

Raises exception when the source does not support sync



23
24
25
26
27
# File 'lib/flydata/source/sync.rb', line 23

def setup
  prefs = de[self.class::SOURCE_PREFERENCE_NAME]
  setup_table_prefs(prefs)
  setup_pk_override_prefs(prefs)
end

#supported?Boolean

Public Interface: Tells if the source support sync or not

Returns true if the source supports sync. No otherwise.

Returns:

  • (Boolean)

Raises:



32
33
34
# File 'lib/flydata/source/sync.rb', line 32

def supported?
  raise UnsupportedSourceError, "subclass must implement"
end

#table_listsObject



51
52
53
# File 'lib/flydata/source/sync.rb', line 51

def table_lists
  de[self.class::SOURCE_PREFERENCE_NAME].select {|key, value| SOURCE_TABLE_LISTS_KEYS.include?(key)}
end