Class: Multiwoven::Integrations::Destination::AmazonS3::Client

Inherits:
DestinationConnector
  • Object
show all
Defined in:
lib/multiwoven/integrations/destination/amazon_s3/client.rb

Instance Method Summary collapse

Instance Method Details

#check_connection(connection_config) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/multiwoven/integrations/destination/amazon_s3/client.rb', line 7

def check_connection(connection_config)
  connection_config = connection_config.with_indifferent_access
  conn = create_connection(connection_config)
  conn.head_bucket(bucket: connection_config[:bucket_name])
  ConnectionStatus.new(status: ConnectionStatusType["succeeded"]).to_multiwoven_message
rescue StandardError => e
  ConnectionStatus.new(status: ConnectionStatusType["failed"], message: e.message).to_multiwoven_message
end

#discover(connection_config) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/multiwoven/integrations/destination/amazon_s3/client.rb', line 16

def discover(connection_config)
  connection_config = connection_config.with_indifferent_access
  conn = create_connection(connection_config)
  records = discover_columns_from_s3(conn, connection_config)
  grouped = group_by_table(records, connection_config[:file_name])
  catalog = Catalog.new(streams: create_streams(grouped))
  catalog.to_multiwoven_message
rescue StandardError => e
  handle_exception(e, {
                     context: "AMAZONS3:DISCOVER:EXCEPTION",
                     type: "error"
                   })
end

#write(sync_config, records, _action = "destination_insert") ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/multiwoven/integrations/destination/amazon_s3/client.rb', line 30

def write(sync_config, records, _action = "destination_insert")
  records_size = records.size
  log_message_array = []
  write_success = upload_csv_content(sync_config, records)
  write_failure = records_size - write_success
  log_message_array << log_request_response("info", @args, @response)
  tracking_message(write_success, write_failure, log_message_array)
rescue StandardError => e
  handle_exception(e, {
                     context: "AMAZONS3:WRITE:EXCEPTION",
                     type: "error",
                     sync_id: sync_config.sync_id,
                     sync_run_id: sync_config.sync_run_id
                   })
end