@microsoft/1ds-post-js 3.1.9 → 3.2.0
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/README.md +124 -5
- package/bundle/{ms.post-3.1.9.gbl.js → ms.post-3.2.0.gbl.js} +1706 -825
- package/bundle/ms.post-3.2.0.gbl.js.map +1 -0
- package/bundle/ms.post-3.2.0.gbl.min.js +7 -0
- package/bundle/ms.post-3.2.0.gbl.min.js.map +1 -0
- package/bundle/ms.post-3.2.0.integrity.json +46 -0
- package/bundle/{ms.post-3.1.9.js → ms.post-3.2.0.js} +1706 -825
- package/bundle/ms.post-3.2.0.js.map +1 -0
- package/bundle/ms.post-3.2.0.min.js +7 -0
- package/bundle/ms.post-3.2.0.min.js.map +1 -0
- package/bundle/ms.post.gbl.js +1705 -824
- package/bundle/ms.post.gbl.js.map +1 -1
- package/bundle/ms.post.gbl.min.js +2 -2
- package/bundle/ms.post.gbl.min.js.map +1 -1
- package/bundle/ms.post.integrity.json +17 -17
- package/bundle/ms.post.js +1705 -824
- package/bundle/ms.post.js.map +1 -1
- package/bundle/ms.post.min.js +2 -2
- package/bundle/ms.post.min.js.map +1 -1
- package/dist/ms.post.js +395 -212
- package/dist/ms.post.js.map +1 -1
- package/dist/ms.post.min.js +2 -2
- package/dist/ms.post.min.js.map +1 -1
- package/dist-esm/src/BatchNotificationActions.js +1 -1
- package/dist-esm/src/ClockSkewManager.js +1 -1
- package/dist-esm/src/Constants.d.ts +25 -0
- package/dist-esm/src/Constants.js +31 -0
- package/dist-esm/src/Constants.js.map +1 -0
- package/dist-esm/src/DataModels.d.ts +55 -0
- package/dist-esm/src/DataModels.js +1 -1
- package/dist-esm/src/EventBatch.d.ts +5 -2
- package/dist-esm/src/EventBatch.js +35 -15
- package/dist-esm/src/EventBatch.js.map +1 -1
- package/dist-esm/src/HttpManager.d.ts +2 -2
- package/dist-esm/src/HttpManager.js +186 -94
- package/dist-esm/src/HttpManager.js.map +1 -1
- package/dist-esm/src/Index.js +1 -1
- package/dist-esm/src/KillSwitch.js +1 -1
- package/dist-esm/src/PostChannel.d.ts +0 -4
- package/dist-esm/src/PostChannel.js +175 -107
- package/dist-esm/src/PostChannel.js.map +1 -1
- package/dist-esm/src/RetryPolicy.d.ts +20 -25
- package/dist-esm/src/RetryPolicy.js +35 -44
- package/dist-esm/src/RetryPolicy.js.map +1 -1
- package/dist-esm/src/Serializer.js +1 -1
- package/dist-esm/src/typings/XDomainRequest.js +1 -1
- package/package.json +3 -3
- package/src/Constants.ts +28 -0
- package/src/DataModels.ts +68 -0
- package/src/EventBatch.ts +47 -14
- package/src/HttpManager.ts +216 -98
- package/src/PostChannel.ts +207 -130
- package/src/RetryPolicy.ts +33 -38
- package/bundle/ms.post-3.1.9.gbl.js.map +0 -1
- package/bundle/ms.post-3.1.9.gbl.min.js +0 -7
- package/bundle/ms.post-3.1.9.gbl.min.js.map +0 -1
- package/bundle/ms.post-3.1.9.integrity.json +0 -46
- package/bundle/ms.post-3.1.9.js.map +0 -1
- package/bundle/ms.post-3.1.9.min.js +0 -7
- package/bundle/ms.post-3.1.9.min.js.map +0 -1
package/src/RetryPolicy.ts
CHANGED
|
@@ -9,43 +9,38 @@ const BaseBackoff = 3000;
|
|
|
9
9
|
const MaxBackoff = 600000;
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|| (httpStatusCode == 501)
|
|
32
|
-
|| (httpStatusCode == 505));
|
|
33
|
-
/* tslint:enable:triple-equals */
|
|
34
|
-
}
|
|
12
|
+
* Determine if the request should be retried for the given status code.
|
|
13
|
+
* The below expression reads that we should only retry for:
|
|
14
|
+
* - HttpStatusCodes that are smaller than 300.
|
|
15
|
+
* - HttpStatusCodes greater or equal to 500 (except for 501-NotImplement
|
|
16
|
+
* and 505-HttpVersionNotSupport).
|
|
17
|
+
* - HttpStatusCode 408-RequestTimeout.
|
|
18
|
+
* - HttpStatusCode 429.
|
|
19
|
+
* This is based on Microsoft.WindowsAzure.Storage.RetryPolicies.ExponentialRetry class
|
|
20
|
+
* @param httpStatusCode - The status code returned for the request.
|
|
21
|
+
* @returns True if request should be retried, false otherwise.
|
|
22
|
+
*/
|
|
23
|
+
export function retryPolicyShouldRetryForStatus(httpStatusCode: number): boolean {
|
|
24
|
+
/* tslint:disable:triple-equals */
|
|
25
|
+
// Disabling triple-equals rule to avoid httpOverrides from failing because they are returning a string value
|
|
26
|
+
return !((httpStatusCode >= 300 && httpStatusCode < 500 && httpStatusCode != 408 && httpStatusCode != 429)
|
|
27
|
+
|| (httpStatusCode == 501)
|
|
28
|
+
|| (httpStatusCode == 505));
|
|
29
|
+
/* tslint:enable:triple-equals */
|
|
30
|
+
}
|
|
35
31
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
32
|
+
/**
|
|
33
|
+
* Gets the number of milliseconds to back off before retrying the request. The
|
|
34
|
+
* back off duration is exponentially scaled based on the number of retries already
|
|
35
|
+
* done for the request.
|
|
36
|
+
* @param retriesSoFar - The number of times the request has already been retried.
|
|
37
|
+
* @returns The back off duration for the request before it can be retried.
|
|
38
|
+
*/
|
|
39
|
+
export function retryPolicyGetMillisToBackoffForRetry(retriesSoFar: number): number {
|
|
40
|
+
let waitDuration = 0;
|
|
41
|
+
let minBackoff = BaseBackoff * RandomizationLowerThreshold;
|
|
42
|
+
let maxBackoff = BaseBackoff * RandomizationUpperThreshold;
|
|
43
|
+
let randomBackoff = Math.floor(Math.random() * (maxBackoff - minBackoff)) + minBackoff;
|
|
44
|
+
waitDuration = Math.pow(2, retriesSoFar) * randomBackoff;
|
|
45
|
+
return Math.min(waitDuration, MaxBackoff);
|
|
51
46
|
}
|