Class: RedshiftConnector::Connector
- Inherits:
-
Object
- Object
- RedshiftConnector::Connector
- Defined in:
- lib/redshift-connector/connector.rb
Class Method Summary collapse
- .transport_all(strategy: 'rename', schema:, table:, src_table: table, dest_table: table, columns:, bucket: nil, txn_id:, filter:, logger: RedshiftConnector.logger, quiet: false) ⇒ Object
- .transport_delta(schema:, table: nil, src_table: table, dest_table: table, condition:, columns:, delete_cond: nil, upsert_columns: nil, bucket: nil, txn_id:, filter:, logger: RedshiftConnector.logger, quiet: false) ⇒ Object
Instance Method Summary collapse
- #execute ⇒ Object
- #export ⇒ Object
- #export_enabled? ⇒ Boolean
- #import ⇒ Object
- #import_enabled? ⇒ Boolean
-
#initialize(exporter:, importer:, logger:) ⇒ Connector
constructor
A new instance of Connector.
Constructor Details
#initialize(exporter:, importer:, logger:) ⇒ Connector
Returns a new instance of Connector.
91 92 93 94 95 |
# File 'lib/redshift-connector/connector.rb', line 91 def initialize(exporter:, importer:, logger:) @exporter = exporter @importer = importer @logger = logger end |
Class Method Details
.transport_all(strategy: 'rename', schema:, table:, src_table: table, dest_table: table, columns:, bucket: nil, txn_id:, filter:, logger: RedshiftConnector.logger, quiet: false) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/redshift-connector/connector.rb', line 52 def Connector.transport_all( strategy: 'rename', schema:, table:, src_table: table, dest_table: table, columns:, bucket: nil, txn_id:, filter:, logger: RedshiftConnector.logger, quiet: false ) bucket = bucket ? S3Bucket.get(bucket) : S3Bucket.default logger = NullLogger.new if quiet bundle = S3DataFileBundle.for_table( bucket: bucket, schema: schema, table: table, txn_id: txn_id, filter: filter, logger: logger ) exporter = Exporter.for_table( bundle: bundle, schema: schema, table: table, columns: columns, logger: logger ) importer = Importer.transport_all_from_bundle( strategy: strategy, bundle: bundle, table: table, columns: columns, logger: logger, quiet: quiet ) new(exporter: exporter, importer: importer, logger: logger) end |
.transport_delta(schema:, table: nil, src_table: table, dest_table: table, condition:, columns:, delete_cond: nil, upsert_columns: nil, bucket: nil, txn_id:, filter:, logger: RedshiftConnector.logger, quiet: false) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/redshift-connector/connector.rb', line 8 def Connector.transport_delta( schema:, table: nil, src_table: table, dest_table: table, condition:, columns:, delete_cond: nil, upsert_columns: nil, bucket: nil, txn_id:, filter:, logger: RedshiftConnector.logger, quiet: false ) unless src_table and dest_table raise ArgumentError, "missing :table, :src_table or :dest_table" end bucket = bucket ? S3Bucket.get(bucket) : S3Bucket.default logger = NullLogger.new if quiet bundle = S3DataFileBundle.for_table( bucket: bucket, schema: schema, table: src_table, txn_id: txn_id, filter: filter, logger: logger ) exporter = Exporter.for_table_delta( bundle: bundle, schema: schema, table: src_table, columns: columns, condition: condition, logger: logger ) importer = Importer.transport_delta_from_bundle( bundle: bundle, table: dest_table, columns: columns, delete_cond: delete_cond, upsert_columns: upsert_columns, logger: logger, quiet: quiet ) new(exporter: exporter, importer: importer, logger: logger) end |
Instance Method Details
#execute ⇒ Object
105 106 107 108 |
# File 'lib/redshift-connector/connector.rb', line 105 def execute export if export_enabled? import if import_enabled? end |
#export ⇒ Object
110 111 112 113 |
# File 'lib/redshift-connector/connector.rb', line 110 def export @logger.info "==== export task ==================================================" @exporter.execute end |
#export_enabled? ⇒ Boolean
97 98 99 |
# File 'lib/redshift-connector/connector.rb', line 97 def export_enabled? not ENV['IMPORT_ONLY'] end |
#import ⇒ Object
115 116 117 118 |
# File 'lib/redshift-connector/connector.rb', line 115 def import @logger.info "==== import task ==================================================" @importer.execute end |
#import_enabled? ⇒ Boolean
101 102 103 |
# File 'lib/redshift-connector/connector.rb', line 101 def import_enabled? not ENV['EXPORT_ONLY'] end |