multiwoven-integrations 0.1.42 → 0.1.43

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: eee51b7ba03e877f2765da694f9ca7b4ede8e44e07ca74931d808f79fb828c06
4
- data.tar.gz: 21a23a656e09175222172eea24e562c95ccc97e7bebe92443cc60678d68050bf
3
+ metadata.gz: c2f57a8f398e40f9a12c710487ff9818640abab9e2b445a1ad1a3959350c35c6
4
+ data.tar.gz: 60837c95c23653870d97ca8daa865987e15d3c677f9111aaca1221d56d9eb323
5
5
  SHA512:
6
- metadata.gz: 388d743e298e3296fbd9bd12e5d29037d72bf4912f93ae8ae8b9d7f5285dbb2d39f39f1500f6ee3b6214e186564287eec8c3fe14d66f55cc53861585e3929e33
7
- data.tar.gz: e527726e1e69c57c07d7d6ab28194f2a84dfbbffb941f61e2b5fca927cecf486edcb7fa2cecbbcc8ccc1713c396e1723161e5ea55f0cc8d310ce2d888f6de845
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
- # 10000 records in single
44
- with_sftp_client(connection_config) do |sftp|
45
- sftp.file.open(file_path, "w") { |file| file.puts(csv_content) }
46
- write_success += records.size
47
- rescue StandardError => e
48
- handle_exception("SFTP:RECORD:WRITE:EXCEPTION", "error", e)
49
- write_failure += records.size
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(sync_config.destination.connection_specification[:destination_path], file_name)
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": 10000,
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(
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Multiwoven
4
4
  module Integrations
5
- VERSION = "0.1.42"
5
+ VERSION = "0.1.43"
6
6
 
7
7
  ENABLED_SOURCES = %w[
8
8
  Snowflake
@@ -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|
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.1.42
4
+ version: 0.1.43
5
5
  platform: ruby
6
6
  authors:
7
7
  - Subin T P