presidium 4.0.0 → 4.0.1
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.
- package/DynamoDBGlobalSecondaryIndex.js +2 -1
- package/DynamoDBStream.js +3 -2
- package/DynamoDBTable.js +2 -1
- package/ECR.js +2 -1
- package/HTTP.js +1 -1
- package/S3Bucket.js +3 -2
- package/SecretsManager.js +2 -1
- package/internal/dynamoDBStreamListStreams.js +1 -0
- package/internal/retryHTTPRequest.js +17 -0
- package/internal/retryHTTPRequest.test.js +40 -0
- package/package.json +1 -1
|
@@ -24,6 +24,7 @@ const DynamoDBAttributeValueJSON =
|
|
|
24
24
|
require('./internal/DynamoDBAttributeValueJSON')
|
|
25
25
|
const hashJSON = require('./internal/hashJSON')
|
|
26
26
|
const sleep = require('./internal/sleep')
|
|
27
|
+
const retryHTTPRequest = require('./internal/retryHTTPRequest')
|
|
27
28
|
const createExpressionAttributeNames =
|
|
28
29
|
require('./internal/createExpressionAttributeNames')
|
|
29
30
|
const createExpressionAttributeValues =
|
|
@@ -227,7 +228,7 @@ class DynamoDBGlobalSecondaryIndex {
|
|
|
227
228
|
}
|
|
228
229
|
})
|
|
229
230
|
|
|
230
|
-
return this.http
|
|
231
|
+
return retryHTTPRequest(this.http, method, url, { headers, body: payload })
|
|
231
232
|
}
|
|
232
233
|
|
|
233
234
|
/**
|
package/DynamoDBStream.js
CHANGED
|
@@ -16,6 +16,7 @@ const AwsAuthorization = require('./internal/AwsAuthorization')
|
|
|
16
16
|
const AmzDate = require('./internal/AmzDate')
|
|
17
17
|
const Readable = require('./Readable')
|
|
18
18
|
const sleep = require('./internal/sleep')
|
|
19
|
+
const retryHTTPRequest = require('./internal/retryHTTPRequest')
|
|
19
20
|
const dynamoDBStreamGetStreamsIterator =
|
|
20
21
|
require('./internal/dynamoDBStreamGetStreamsIterator')
|
|
21
22
|
const dynamoDBStreamGetShardsIterator =
|
|
@@ -238,7 +239,7 @@ class DynamoDBStream {
|
|
|
238
239
|
}
|
|
239
240
|
})
|
|
240
241
|
|
|
241
|
-
return this.http
|
|
242
|
+
return retryHTTPRequest(this.http, method, url, { headers, body: payload })
|
|
242
243
|
}
|
|
243
244
|
|
|
244
245
|
/**
|
|
@@ -296,7 +297,7 @@ class DynamoDBStream {
|
|
|
296
297
|
}
|
|
297
298
|
})
|
|
298
299
|
|
|
299
|
-
return this.streamsHttp
|
|
300
|
+
return retryHTTPRequest(this.streamsHttp, method, url, { headers, body: payload })
|
|
300
301
|
}
|
|
301
302
|
|
|
302
303
|
/**
|
package/DynamoDBTable.js
CHANGED
|
@@ -25,6 +25,7 @@ const AwsError = require('./internal/AwsError')
|
|
|
25
25
|
const hashJSON = require('./internal/hashJSON')
|
|
26
26
|
const sleep = require('./internal/sleep')
|
|
27
27
|
const join = require('./internal/join')
|
|
28
|
+
const retryHTTPRequest = require('./internal/retryHTTPRequest')
|
|
28
29
|
const createExpressionAttributeNames =
|
|
29
30
|
require('./internal/createExpressionAttributeNames')
|
|
30
31
|
const createExpressionAttributeValues =
|
|
@@ -216,7 +217,7 @@ class DynamoDBTable {
|
|
|
216
217
|
}
|
|
217
218
|
})
|
|
218
219
|
|
|
219
|
-
return this.http
|
|
220
|
+
return retryHTTPRequest(this.http, method, url, { headers, body: payload })
|
|
220
221
|
}
|
|
221
222
|
|
|
222
223
|
/**
|
package/ECR.js
CHANGED
|
@@ -13,6 +13,7 @@ const AwsAuthorization = require('./internal/AwsAuthorization')
|
|
|
13
13
|
const AwsError = require('./internal/AwsError')
|
|
14
14
|
const userAgent = require('./userAgent')
|
|
15
15
|
const Readable = require('./Readable')
|
|
16
|
+
const retryHTTPRequest = require('./internal/retryHTTPRequest')
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* @name ECR
|
|
@@ -112,7 +113,7 @@ class ECR {
|
|
|
112
113
|
}
|
|
113
114
|
})
|
|
114
115
|
|
|
115
|
-
return this.http
|
|
116
|
+
return retryHTTPRequest(this.http, method, url, { headers, body: payload })
|
|
116
117
|
}
|
|
117
118
|
|
|
118
119
|
/**
|
package/HTTP.js
CHANGED
|
@@ -141,7 +141,7 @@ class HTTP {
|
|
|
141
141
|
resolve(response)
|
|
142
142
|
})
|
|
143
143
|
|
|
144
|
-
/* TODO remove this
|
|
144
|
+
/* TODO remove this and closeConnections from codebase (breaking)
|
|
145
145
|
request.on('socket', socket => {
|
|
146
146
|
this._sockets.add(socket)
|
|
147
147
|
})
|
package/S3Bucket.js
CHANGED
|
@@ -14,6 +14,7 @@ const AwsAuthorization = require('./internal/AwsAuthorization')
|
|
|
14
14
|
const AmzDate = require('./internal/AmzDate')
|
|
15
15
|
const AwsError = require('./internal/AwsError')
|
|
16
16
|
const parseURL = require('./internal/parseURL')
|
|
17
|
+
const retryHTTPRequest = require('./internal/retryHTTPRequest')
|
|
17
18
|
const createS3DeleteObjectError = require('./internal/createS3DeleteObjectError')
|
|
18
19
|
const XML = require('./XML')
|
|
19
20
|
const HTMLEntities = require('html-entities')
|
|
@@ -255,7 +256,7 @@ class S3Bucket {
|
|
|
255
256
|
headers: authorizationHeaders,
|
|
256
257
|
})
|
|
257
258
|
|
|
258
|
-
return this.http0
|
|
259
|
+
return retryHTTPRequest(this.http0, method, url, { headers, body })
|
|
259
260
|
}
|
|
260
261
|
|
|
261
262
|
/**
|
|
@@ -319,7 +320,7 @@ class S3Bucket {
|
|
|
319
320
|
headers: authorizationHeaders,
|
|
320
321
|
})
|
|
321
322
|
|
|
322
|
-
return this.http1
|
|
323
|
+
return retryHTTPRequest(this.http1, method, url, { headers, body })
|
|
323
324
|
}
|
|
324
325
|
|
|
325
326
|
// _putBucketEncryption() -> Promise<>
|
package/SecretsManager.js
CHANGED
|
@@ -15,6 +15,7 @@ const userAgent = require('./userAgent')
|
|
|
15
15
|
const Readable = require('./Readable')
|
|
16
16
|
const handleAwsResponse = require('./internal/handleAwsResponse')
|
|
17
17
|
const retryableErrorNames = require('./internal/retryableErrorNames')
|
|
18
|
+
const retryHTTPRequest = require('./internal/retryHTTPRequest')
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* @name SecretsManager
|
|
@@ -114,7 +115,7 @@ class SecretsManager {
|
|
|
114
115
|
}
|
|
115
116
|
})
|
|
116
117
|
|
|
117
|
-
return this.http
|
|
118
|
+
return retryHTTPRequest(this.http, method, url, { headers, body: payload })
|
|
118
119
|
}
|
|
119
120
|
|
|
120
121
|
/**
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const sleep = require('./sleep')
|
|
2
|
+
|
|
3
|
+
// retryHTTPRequest(http HTTP, method string, url string, options {
|
|
4
|
+
// headers: Object<string>,
|
|
5
|
+
// body: string,
|
|
6
|
+
// }) -> http.ServerResponse
|
|
7
|
+
async function retryHTTPRequest(http, method, url, options) {
|
|
8
|
+
try {
|
|
9
|
+
const response = await http[method](url, options)
|
|
10
|
+
return response
|
|
11
|
+
} catch {
|
|
12
|
+
await sleep(1000)
|
|
13
|
+
return retryHTTPRequest(http, method, url, options)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = retryHTTPRequest
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const Test = require('thunk-test')
|
|
2
|
+
const assert = require('assert')
|
|
3
|
+
const retryHTTPRequest = require('./retryHTTPRequest')
|
|
4
|
+
|
|
5
|
+
const test = new Test('retryHTTPRequest', async function integration() {
|
|
6
|
+
const http1 = {
|
|
7
|
+
async GET(url, options) {
|
|
8
|
+
return 'ok'
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
{
|
|
13
|
+
const response = await retryHTTPRequest(http1, 'GET', '/test', {})
|
|
14
|
+
assert.equal(response, 'ok')
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let retries = 0
|
|
18
|
+
const http2 = {
|
|
19
|
+
async GET(url, options) {
|
|
20
|
+
if (retries === 0) {
|
|
21
|
+
retries += 1
|
|
22
|
+
throw new Error('test')
|
|
23
|
+
}
|
|
24
|
+
return 'ok'
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
{
|
|
29
|
+
const response = await retryHTTPRequest(http2, 'GET', '/test', {})
|
|
30
|
+
assert.equal(response, 'ok')
|
|
31
|
+
assert.strictEqual(retries, 1)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
}).case()
|
|
35
|
+
|
|
36
|
+
if (process.argv[1] == __filename) {
|
|
37
|
+
test()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module.exports = test
|