salesforce_chunker 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +5 -5
- data/LICENSE.txt +1 -1
- data/README.md +2 -0
- data/lib/salesforce_chunker/connection.rb +30 -4
- data/lib/salesforce_chunker/job.rb +1 -1
- data/lib/salesforce_chunker/version.rb +1 -1
- data/lib/salesforce_chunker.rb +3 -1
- data/salesforce_chunker.gemspec +1 -1
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bce2e320c05d4d8a6cd855eeedc8eac3bb2fd02a0a2d90be3743d156fc326127
|
4
|
+
data.tar.gz: 88e0b977efdf78f298adceb9a09b5d31b67ecd59e58884e9ac2d649de15ac30b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3294b08e552ac9dad461f13c9678ee48823f8fc3a708db6acabbf6574ad6f0715bcb0947fee78836d9f0d212ec713b555ab017268664d25ee40c1e75a78f939a
|
7
|
+
data.tar.gz: addb0a2b786fc330f1366582e616bf9e63677fe6664873d14189f923c9a96527ee50a17685aab2b8f021b548cbb0afaa20f59eaf6b85a7785633a4f62b5d599f
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 1.2.0 - 2019-06-14
|
4
|
+
|
5
|
+
- Added an include_deleted flag to perform a queryAll operation.
|
6
|
+
- Disabled explicit GZIP encoding to work with the latest versions of HTTParty.
|
7
|
+
- Added a retry for requests to recover from Net::ReadTimeout errors
|
8
|
+
|
3
9
|
## 1.1.1 - 2018-11-26
|
4
10
|
|
5
11
|
- Reimplemented ManualChunkingQuery using CSV batch results.
|
data/Gemfile.lock
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
salesforce_chunker (1.
|
5
|
-
httparty (~> 0.
|
4
|
+
salesforce_chunker (1.2.0)
|
5
|
+
httparty (~> 0.15)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
coderay (1.1.2)
|
11
|
-
httparty (0.
|
11
|
+
httparty (0.17.0)
|
12
12
|
mime-types (~> 3.0)
|
13
13
|
multi_xml (>= 0.5.2)
|
14
14
|
metaclass (0.0.4)
|
15
15
|
method_source (0.9.0)
|
16
16
|
mime-types (3.2.2)
|
17
17
|
mime-types-data (~> 3.2015)
|
18
|
-
mime-types-data (3.
|
18
|
+
mime-types-data (3.2019.0331)
|
19
19
|
minitest (5.11.3)
|
20
20
|
mocha (1.5.0)
|
21
21
|
metaclass (~> 0.0.1)
|
@@ -37,4 +37,4 @@ DEPENDENCIES
|
|
37
37
|
salesforce_chunker!
|
38
38
|
|
39
39
|
BUNDLED WITH
|
40
|
-
1.17.
|
40
|
+
1.17.3
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -76,6 +76,7 @@ options = {
|
|
76
76
|
logger: nil,
|
77
77
|
log_output: STDOUT,
|
78
78
|
job_type: "primary_key_chunking",
|
79
|
+
include_deleted: true,
|
79
80
|
}
|
80
81
|
|
81
82
|
client.query(options) do |result|
|
@@ -93,6 +94,7 @@ end
|
|
93
94
|
| logger | optional | logger to use. Must be instance of or similar to rails logger. |
|
94
95
|
| log_output | optional | log output to use. i.e. `STDOUT`. |
|
95
96
|
| job_type | optional | defaults to `"primary_key_chunking"`. Can also be set to `"single_batch"`. |
|
97
|
+
| include_deleted | optional | defaults to `false`. Whether to include deleted records. |
|
96
98
|
|
97
99
|
`query` can either be called with a block, or will return an enumerator:
|
98
100
|
|
@@ -21,7 +21,6 @@ module SalesforceChunker
|
|
21
21
|
@default_headers = {
|
22
22
|
"Content-Type": "application/json",
|
23
23
|
"X-SFDC-Session": result["sessionId"],
|
24
|
-
"Accept-Encoding": "gzip",
|
25
24
|
}
|
26
25
|
rescue NoMethodError
|
27
26
|
raise ConnectionError, response["Envelope"]["Body"]["Fault"]["faultstring"]
|
@@ -33,19 +32,25 @@ module SalesforceChunker
|
|
33
32
|
|
34
33
|
def post(url, body, headers={})
|
35
34
|
@log.info "POST: #{url}"
|
36
|
-
response =
|
35
|
+
response = self.class.retry_block(log: @log, rescues: Net::ReadTimeout) do
|
36
|
+
HTTParty.post(@base_url + url, headers: @default_headers.merge(headers), body: body)
|
37
|
+
end
|
37
38
|
self.class.check_response_error(response.parsed_response)
|
38
39
|
end
|
39
40
|
|
40
41
|
def get_json(url, headers={})
|
41
42
|
@log.info "GET: #{url}"
|
42
|
-
response =
|
43
|
+
response = self.class.retry_block(log: @log, rescues: Net::ReadTimeout) do
|
44
|
+
HTTParty.get(@base_url + url, headers: @default_headers.merge(headers))
|
45
|
+
end
|
43
46
|
self.class.check_response_error(response.parsed_response)
|
44
47
|
end
|
45
48
|
|
46
49
|
def get(url, headers={})
|
47
50
|
@log.info "GET: #{url}"
|
48
|
-
|
51
|
+
self.class.retry_block(log: @log, rescues: Net::ReadTimeout) do
|
52
|
+
HTTParty.get(@base_url + url, headers: @default_headers.merge(headers)).body
|
53
|
+
end
|
49
54
|
end
|
50
55
|
|
51
56
|
private
|
@@ -77,5 +82,26 @@ module SalesforceChunker
|
|
77
82
|
response
|
78
83
|
end
|
79
84
|
end
|
85
|
+
|
86
|
+
MAX_TRIES = 5
|
87
|
+
SLEEP_DURATION = 10
|
88
|
+
|
89
|
+
def self.retry_block(log: log, tries: MAX_TRIES, sleep_duration: SLEEP_DURATION, rescues:, &block)
|
90
|
+
attempt_number = 1
|
91
|
+
|
92
|
+
begin
|
93
|
+
return block.call
|
94
|
+
rescue *rescues => e
|
95
|
+
log.warn "Retry block attempt #{attempt_number} rescued exception: #{e}"
|
96
|
+
if attempt_number >= tries
|
97
|
+
log.error "Maximum number of tries (#{tries}) was reached in retry_block. Raising exception."
|
98
|
+
raise e
|
99
|
+
else
|
100
|
+
attempt_number += 1
|
101
|
+
sleep sleep_duration
|
102
|
+
retry
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
80
106
|
end
|
81
107
|
end
|
data/lib/salesforce_chunker.rb
CHANGED
@@ -29,10 +29,12 @@ module SalesforceChunker
|
|
29
29
|
job_class = SalesforceChunker::PrimaryKeyChunkingQuery
|
30
30
|
end
|
31
31
|
|
32
|
+
operation = options[:include_deleted] ? "queryAll" : "query"
|
33
|
+
|
32
34
|
job_params = {
|
33
35
|
connection: @connection,
|
34
36
|
object: object,
|
35
|
-
operation:
|
37
|
+
operation: operation,
|
36
38
|
query: query,
|
37
39
|
**options.slice(:batch_size, :logger, :log_output)
|
38
40
|
}
|
data/salesforce_chunker.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.add_dependency "httparty", "~> 0.
|
24
|
+
spec.add_dependency "httparty", "~> 0.15"
|
25
25
|
spec.add_development_dependency "bundler", "~> 1.16"
|
26
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
27
27
|
spec.add_development_dependency "minitest", "~> 5.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: salesforce_chunker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Curtis Holmes
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.15'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.15'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,8 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
142
|
- !ruby/object:Gem::Version
|
143
143
|
version: '0'
|
144
144
|
requirements: []
|
145
|
-
|
146
|
-
rubygems_version: 2.7.6
|
145
|
+
rubygems_version: 3.0.2
|
147
146
|
signing_key:
|
148
147
|
specification_version: 4
|
149
148
|
summary: Salesforce Bulk API Client
|