multiwoven-integrations 0.1.42 → 0.1.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/multiwoven/integrations/core/utils.rb +3 -3
- data/lib/multiwoven/integrations/destination/sftp/client.rb +20 -9
- data/lib/multiwoven/integrations/destination/sftp/config/catalog.json +2 -2
- data/lib/multiwoven/integrations/protocol/protocol.rb +1 -1
- data/lib/multiwoven/integrations/rollout.rb +1 -1
- data/lib/multiwoven/integrations/source/salesforce_consumer_goods_cloud/client.rb +6 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2f57a8f398e40f9a12c710487ff9818640abab9e2b445a1ad1a3959350c35c6
|
4
|
+
data.tar.gz: 60837c95c23653870d97ca8daa865987e15d3c677f9111aaca1221d56d9eb323
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 474a754e9cbd76963d786e6c059f96d731cc05ef7d26427e6f8606a8383dfa130e2a4905a9ebaed6af65d7495de56cea80c566940ed8e76355a8c6b27b34f783
|
7
|
+
data.tar.gz: e4073c88c0b76e56f46497841abdcc34b02f8b6cfa33b25b418abc4d37759702cc295c8957d2632301ce8cf596526e622e2087b35a484ea187e1bfcc670d457e
|
@@ -79,7 +79,8 @@ module Multiwoven
|
|
79
79
|
streams: streams,
|
80
80
|
request_rate_limit: catalog_json["request_rate_limit"] || 60,
|
81
81
|
request_rate_limit_unit: catalog_json["request_rate_limit_unit"] || "minute",
|
82
|
-
request_rate_concurrency: catalog_json["request_rate_concurrency"] || 10
|
82
|
+
request_rate_concurrency: catalog_json["request_rate_concurrency"] || 10,
|
83
|
+
schema_mode: catalog_json["schema_mode"] || ["schema"]
|
83
84
|
)
|
84
85
|
end
|
85
86
|
|
@@ -95,8 +96,7 @@ module Multiwoven
|
|
95
96
|
request_rate_limit: stream_json["request_rate_limit"].to_i,
|
96
97
|
request_rate_limit_unit: stream_json["request_rate_limit_unit"] || "minute",
|
97
98
|
request_rate_concurrency: stream_json["request_rate_concurrency"].to_i,
|
98
|
-
supported_sync_modes: stream_json["supported_sync_modes"]
|
99
|
-
schema_mode: stream_json["schema_mode"]
|
99
|
+
supported_sync_modes: stream_json["supported_sync_modes"]
|
100
100
|
)
|
101
101
|
end
|
102
102
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Multiwoven::Integrations::Destination
|
4
4
|
module Sftp
|
5
5
|
include Multiwoven::Integrations::Core
|
6
|
-
class Client < DestinationConnector
|
6
|
+
class Client < DestinationConnector # rubocop:disable Metrics/ClassLength
|
7
7
|
prepend Multiwoven::Integrations::Core::Fullrefresher
|
8
8
|
prepend Multiwoven::Integrations::Core::RateLimiter
|
9
9
|
|
@@ -37,16 +37,21 @@ module Multiwoven::Integrations::Destination
|
|
37
37
|
def write(sync_config, records, _action = "insert")
|
38
38
|
connection_config = sync_config.destination.connection_specification.with_indifferent_access
|
39
39
|
file_path = generate_file_path(sync_config)
|
40
|
+
local_file_name = generate_local_file_name(sync_config)
|
40
41
|
csv_content = generate_csv_content(records)
|
41
42
|
write_success = 0
|
42
43
|
write_failure = 0
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
44
|
+
|
45
|
+
Tempfile.create([local_file_name, ".csv"]) do |tempfile|
|
46
|
+
tempfile.write(csv_content)
|
47
|
+
tempfile.close
|
48
|
+
with_sftp_client(connection_config) do |sftp|
|
49
|
+
sftp.upload!(tempfile.path, file_path)
|
50
|
+
write_success += records.size
|
51
|
+
rescue StandardError => e
|
52
|
+
handle_exception("SFTP:RECORD:WRITE:EXCEPTION", "error", e)
|
53
|
+
write_failure += records.size
|
54
|
+
end
|
50
55
|
end
|
51
56
|
tracking_message(write_success, write_failure)
|
52
57
|
rescue StandardError => e
|
@@ -78,9 +83,15 @@ module Multiwoven::Integrations::Destination
|
|
78
83
|
private
|
79
84
|
|
80
85
|
def generate_file_path(sync_config)
|
86
|
+
connection_specification = sync_config.destination.connection_specification.with_indifferent_access
|
81
87
|
timestamp = Time.now.strftime("%Y%m%d-%H%M%S")
|
82
88
|
file_name = "#{sync_config.stream.name}_#{timestamp}.csv"
|
83
|
-
File.join(
|
89
|
+
File.join(connection_specification[:destination_path], file_name)
|
90
|
+
end
|
91
|
+
|
92
|
+
def generate_local_file_name(sync_config)
|
93
|
+
timestamp = Time.now.strftime("%Y%m%d-%H%M%S")
|
94
|
+
"#{sync_config.stream.name}_#{timestamp}"
|
84
95
|
end
|
85
96
|
|
86
97
|
def generate_csv_content(records)
|
@@ -2,13 +2,13 @@
|
|
2
2
|
"request_rate_limit": 600,
|
3
3
|
"request_rate_limit_unit": "minute",
|
4
4
|
"request_rate_concurrency": 10,
|
5
|
+
"schema_mode": ["schemaless"],
|
5
6
|
"streams": [
|
6
7
|
{
|
7
8
|
"name": "sftp",
|
8
9
|
"batch_support": true,
|
9
|
-
"batch_size":
|
10
|
+
"batch_size": 100000,
|
10
11
|
"action": "create",
|
11
|
-
"schema_mode": ["schemaless"],
|
12
12
|
"json_schema": {},
|
13
13
|
"supported_sync_modes": ["full_refresh","incremental"]
|
14
14
|
}
|
@@ -125,7 +125,6 @@ module Multiwoven
|
|
125
125
|
attribute? :request_rate_limit, Types::Integer
|
126
126
|
attribute? :request_rate_limit_unit, RequestRateLimitingUnit
|
127
127
|
attribute? :request_rate_concurrency, Types::Integer
|
128
|
-
attribute? :schema_mode, Types::Array.of(SchemaMode).optional.default(["schema"])
|
129
128
|
|
130
129
|
def rate_limit_unit_seconds
|
131
130
|
case request_rate_limit_unit
|
@@ -148,6 +147,7 @@ module Multiwoven
|
|
148
147
|
attribute? :request_rate_limit, Types::Integer.default(60)
|
149
148
|
attribute? :request_rate_limit_unit, RequestRateLimitingUnit
|
150
149
|
attribute? :request_rate_concurrency, Types::Integer.default(10)
|
150
|
+
attribute? :schema_mode, Types::Array.of(SchemaMode).optional.default(["schema"])
|
151
151
|
|
152
152
|
def to_multiwoven_message
|
153
153
|
MultiwovenMessage.new(
|
@@ -39,8 +39,13 @@ module Multiwoven
|
|
39
39
|
def read(sync_config)
|
40
40
|
connection_config = sync_config.source.connection_specification.with_indifferent_access
|
41
41
|
initialize_client(connection_config)
|
42
|
+
return [] if sync_config.offset&.> 2000
|
43
|
+
|
44
|
+
# TODO: Salesforce imposes a limit on the use of OFFSET in SOQL queries, where you cannot skip(offset) more than 2000 records.
|
45
|
+
# This limitation can hinder the retrieval of large datasets in a single query.
|
46
|
+
# To overcome this, we need a cursor-based pagination strategy instead of relying on OFFSET.
|
47
|
+
# query = batched_query(query, sync_config.limit, sync_config.offset) unless sync_config.limit.nil? && sync_config.offset.nil?
|
42
48
|
query = sync_config.model.query
|
43
|
-
query = batched_query(query, sync_config.limit, sync_config.offset) unless sync_config.limit.nil? && sync_config.offset.nil?
|
44
49
|
exclude_keys = ["attributes"]
|
45
50
|
queried_data = @client.query(query)
|
46
51
|
results = queried_data.map do |record|
|