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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9aabe3e30bb91a83ba214f11c224f003869420e4f5e2bdaf0fd7cc89ad4b669
4
- data.tar.gz: fcb13aaa42d91efbfffaa047b6c3f8e21d378fa2a318e5ec4ab4cb29736b52d2
3
+ metadata.gz: bce2e320c05d4d8a6cd855eeedc8eac3bb2fd02a0a2d90be3743d156fc326127
4
+ data.tar.gz: 88e0b977efdf78f298adceb9a09b5d31b67ecd59e58884e9ac2d649de15ac30b
5
5
  SHA512:
6
- metadata.gz: ff8e83600ff22d71455a5ff84fa1e997e7badbb2b4a6db5c885d12748ea8b6867a7adf3570dbc361bc9fbe233f1c22ed7bec9e411815dae8b38026082726609a
7
- data.tar.gz: 12023fee018edb1550414fbb16fd918896142fed885970afed558b55fffcd50b13c692ec499ef07a6c7bd3a0c3d0ef50ffb9287fdaa9431e4e08032d76f9a388
6
+ metadata.gz: 3294b08e552ac9dad461f13c9678ee48823f8fc3a708db6acabbf6574ad6f0715bcb0947fee78836d9f0d212ec713b555ab017268664d25ee40c1e75a78f939a
7
+ data.tar.gz: addb0a2b786fc330f1366582e616bf9e63677fe6664873d14189f923c9a96527ee50a17685aab2b8f021b548cbb0afaa20f59eaf6b85a7785633a4f62b5d599f
data/.travis.yml CHANGED
@@ -2,4 +2,4 @@ sudo: false
2
2
  language: ruby
3
3
  rvm:
4
4
  - 2.5.0
5
- before_install: gem install bundler -v 1.17.1
5
+ before_install: gem install bundler -v 1.17.3
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.1.1)
5
- httparty (~> 0.13)
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.16.3)
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.2018.0812)
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.1
40
+ 1.17.3
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018 Shopify
3
+ Copyright (c) 2018-2019 Shopify
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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 = HTTParty.post(@base_url + url, headers: @default_headers.merge(headers), body: body)
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 = HTTParty.get(@base_url + url, headers: @default_headers.merge(headers))
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
- HTTParty.get(@base_url + url, headers: @default_headers.merge(headers)).body
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
@@ -4,7 +4,7 @@ module SalesforceChunker
4
4
  class Job
5
5
  attr_reader :batches_count
6
6
 
7
- QUERY_OPERATIONS = ["query", "queryall"].freeze
7
+ QUERY_OPERATIONS = ["query", "queryAll"].freeze
8
8
  DEFAULT_RETRY_SECONDS = 10
9
9
  DEFAULT_TIMEOUT_SECONDS = 3600
10
10
 
@@ -1,3 +1,3 @@
1
1
  module SalesforceChunker
2
- VERSION = "1.1.1"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -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: "query",
37
+ operation: operation,
36
38
  query: query,
37
39
  **options.slice(:batch_size, :logger, :log_output)
38
40
  }
@@ -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.13"
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.1.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: 2018-11-26 00:00:00.000000000 Z
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.13'
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.13'
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
- rubyforge_project:
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