multiwoven-integrations 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb9f117bf574599b93ccfd2238f1629166c473184837ec48a16a447650b1dc54
4
- data.tar.gz: efa39262c596d2b50bbd04d2d8a9d98889b708a9e2859e6ec3801b2c6eb79169
3
+ metadata.gz: 50ba719dc1cdacb377fe3caeadc0948944da43f2fce377d7db93f9ca3d5f1bea
4
+ data.tar.gz: 0f04916affd15488b2e5f7fe67b3031747d193b851dfa31e5085065bc8e6048e
5
5
  SHA512:
6
- metadata.gz: 959b53319cb4581fd8aeb2731891f967031a23096c42e1e855fa79802bf81e799a746ba62c1c08f20484c3a443418d2175e1d9218abd28939eceaf89b6f87964
7
- data.tar.gz: 22c706c8d47d9803cbdee5fa91a8f6862f7d0efb11c13466e2b0b0e07753a5e784e43443487a939a05f0cee0457bf310d12ce274e24ad322e5aa2cf8767c05ea
6
+ metadata.gz: e1a4bb4360df030a2a8124579a1d95b84ee9ae3b2f64eb59a9e4502d481d1f5a8470216981c0303868cdca22dff9c8d8a14ca7bf01547277c4bf4bb6d72da78c
7
+ data.tar.gz: 6251c28f1bbbd38beeed2e1008715a146ad0d2fd7826c60c7508dc177e43bdf4f3bf7a792b7976c031fbfad9a0d77946ab301949cbaf9eb95acc5024596af3d8
@@ -9,6 +9,12 @@ module Multiwoven
9
9
  raise "Not implemented"
10
10
  # return Protocol::TrackingMessage
11
11
  end
12
+
13
+ def tracking_message(success, failure, log_message_array)
14
+ Multiwoven::Integrations::Protocol::TrackingMessage.new(
15
+ success: success, failed: failure, logs: log_message_array
16
+ ).to_multiwoven_message
17
+ end
12
18
  end
13
19
  end
14
20
  end
@@ -53,6 +53,14 @@ module Multiwoven
53
53
  reporter&.report(exception, meta)
54
54
  end
55
55
 
56
+ def log_request_response(level, request, response)
57
+ Integrations::Protocol::LogMessage.new(
58
+ name: self.class.name,
59
+ level: level,
60
+ message: { request: request.to_s, response: response.to_s, level: level }.to_json
61
+ )
62
+ end
63
+
56
64
  def create_log_message(context, type, exception)
57
65
  Integrations::Protocol::LogMessage.new(
58
66
  name: context,
@@ -46,6 +46,7 @@ module Multiwoven::Integrations::Destination
46
46
  connection_config = sync_config.destination.connection_specification.with_indifferent_access
47
47
  table_name = sync_config.stream.name
48
48
  primary_key = sync_config.model.primary_key
49
+ log_message_array = []
49
50
  db = create_connection(connection_config)
50
51
 
51
52
  write_success = 0
@@ -55,8 +56,9 @@ module Multiwoven::Integrations::Destination
55
56
  query = Multiwoven::Integrations::Core::QueryBuilder.perform(action, table_name, record, primary_key)
56
57
  logger.debug("POSTGRESQL:WRITE:QUERY query = #{query} sync_id = #{sync_config.sync_id} sync_run_id = #{sync_config.sync_run_id}")
57
58
  begin
58
- db.exec(query)
59
+ response = db.exec(query)
59
60
  write_success += 1
61
+ log_message_array << log_request_response("info", query, response)
60
62
  rescue StandardError => e
61
63
  handle_exception(e, {
62
64
  context: "POSTGRESQL:RECORD:WRITE:EXCEPTION",
@@ -65,9 +67,10 @@ module Multiwoven::Integrations::Destination
65
67
  sync_run_id: sync_config.sync_run_id
66
68
  })
67
69
  write_failure += 1
70
+ log_message_array << log_request_response("error", query, e.message)
68
71
  end
69
72
  end
70
- tracking_message(write_success, write_failure)
73
+ tracking_message(write_success, write_failure, log_message_array)
71
74
  rescue StandardError => e
72
75
  handle_exception(e, {
73
76
  context: "POSTGRESQL:RECORD:WRITE:EXCEPTION",
@@ -119,12 +122,6 @@ module Multiwoven::Integrations::Destination
119
122
  }
120
123
  end
121
124
  end
122
-
123
- def tracking_message(success, failure)
124
- Multiwoven::Integrations::Protocol::TrackingMessage.new(
125
- success: success, failed: failure
126
- ).to_multiwoven_message
127
- end
128
125
  end
129
126
  end
130
127
  end
@@ -80,10 +80,14 @@ module Multiwoven
80
80
  write_success = 0
81
81
  write_failure = 0
82
82
  properties = stream.json_schema[:properties]
83
+ log_message_array = []
84
+
83
85
  records.each do |record_object|
84
86
  record = extract_data(record_object, properties)
85
- process_record(stream, record)
87
+ args = [stream.name, "Id", record]
88
+ response = send_data_to_salesforce(args)
86
89
  write_success += 1
90
+ log_message_array << log_request_response("info", args, response)
87
91
  rescue StandardError => e
88
92
  # TODO: add sync_id and sync run id to the logs
89
93
  handle_exception(e, {
@@ -93,18 +97,14 @@ module Multiwoven
93
97
  sync_run_id: @sync_config.sync_run_id
94
98
  })
95
99
  write_failure += 1
100
+ log_message_array << log_request_response("error", args, e.message)
96
101
  end
97
- tracking_message(write_success, write_failure)
98
- end
99
-
100
- def process_record(stream, record)
101
- send_data_to_salesforce(stream.name, record)
102
+ tracking_message(write_success, write_failure, log_message_array)
102
103
  end
103
104
 
104
- def send_data_to_salesforce(stream_name, record = {})
105
+ def send_data_to_salesforce(args)
105
106
  method_name = "upsert!"
106
- args = [stream_name, "Id", record]
107
- @logger.debug("sync_id: #{@sync_config.sync_id}, sync_run_id: #{@sync_config.sync_run_id}, record: #{record}")
107
+ @logger.debug("sync_id: #{@sync_config.sync_id}, sync_run_id: #{@sync_config.sync_run_id}, args: #{args}")
108
108
  @client.send(method_name, *args)
109
109
  end
110
110
 
@@ -124,12 +124,6 @@ module Multiwoven
124
124
  read_json(CATALOG_SPEC_PATH)
125
125
  end
126
126
 
127
- def tracking_message(success, failure)
128
- Multiwoven::Integrations::Protocol::TrackingMessage.new(
129
- success: success, failed: failure
130
- ).to_multiwoven_message
131
- end
132
-
133
127
  def log_debug(message)
134
128
  Multiwoven::Integrations::Service.logger.debug(message)
135
129
  end
@@ -197,6 +197,7 @@ module Multiwoven
197
197
  attribute :success, Types::Integer.default(0)
198
198
  attribute :failed, Types::Integer.default(0)
199
199
  attribute? :meta, Types::Hash
200
+ attribute? :logs, Types::Array.of(LogMessage)
200
201
 
201
202
  def to_multiwoven_message
202
203
  MultiwovenMessage.new(
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Multiwoven
4
4
  module Integrations
5
- VERSION = "0.3.4"
5
+ VERSION = "0.3.5"
6
6
 
7
7
  ENABLED_SOURCES = %w[
8
8
  Snowflake
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multiwoven-integrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Subin T P