@cdklabs/cdk-ecs-codedeploy 0.0.102 → 0.0.104
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/.jsii +70 -5
- package/.projenrc.ts +1 -1
- package/lib/api-canary/index.js +1 -1
- package/lib/ecs-appspec/index.js +1 -1
- package/lib/ecs-deployment/index.js +1 -1
- package/lib/ecs-patterns/application-load-balanced-codedeployed-fargate-service.js +1 -1
- package/node_modules/@aws-sdk/abort-controller/package.json +2 -2
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/CodeDeploy.d.ts +48 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/CodeDeployClient.d.ts +24 -4
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/AddTagsToOnPremisesInstancesCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/BatchGetApplicationRevisionsCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/BatchGetApplicationsCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/BatchGetDeploymentGroupsCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/BatchGetDeploymentInstancesCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/BatchGetDeploymentTargetsCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/BatchGetDeploymentsCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/BatchGetOnPremisesInstancesCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/ContinueDeploymentCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/CreateApplicationCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/CreateDeploymentCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/CreateDeploymentConfigCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/CreateDeploymentGroupCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/DeleteApplicationCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/DeleteDeploymentConfigCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/DeleteDeploymentGroupCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/DeleteGitHubAccountTokenCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/DeleteResourcesByExternalIdCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/DeregisterOnPremisesInstanceCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/GetApplicationCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/GetApplicationRevisionCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/GetDeploymentCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/GetDeploymentConfigCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/GetDeploymentGroupCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/GetDeploymentInstanceCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/GetDeploymentTargetCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/GetOnPremisesInstanceCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/ListApplicationRevisionsCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/ListApplicationsCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/ListDeploymentConfigsCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/ListDeploymentGroupsCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/ListDeploymentInstancesCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/ListDeploymentTargetsCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/ListDeploymentsCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/ListGitHubAccountTokenNamesCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/ListOnPremisesInstancesCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/ListTagsForResourceCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/PutLifecycleEventHookExecutionStatusCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/RegisterApplicationRevisionCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/RegisterOnPremisesInstanceCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/RemoveTagsFromOnPremisesInstancesCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/SkipWaitTimeForInstanceTerminationCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/StopDeploymentCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/TagResourceCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/UntagResourceCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/UpdateApplicationCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/commands/UpdateDeploymentGroupCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/models/CodeDeployServiceException.d.ts +2 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/models/models_0.d.ts +382 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/pagination/Interfaces.d.ts +3 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/pagination/ListApplicationRevisionsPaginator.d.ts +3 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/pagination/ListApplicationsPaginator.d.ts +3 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/pagination/ListDeploymentConfigsPaginator.d.ts +3 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/pagination/ListDeploymentGroupsPaginator.d.ts +3 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/pagination/ListDeploymentInstancesPaginator.d.ts +3 -0
- package/node_modules/@aws-sdk/client-codedeploy/dist-types/pagination/ListDeploymentsPaginator.d.ts +3 -0
- package/node_modules/@aws-sdk/client-codedeploy/package.json +30 -30
- package/node_modules/@aws-sdk/client-sso/dist-types/SSO.d.ts +5 -0
- package/node_modules/@aws-sdk/client-sso/dist-types/SSOClient.d.ts +24 -4
- package/node_modules/@aws-sdk/client-sso/dist-types/commands/GetRoleCredentialsCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-sso/dist-types/commands/ListAccountRolesCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-sso/dist-types/commands/ListAccountsCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-sso/dist-types/commands/LogoutCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-sso/dist-types/models/SSOServiceException.d.ts +2 -0
- package/node_modules/@aws-sdk/client-sso/dist-types/models/models_0.d.ts +28 -0
- package/node_modules/@aws-sdk/client-sso/dist-types/pagination/Interfaces.d.ts +3 -0
- package/node_modules/@aws-sdk/client-sso/dist-types/pagination/ListAccountRolesPaginator.d.ts +3 -0
- package/node_modules/@aws-sdk/client-sso/dist-types/pagination/ListAccountsPaginator.d.ts +3 -0
- package/node_modules/@aws-sdk/client-sso/package.json +26 -26
- package/node_modules/@aws-sdk/client-sso-oidc/dist-types/SSOOIDC.d.ts +4 -0
- package/node_modules/@aws-sdk/client-sso-oidc/dist-types/SSOOIDCClient.d.ts +24 -4
- package/node_modules/@aws-sdk/client-sso-oidc/dist-types/commands/CreateTokenCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-sso-oidc/dist-types/commands/RegisterClientCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-sso-oidc/dist-types/commands/StartDeviceAuthorizationCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-sso-oidc/dist-types/models/SSOOIDCServiceException.d.ts +2 -0
- package/node_modules/@aws-sdk/client-sso-oidc/dist-types/models/models_0.d.ts +30 -0
- package/node_modules/@aws-sdk/client-sso-oidc/package.json +26 -26
- package/node_modules/@aws-sdk/client-sts/dist-cjs/protocols/Aws_query.js +19 -83
- package/node_modules/@aws-sdk/client-sts/dist-es/protocols/Aws_query.js +19 -83
- package/node_modules/@aws-sdk/client-sts/dist-types/STS.d.ts +10 -1
- package/node_modules/@aws-sdk/client-sts/dist-types/STSClient.d.ts +24 -4
- package/node_modules/@aws-sdk/client-sts/dist-types/commands/AssumeRoleCommand.d.ts +17 -1
- package/node_modules/@aws-sdk/client-sts/dist-types/commands/AssumeRoleWithSAMLCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-sts/dist-types/commands/AssumeRoleWithWebIdentityCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-sts/dist-types/commands/DecodeAuthorizationMessageCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-sts/dist-types/commands/GetAccessKeyInfoCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-sts/dist-types/commands/GetCallerIdentityCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-sts/dist-types/commands/GetFederationTokenCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-sts/dist-types/commands/GetSessionTokenCommand.d.ts +16 -0
- package/node_modules/@aws-sdk/client-sts/dist-types/models/STSServiceException.d.ts +2 -0
- package/node_modules/@aws-sdk/client-sts/dist-types/models/models_0.d.ts +47 -0
- package/node_modules/@aws-sdk/client-sts/package.json +29 -29
- package/node_modules/@aws-sdk/config-resolver/package.json +5 -5
- package/node_modules/@aws-sdk/credential-provider-env/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-imds/package.json +5 -5
- package/node_modules/@aws-sdk/credential-provider-ini/dist-cjs/resolveProcessCredentials.js +1 -3
- package/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveProcessCredentials.js +1 -3
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +9 -9
- package/node_modules/@aws-sdk/credential-provider-node/package.json +10 -10
- package/node_modules/@aws-sdk/credential-provider-process/package.json +4 -4
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +6 -6
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
- package/node_modules/@aws-sdk/fetch-http-handler/package.json +5 -5
- package/node_modules/@aws-sdk/hash-node/package.json +2 -2
- package/node_modules/@aws-sdk/invalid-dependency/package.json +2 -2
- package/node_modules/@aws-sdk/middleware-content-length/package.json +3 -3
- package/node_modules/@aws-sdk/middleware-endpoint/package.json +7 -7
- package/node_modules/@aws-sdk/middleware-host-header/package.json +3 -3
- package/node_modules/@aws-sdk/middleware-logger/package.json +2 -2
- package/node_modules/@aws-sdk/middleware-recursion-detection/package.json +3 -3
- package/node_modules/@aws-sdk/middleware-retry/package.json +7 -7
- package/node_modules/@aws-sdk/middleware-sdk-sts/package.json +6 -6
- package/node_modules/@aws-sdk/middleware-serde/package.json +2 -2
- package/node_modules/@aws-sdk/middleware-signing/package.json +6 -6
- package/node_modules/@aws-sdk/middleware-stack/package.json +2 -2
- package/node_modules/@aws-sdk/middleware-user-agent/package.json +5 -5
- package/node_modules/@aws-sdk/node-config-provider/package.json +4 -4
- package/node_modules/@aws-sdk/node-http-handler/dist-cjs/node-http-handler.js +11 -6
- package/node_modules/@aws-sdk/node-http-handler/dist-cjs/node-http2-connection-manager.js +92 -0
- package/node_modules/@aws-sdk/node-http-handler/dist-cjs/node-http2-connection-pool.js +36 -0
- package/node_modules/@aws-sdk/node-http-handler/dist-cjs/node-http2-handler.js +14 -37
- package/node_modules/@aws-sdk/node-http-handler/dist-es/node-http-handler.js +8 -5
- package/node_modules/@aws-sdk/node-http-handler/dist-es/node-http2-connection-manager.js +86 -0
- package/node_modules/@aws-sdk/node-http-handler/dist-es/node-http2-connection-pool.js +32 -0
- package/node_modules/@aws-sdk/node-http-handler/dist-es/node-http2-handler.js +14 -37
- package/node_modules/@aws-sdk/node-http-handler/dist-types/node-http-handler.d.ts +16 -0
- package/node_modules/@aws-sdk/node-http-handler/dist-types/node-http2-connection-manager.d.ts +22 -0
- package/node_modules/@aws-sdk/node-http-handler/dist-types/node-http2-connection-pool.d.ts +13 -0
- package/node_modules/@aws-sdk/node-http-handler/dist-types/node-http2-handler.d.ts +9 -16
- package/node_modules/@aws-sdk/node-http-handler/dist-types/ts3.4/node-http-handler.d.ts +2 -0
- package/node_modules/@aws-sdk/node-http-handler/dist-types/ts3.4/node-http2-connection-manager.d.ts +24 -0
- package/node_modules/@aws-sdk/node-http-handler/dist-types/ts3.4/node-http2-connection-pool.d.ts +14 -0
- package/node_modules/@aws-sdk/node-http-handler/dist-types/ts3.4/node-http2-handler.d.ts +2 -3
- package/node_modules/@aws-sdk/node-http-handler/package.json +5 -5
- package/node_modules/@aws-sdk/property-provider/package.json +2 -2
- package/node_modules/@aws-sdk/protocol-http/package.json +2 -2
- package/node_modules/@aws-sdk/querystring-builder/package.json +2 -2
- package/node_modules/@aws-sdk/querystring-parser/package.json +2 -2
- package/node_modules/@aws-sdk/service-error-classification/package.json +2 -2
- package/node_modules/@aws-sdk/shared-ini-file-loader/package.json +2 -2
- package/node_modules/@aws-sdk/signature-v4/package.json +4 -4
- package/node_modules/@aws-sdk/smithy-client/package.json +3 -3
- package/node_modules/@aws-sdk/token-providers/package.json +5 -5
- package/node_modules/@aws-sdk/types/dist-cjs/connection/config.js +2 -0
- package/node_modules/@aws-sdk/types/dist-cjs/connection/manager.js +2 -0
- package/node_modules/@aws-sdk/types/dist-cjs/connection/pool.js +2 -0
- package/node_modules/@aws-sdk/types/dist-cjs/transfer.js +7 -0
- package/node_modules/@aws-sdk/types/dist-es/connection/config.js +1 -0
- package/node_modules/@aws-sdk/types/dist-es/connection/manager.js +1 -0
- package/node_modules/@aws-sdk/types/dist-es/connection/pool.js +1 -0
- package/node_modules/@aws-sdk/types/dist-es/transfer.js +6 -1
- package/node_modules/@aws-sdk/types/dist-types/connection/config.d.ts +7 -0
- package/node_modules/@aws-sdk/types/dist-types/connection/manager.d.ts +28 -0
- package/node_modules/@aws-sdk/types/dist-types/connection/pool.d.ts +24 -0
- package/node_modules/@aws-sdk/types/dist-types/http.d.ts +5 -0
- package/node_modules/@aws-sdk/types/dist-types/transfer.d.ts +9 -1
- package/node_modules/@aws-sdk/types/dist-types/ts3.4/connection/config.d.ts +3 -0
- package/node_modules/@aws-sdk/types/dist-types/ts3.4/connection/manager.d.ts +14 -0
- package/node_modules/@aws-sdk/types/dist-types/ts3.4/connection/pool.d.ts +9 -0
- package/node_modules/@aws-sdk/types/dist-types/ts3.4/http.d.ts +1 -0
- package/node_modules/@aws-sdk/types/dist-types/ts3.4/transfer.d.ts +9 -1
- package/node_modules/@aws-sdk/types/package.json +1 -1
- package/node_modules/@aws-sdk/url-parser/package.json +3 -3
- package/node_modules/@aws-sdk/util-defaults-mode-browser/package.json +4 -4
- package/node_modules/@aws-sdk/util-defaults-mode-node/package.json +7 -7
- package/node_modules/@aws-sdk/util-endpoints/package.json +2 -2
- package/node_modules/@aws-sdk/util-middleware/package.json +2 -2
- package/node_modules/@aws-sdk/util-retry/package.json +3 -3
- package/node_modules/@aws-sdk/util-user-agent-browser/package.json +3 -3
- package/node_modules/@aws-sdk/util-user-agent-node/package.json +4 -4
- package/node_modules/@aws-sdk/util-waiter/package.json +3 -3
- package/package.json +13 -13
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/node-config-provider",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.296.0",
|
|
4
4
|
"description": "Load config default values from ini config files and environmental variable",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"module": "./dist-es/index.js",
|
|
23
23
|
"types": "./dist-types/index.d.ts",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@aws-sdk/property-provider": "3.
|
|
26
|
-
"@aws-sdk/shared-ini-file-loader": "3.
|
|
27
|
-
"@aws-sdk/types": "3.
|
|
25
|
+
"@aws-sdk/property-provider": "3.296.0",
|
|
26
|
+
"@aws-sdk/shared-ini-file-loader": "3.296.0",
|
|
27
|
+
"@aws-sdk/types": "3.296.0",
|
|
28
28
|
"tslib": "^2.5.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NodeHttpHandler = void 0;
|
|
3
|
+
exports.NodeHttpHandler = exports.DEFAULT_REQUEST_TIMEOUT = void 0;
|
|
4
4
|
const protocol_http_1 = require("@aws-sdk/protocol-http");
|
|
5
5
|
const querystring_builder_1 = require("@aws-sdk/querystring-builder");
|
|
6
6
|
const http_1 = require("http");
|
|
7
7
|
const https_1 = require("https");
|
|
8
8
|
const constants_1 = require("./constants");
|
|
9
9
|
const get_transformed_headers_1 = require("./get-transformed-headers");
|
|
10
|
-
const set_connection_timeout_1 = require("./set-connection-timeout");
|
|
11
|
-
const set_socket_timeout_1 = require("./set-socket-timeout");
|
|
12
10
|
const write_request_body_1 = require("./write-request-body");
|
|
11
|
+
exports.DEFAULT_REQUEST_TIMEOUT = 0;
|
|
13
12
|
class NodeHttpHandler {
|
|
14
13
|
constructor(options) {
|
|
15
14
|
this.metadata = { handlerProtocol: "http/1.1" };
|
|
@@ -27,12 +26,14 @@ class NodeHttpHandler {
|
|
|
27
26
|
});
|
|
28
27
|
}
|
|
29
28
|
resolveDefaultConfig(options) {
|
|
30
|
-
|
|
29
|
+
var _a, _b;
|
|
30
|
+
const { requestTimeout, connectionTimeout, socketTimeout, httpAgent, httpsAgent } = options || {};
|
|
31
31
|
const keepAlive = true;
|
|
32
32
|
const maxSockets = 50;
|
|
33
33
|
return {
|
|
34
34
|
connectionTimeout,
|
|
35
35
|
socketTimeout,
|
|
36
|
+
requestTimeout: (_b = (_a = requestTimeout !== null && requestTimeout !== void 0 ? requestTimeout : connectionTimeout) !== null && _a !== void 0 ? _a : socketTimeout) !== null && _b !== void 0 ? _b : exports.DEFAULT_REQUEST_TIMEOUT,
|
|
36
37
|
httpAgent: httpAgent || new http_1.Agent({ keepAlive, maxSockets }),
|
|
37
38
|
httpsAgent: httpsAgent || new https_1.Agent({ keepAlive, maxSockets }),
|
|
38
39
|
};
|
|
@@ -47,6 +48,7 @@ class NodeHttpHandler {
|
|
|
47
48
|
this.config = await this.configProvider;
|
|
48
49
|
}
|
|
49
50
|
return new Promise((resolve, reject) => {
|
|
51
|
+
var _a, _b;
|
|
50
52
|
if (!this.config) {
|
|
51
53
|
throw new Error("Node HTTP request handler config is not resolved");
|
|
52
54
|
}
|
|
@@ -83,8 +85,11 @@ class NodeHttpHandler {
|
|
|
83
85
|
reject(err);
|
|
84
86
|
}
|
|
85
87
|
});
|
|
86
|
-
(
|
|
87
|
-
(
|
|
88
|
+
const timeout = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.requestTimeout) !== null && _b !== void 0 ? _b : exports.DEFAULT_REQUEST_TIMEOUT;
|
|
89
|
+
req.setTimeout(timeout, () => {
|
|
90
|
+
req.destroy();
|
|
91
|
+
reject(Object.assign(new Error(`Connection timed out after ${timeout} ms`), { name: "TimeoutError" }));
|
|
92
|
+
});
|
|
88
93
|
if (abortSignal) {
|
|
89
94
|
abortSignal.onabort = () => {
|
|
90
95
|
req.abort();
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NodeHttp2ConnectionManager = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const http2_1 = tslib_1.__importDefault(require("http2"));
|
|
6
|
+
const node_http2_connection_pool_1 = require("./node-http2-connection-pool");
|
|
7
|
+
class NodeHttp2ConnectionManager {
|
|
8
|
+
constructor(config) {
|
|
9
|
+
this.sessionCache = new Map();
|
|
10
|
+
this.config = config;
|
|
11
|
+
if (this.config.maxConcurrency && this.config.maxConcurrency <= 0) {
|
|
12
|
+
throw new RangeError("maxConcurrency must be greater than zero.");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
lease(requestContext, connectionConfiguration) {
|
|
16
|
+
const url = this.getUrlString(requestContext);
|
|
17
|
+
const existingPool = this.sessionCache.get(url);
|
|
18
|
+
if (existingPool) {
|
|
19
|
+
const existingSession = existingPool.poll();
|
|
20
|
+
if (existingSession && !this.config.disableConcurrency) {
|
|
21
|
+
return existingSession;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const session = http2_1.default.connect(url);
|
|
25
|
+
if (this.config.maxConcurrency) {
|
|
26
|
+
session.settings({ maxConcurrentStreams: this.config.maxConcurrency }, (err) => {
|
|
27
|
+
if (err) {
|
|
28
|
+
throw new Error("Fail to set maxConcurrentStreams to " +
|
|
29
|
+
this.config.maxConcurrency +
|
|
30
|
+
"when creating new session for " +
|
|
31
|
+
requestContext.destination.toString());
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
session.unref();
|
|
36
|
+
const destroySessionCb = () => {
|
|
37
|
+
session.destroy();
|
|
38
|
+
this.deleteSession(url, session);
|
|
39
|
+
};
|
|
40
|
+
session.on("goaway", destroySessionCb);
|
|
41
|
+
session.on("error", destroySessionCb);
|
|
42
|
+
session.on("frameError", destroySessionCb);
|
|
43
|
+
session.on("close", () => this.deleteSession(url, session));
|
|
44
|
+
if (connectionConfiguration.requestTimeout) {
|
|
45
|
+
session.setTimeout(connectionConfiguration.requestTimeout, destroySessionCb);
|
|
46
|
+
}
|
|
47
|
+
const connectionPool = this.sessionCache.get(url) || new node_http2_connection_pool_1.NodeHttp2ConnectionPool();
|
|
48
|
+
connectionPool.offerLast(session);
|
|
49
|
+
this.sessionCache.set(url, connectionPool);
|
|
50
|
+
return session;
|
|
51
|
+
}
|
|
52
|
+
deleteSession(authority, session) {
|
|
53
|
+
const existingConnectionPool = this.sessionCache.get(authority);
|
|
54
|
+
if (!existingConnectionPool) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (!existingConnectionPool.contains(session)) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
existingConnectionPool.remove(session);
|
|
61
|
+
this.sessionCache.set(authority, existingConnectionPool);
|
|
62
|
+
}
|
|
63
|
+
release(requestContext, session) {
|
|
64
|
+
var _a;
|
|
65
|
+
const cacheKey = this.getUrlString(requestContext);
|
|
66
|
+
(_a = this.sessionCache.get(cacheKey)) === null || _a === void 0 ? void 0 : _a.offerLast(session);
|
|
67
|
+
}
|
|
68
|
+
destroy() {
|
|
69
|
+
for (const [key, connectionPool] of this.sessionCache) {
|
|
70
|
+
for (const session of connectionPool) {
|
|
71
|
+
if (!session.destroyed) {
|
|
72
|
+
session.destroy();
|
|
73
|
+
}
|
|
74
|
+
connectionPool.remove(session);
|
|
75
|
+
}
|
|
76
|
+
this.sessionCache.delete(key);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
setMaxConcurrentStreams(maxConcurrentStreams) {
|
|
80
|
+
if (this.config.maxConcurrency && this.config.maxConcurrency <= 0) {
|
|
81
|
+
throw new RangeError("maxConcurrentStreams must be greater than zero.");
|
|
82
|
+
}
|
|
83
|
+
this.config.maxConcurrency = maxConcurrentStreams;
|
|
84
|
+
}
|
|
85
|
+
setDisableConcurrentStreams(disableConcurrentStreams) {
|
|
86
|
+
this.config.disableConcurrency = disableConcurrentStreams;
|
|
87
|
+
}
|
|
88
|
+
getUrlString(request) {
|
|
89
|
+
return request.destination.toString();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.NodeHttp2ConnectionManager = NodeHttp2ConnectionManager;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NodeHttp2ConnectionPool = void 0;
|
|
4
|
+
class NodeHttp2ConnectionPool {
|
|
5
|
+
constructor(sessions) {
|
|
6
|
+
this.sessions = [];
|
|
7
|
+
this.sessions = sessions !== null && sessions !== void 0 ? sessions : [];
|
|
8
|
+
}
|
|
9
|
+
poll() {
|
|
10
|
+
if (this.sessions.length > 0) {
|
|
11
|
+
return this.sessions.shift();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
offerLast(session) {
|
|
15
|
+
this.sessions.push(session);
|
|
16
|
+
}
|
|
17
|
+
contains(session) {
|
|
18
|
+
return this.sessions.includes(session);
|
|
19
|
+
}
|
|
20
|
+
remove(session) {
|
|
21
|
+
this.sessions = this.sessions.filter((s) => s !== session);
|
|
22
|
+
}
|
|
23
|
+
[Symbol.iterator]() {
|
|
24
|
+
return this.sessions[Symbol.iterator]();
|
|
25
|
+
}
|
|
26
|
+
destroy(connection) {
|
|
27
|
+
for (const session of this.sessions) {
|
|
28
|
+
if (session === connection) {
|
|
29
|
+
if (!session.destroyed) {
|
|
30
|
+
session.destroy();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.NodeHttp2ConnectionPool = NodeHttp2ConnectionPool;
|
|
@@ -5,10 +5,12 @@ const protocol_http_1 = require("@aws-sdk/protocol-http");
|
|
|
5
5
|
const querystring_builder_1 = require("@aws-sdk/querystring-builder");
|
|
6
6
|
const http2_1 = require("http2");
|
|
7
7
|
const get_transformed_headers_1 = require("./get-transformed-headers");
|
|
8
|
+
const node_http2_connection_manager_1 = require("./node-http2-connection-manager");
|
|
8
9
|
const write_request_body_1 = require("./write-request-body");
|
|
9
10
|
class NodeHttp2Handler {
|
|
10
11
|
constructor(options) {
|
|
11
12
|
this.metadata = { handlerProtocol: "h2" };
|
|
13
|
+
this.connectionManager = new node_http2_connection_manager_1.NodeHttp2ConnectionManager({});
|
|
12
14
|
this.configProvider = new Promise((resolve, reject) => {
|
|
13
15
|
if (typeof options === "function") {
|
|
14
16
|
options()
|
|
@@ -21,20 +23,21 @@ class NodeHttp2Handler {
|
|
|
21
23
|
resolve(options || {});
|
|
22
24
|
}
|
|
23
25
|
});
|
|
24
|
-
this.sessionCache = new Map();
|
|
25
26
|
}
|
|
26
27
|
destroy() {
|
|
27
|
-
|
|
28
|
-
sessions.forEach((session) => this.destroySession(session));
|
|
29
|
-
}
|
|
30
|
-
this.sessionCache.clear();
|
|
28
|
+
this.connectionManager.destroy();
|
|
31
29
|
}
|
|
32
30
|
async handle(request, { abortSignal } = {}) {
|
|
33
31
|
if (!this.config) {
|
|
34
32
|
this.config = await this.configProvider;
|
|
33
|
+
this.connectionManager.setDisableConcurrentStreams(this.config.disableConcurrentStreams || false);
|
|
34
|
+
if (this.config.maxConcurrentStreams) {
|
|
35
|
+
this.connectionManager.setMaxConcurrentStreams(this.config.maxConcurrentStreams);
|
|
36
|
+
}
|
|
35
37
|
}
|
|
36
38
|
const { requestTimeout, disableConcurrentStreams } = this.config;
|
|
37
39
|
return new Promise((resolve, rejectOriginal) => {
|
|
40
|
+
var _a;
|
|
38
41
|
let fulfilled = false;
|
|
39
42
|
if (abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.aborted) {
|
|
40
43
|
fulfilled = true;
|
|
@@ -45,7 +48,11 @@ class NodeHttp2Handler {
|
|
|
45
48
|
}
|
|
46
49
|
const { hostname, method, port, protocol, path, query } = request;
|
|
47
50
|
const authority = `${protocol}//${hostname}${port ? `:${port}` : ""}`;
|
|
48
|
-
const
|
|
51
|
+
const requestContext = { destination: new URL(authority) };
|
|
52
|
+
const session = this.connectionManager.lease(requestContext, {
|
|
53
|
+
requestTimeout: (_a = this.config) === null || _a === void 0 ? void 0 : _a.sessionTimeout,
|
|
54
|
+
disableConcurrentStreams: disableConcurrentStreams || false,
|
|
55
|
+
});
|
|
49
56
|
const reject = (err) => {
|
|
50
57
|
if (disableConcurrentStreams) {
|
|
51
58
|
this.destroySession(session);
|
|
@@ -70,7 +77,7 @@ class NodeHttp2Handler {
|
|
|
70
77
|
resolve({ response: httpResponse });
|
|
71
78
|
if (disableConcurrentStreams) {
|
|
72
79
|
session.close();
|
|
73
|
-
this.
|
|
80
|
+
this.connectionManager.deleteSession(authority, session);
|
|
74
81
|
}
|
|
75
82
|
});
|
|
76
83
|
if (requestTimeout) {
|
|
@@ -108,40 +115,10 @@ class NodeHttp2Handler {
|
|
|
108
115
|
(0, write_request_body_1.writeRequestBody)(req, request);
|
|
109
116
|
});
|
|
110
117
|
}
|
|
111
|
-
getSession(authority, disableConcurrentStreams) {
|
|
112
|
-
var _a;
|
|
113
|
-
const sessionCache = this.sessionCache;
|
|
114
|
-
const existingSessions = sessionCache.get(authority) || [];
|
|
115
|
-
if (existingSessions.length > 0 && !disableConcurrentStreams)
|
|
116
|
-
return existingSessions[0];
|
|
117
|
-
const newSession = (0, http2_1.connect)(authority);
|
|
118
|
-
newSession.unref();
|
|
119
|
-
const destroySessionCb = () => {
|
|
120
|
-
this.destroySession(newSession);
|
|
121
|
-
this.deleteSessionFromCache(authority, newSession);
|
|
122
|
-
};
|
|
123
|
-
newSession.on("goaway", destroySessionCb);
|
|
124
|
-
newSession.on("error", destroySessionCb);
|
|
125
|
-
newSession.on("frameError", destroySessionCb);
|
|
126
|
-
newSession.on("close", () => this.deleteSessionFromCache(authority, newSession));
|
|
127
|
-
if ((_a = this.config) === null || _a === void 0 ? void 0 : _a.sessionTimeout) {
|
|
128
|
-
newSession.setTimeout(this.config.sessionTimeout, destroySessionCb);
|
|
129
|
-
}
|
|
130
|
-
existingSessions.push(newSession);
|
|
131
|
-
sessionCache.set(authority, existingSessions);
|
|
132
|
-
return newSession;
|
|
133
|
-
}
|
|
134
118
|
destroySession(session) {
|
|
135
119
|
if (!session.destroyed) {
|
|
136
120
|
session.destroy();
|
|
137
121
|
}
|
|
138
122
|
}
|
|
139
|
-
deleteSessionFromCache(authority, session) {
|
|
140
|
-
const existingSessions = this.sessionCache.get(authority) || [];
|
|
141
|
-
if (!existingSessions.includes(session)) {
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
this.sessionCache.set(authority, existingSessions.filter((s) => s !== session));
|
|
145
|
-
}
|
|
146
123
|
}
|
|
147
124
|
exports.NodeHttp2Handler = NodeHttp2Handler;
|
|
@@ -4,9 +4,8 @@ import { Agent as hAgent, request as hRequest } from "http";
|
|
|
4
4
|
import { Agent as hsAgent, request as hsRequest } from "https";
|
|
5
5
|
import { NODEJS_TIMEOUT_ERROR_CODES } from "./constants";
|
|
6
6
|
import { getTransformedHeaders } from "./get-transformed-headers";
|
|
7
|
-
import { setConnectionTimeout } from "./set-connection-timeout";
|
|
8
|
-
import { setSocketTimeout } from "./set-socket-timeout";
|
|
9
7
|
import { writeRequestBody } from "./write-request-body";
|
|
8
|
+
export const DEFAULT_REQUEST_TIMEOUT = 0;
|
|
10
9
|
export class NodeHttpHandler {
|
|
11
10
|
constructor(options) {
|
|
12
11
|
this.metadata = { handlerProtocol: "http/1.1" };
|
|
@@ -24,12 +23,13 @@ export class NodeHttpHandler {
|
|
|
24
23
|
});
|
|
25
24
|
}
|
|
26
25
|
resolveDefaultConfig(options) {
|
|
27
|
-
const { connectionTimeout, socketTimeout, httpAgent, httpsAgent } = options || {};
|
|
26
|
+
const { requestTimeout, connectionTimeout, socketTimeout, httpAgent, httpsAgent } = options || {};
|
|
28
27
|
const keepAlive = true;
|
|
29
28
|
const maxSockets = 50;
|
|
30
29
|
return {
|
|
31
30
|
connectionTimeout,
|
|
32
31
|
socketTimeout,
|
|
32
|
+
requestTimeout: requestTimeout ?? connectionTimeout ?? socketTimeout ?? DEFAULT_REQUEST_TIMEOUT,
|
|
33
33
|
httpAgent: httpAgent || new hAgent({ keepAlive, maxSockets }),
|
|
34
34
|
httpsAgent: httpsAgent || new hsAgent({ keepAlive, maxSockets }),
|
|
35
35
|
};
|
|
@@ -79,8 +79,11 @@ export class NodeHttpHandler {
|
|
|
79
79
|
reject(err);
|
|
80
80
|
}
|
|
81
81
|
});
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
const timeout = this.config?.requestTimeout ?? DEFAULT_REQUEST_TIMEOUT;
|
|
83
|
+
req.setTimeout(timeout, () => {
|
|
84
|
+
req.destroy();
|
|
85
|
+
reject(Object.assign(new Error(`Connection timed out after ${timeout} ms`), { name: "TimeoutError" }));
|
|
86
|
+
});
|
|
84
87
|
if (abortSignal) {
|
|
85
88
|
abortSignal.onabort = () => {
|
|
86
89
|
req.abort();
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import http2 from "http2";
|
|
2
|
+
import { NodeHttp2ConnectionPool } from "./node-http2-connection-pool";
|
|
3
|
+
export class NodeHttp2ConnectionManager {
|
|
4
|
+
constructor(config) {
|
|
5
|
+
this.sessionCache = new Map();
|
|
6
|
+
this.config = config;
|
|
7
|
+
if (this.config.maxConcurrency && this.config.maxConcurrency <= 0) {
|
|
8
|
+
throw new RangeError("maxConcurrency must be greater than zero.");
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
lease(requestContext, connectionConfiguration) {
|
|
12
|
+
const url = this.getUrlString(requestContext);
|
|
13
|
+
const existingPool = this.sessionCache.get(url);
|
|
14
|
+
if (existingPool) {
|
|
15
|
+
const existingSession = existingPool.poll();
|
|
16
|
+
if (existingSession && !this.config.disableConcurrency) {
|
|
17
|
+
return existingSession;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const session = http2.connect(url);
|
|
21
|
+
if (this.config.maxConcurrency) {
|
|
22
|
+
session.settings({ maxConcurrentStreams: this.config.maxConcurrency }, (err) => {
|
|
23
|
+
if (err) {
|
|
24
|
+
throw new Error("Fail to set maxConcurrentStreams to " +
|
|
25
|
+
this.config.maxConcurrency +
|
|
26
|
+
"when creating new session for " +
|
|
27
|
+
requestContext.destination.toString());
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
session.unref();
|
|
32
|
+
const destroySessionCb = () => {
|
|
33
|
+
session.destroy();
|
|
34
|
+
this.deleteSession(url, session);
|
|
35
|
+
};
|
|
36
|
+
session.on("goaway", destroySessionCb);
|
|
37
|
+
session.on("error", destroySessionCb);
|
|
38
|
+
session.on("frameError", destroySessionCb);
|
|
39
|
+
session.on("close", () => this.deleteSession(url, session));
|
|
40
|
+
if (connectionConfiguration.requestTimeout) {
|
|
41
|
+
session.setTimeout(connectionConfiguration.requestTimeout, destroySessionCb);
|
|
42
|
+
}
|
|
43
|
+
const connectionPool = this.sessionCache.get(url) || new NodeHttp2ConnectionPool();
|
|
44
|
+
connectionPool.offerLast(session);
|
|
45
|
+
this.sessionCache.set(url, connectionPool);
|
|
46
|
+
return session;
|
|
47
|
+
}
|
|
48
|
+
deleteSession(authority, session) {
|
|
49
|
+
const existingConnectionPool = this.sessionCache.get(authority);
|
|
50
|
+
if (!existingConnectionPool) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (!existingConnectionPool.contains(session)) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
existingConnectionPool.remove(session);
|
|
57
|
+
this.sessionCache.set(authority, existingConnectionPool);
|
|
58
|
+
}
|
|
59
|
+
release(requestContext, session) {
|
|
60
|
+
const cacheKey = this.getUrlString(requestContext);
|
|
61
|
+
this.sessionCache.get(cacheKey)?.offerLast(session);
|
|
62
|
+
}
|
|
63
|
+
destroy() {
|
|
64
|
+
for (const [key, connectionPool] of this.sessionCache) {
|
|
65
|
+
for (const session of connectionPool) {
|
|
66
|
+
if (!session.destroyed) {
|
|
67
|
+
session.destroy();
|
|
68
|
+
}
|
|
69
|
+
connectionPool.remove(session);
|
|
70
|
+
}
|
|
71
|
+
this.sessionCache.delete(key);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
setMaxConcurrentStreams(maxConcurrentStreams) {
|
|
75
|
+
if (this.config.maxConcurrency && this.config.maxConcurrency <= 0) {
|
|
76
|
+
throw new RangeError("maxConcurrentStreams must be greater than zero.");
|
|
77
|
+
}
|
|
78
|
+
this.config.maxConcurrency = maxConcurrentStreams;
|
|
79
|
+
}
|
|
80
|
+
setDisableConcurrentStreams(disableConcurrentStreams) {
|
|
81
|
+
this.config.disableConcurrency = disableConcurrentStreams;
|
|
82
|
+
}
|
|
83
|
+
getUrlString(request) {
|
|
84
|
+
return request.destination.toString();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export class NodeHttp2ConnectionPool {
|
|
2
|
+
constructor(sessions) {
|
|
3
|
+
this.sessions = [];
|
|
4
|
+
this.sessions = sessions ?? [];
|
|
5
|
+
}
|
|
6
|
+
poll() {
|
|
7
|
+
if (this.sessions.length > 0) {
|
|
8
|
+
return this.sessions.shift();
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
offerLast(session) {
|
|
12
|
+
this.sessions.push(session);
|
|
13
|
+
}
|
|
14
|
+
contains(session) {
|
|
15
|
+
return this.sessions.includes(session);
|
|
16
|
+
}
|
|
17
|
+
remove(session) {
|
|
18
|
+
this.sessions = this.sessions.filter((s) => s !== session);
|
|
19
|
+
}
|
|
20
|
+
[Symbol.iterator]() {
|
|
21
|
+
return this.sessions[Symbol.iterator]();
|
|
22
|
+
}
|
|
23
|
+
destroy(connection) {
|
|
24
|
+
for (const session of this.sessions) {
|
|
25
|
+
if (session === connection) {
|
|
26
|
+
if (!session.destroyed) {
|
|
27
|
+
session.destroy();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { HttpResponse } from "@aws-sdk/protocol-http";
|
|
2
2
|
import { buildQueryString } from "@aws-sdk/querystring-builder";
|
|
3
|
-
import {
|
|
3
|
+
import { constants } from "http2";
|
|
4
4
|
import { getTransformedHeaders } from "./get-transformed-headers";
|
|
5
|
+
import { NodeHttp2ConnectionManager } from "./node-http2-connection-manager";
|
|
5
6
|
import { writeRequestBody } from "./write-request-body";
|
|
6
7
|
export class NodeHttp2Handler {
|
|
7
8
|
constructor(options) {
|
|
8
9
|
this.metadata = { handlerProtocol: "h2" };
|
|
10
|
+
this.connectionManager = new NodeHttp2ConnectionManager({});
|
|
9
11
|
this.configProvider = new Promise((resolve, reject) => {
|
|
10
12
|
if (typeof options === "function") {
|
|
11
13
|
options()
|
|
@@ -18,17 +20,17 @@ export class NodeHttp2Handler {
|
|
|
18
20
|
resolve(options || {});
|
|
19
21
|
}
|
|
20
22
|
});
|
|
21
|
-
this.sessionCache = new Map();
|
|
22
23
|
}
|
|
23
24
|
destroy() {
|
|
24
|
-
|
|
25
|
-
sessions.forEach((session) => this.destroySession(session));
|
|
26
|
-
}
|
|
27
|
-
this.sessionCache.clear();
|
|
25
|
+
this.connectionManager.destroy();
|
|
28
26
|
}
|
|
29
27
|
async handle(request, { abortSignal } = {}) {
|
|
30
28
|
if (!this.config) {
|
|
31
29
|
this.config = await this.configProvider;
|
|
30
|
+
this.connectionManager.setDisableConcurrentStreams(this.config.disableConcurrentStreams || false);
|
|
31
|
+
if (this.config.maxConcurrentStreams) {
|
|
32
|
+
this.connectionManager.setMaxConcurrentStreams(this.config.maxConcurrentStreams);
|
|
33
|
+
}
|
|
32
34
|
}
|
|
33
35
|
const { requestTimeout, disableConcurrentStreams } = this.config;
|
|
34
36
|
return new Promise((resolve, rejectOriginal) => {
|
|
@@ -42,7 +44,11 @@ export class NodeHttp2Handler {
|
|
|
42
44
|
}
|
|
43
45
|
const { hostname, method, port, protocol, path, query } = request;
|
|
44
46
|
const authority = `${protocol}//${hostname}${port ? `:${port}` : ""}`;
|
|
45
|
-
const
|
|
47
|
+
const requestContext = { destination: new URL(authority) };
|
|
48
|
+
const session = this.connectionManager.lease(requestContext, {
|
|
49
|
+
requestTimeout: this.config?.sessionTimeout,
|
|
50
|
+
disableConcurrentStreams: disableConcurrentStreams || false,
|
|
51
|
+
});
|
|
46
52
|
const reject = (err) => {
|
|
47
53
|
if (disableConcurrentStreams) {
|
|
48
54
|
this.destroySession(session);
|
|
@@ -67,7 +73,7 @@ export class NodeHttp2Handler {
|
|
|
67
73
|
resolve({ response: httpResponse });
|
|
68
74
|
if (disableConcurrentStreams) {
|
|
69
75
|
session.close();
|
|
70
|
-
this.
|
|
76
|
+
this.connectionManager.deleteSession(authority, session);
|
|
71
77
|
}
|
|
72
78
|
});
|
|
73
79
|
if (requestTimeout) {
|
|
@@ -105,38 +111,9 @@ export class NodeHttp2Handler {
|
|
|
105
111
|
writeRequestBody(req, request);
|
|
106
112
|
});
|
|
107
113
|
}
|
|
108
|
-
getSession(authority, disableConcurrentStreams) {
|
|
109
|
-
const sessionCache = this.sessionCache;
|
|
110
|
-
const existingSessions = sessionCache.get(authority) || [];
|
|
111
|
-
if (existingSessions.length > 0 && !disableConcurrentStreams)
|
|
112
|
-
return existingSessions[0];
|
|
113
|
-
const newSession = connect(authority);
|
|
114
|
-
newSession.unref();
|
|
115
|
-
const destroySessionCb = () => {
|
|
116
|
-
this.destroySession(newSession);
|
|
117
|
-
this.deleteSessionFromCache(authority, newSession);
|
|
118
|
-
};
|
|
119
|
-
newSession.on("goaway", destroySessionCb);
|
|
120
|
-
newSession.on("error", destroySessionCb);
|
|
121
|
-
newSession.on("frameError", destroySessionCb);
|
|
122
|
-
newSession.on("close", () => this.deleteSessionFromCache(authority, newSession));
|
|
123
|
-
if (this.config?.sessionTimeout) {
|
|
124
|
-
newSession.setTimeout(this.config.sessionTimeout, destroySessionCb);
|
|
125
|
-
}
|
|
126
|
-
existingSessions.push(newSession);
|
|
127
|
-
sessionCache.set(authority, existingSessions);
|
|
128
|
-
return newSession;
|
|
129
|
-
}
|
|
130
114
|
destroySession(session) {
|
|
131
115
|
if (!session.destroyed) {
|
|
132
116
|
session.destroy();
|
|
133
117
|
}
|
|
134
118
|
}
|
|
135
|
-
deleteSessionFromCache(authority, session) {
|
|
136
|
-
const existingSessions = this.sessionCache.get(authority) || [];
|
|
137
|
-
if (!existingSessions.includes(session)) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
this.sessionCache.set(authority, existingSessions.filter((s) => s !== session));
|
|
141
|
-
}
|
|
142
119
|
}
|
|
@@ -9,11 +9,26 @@ import { Agent as hsAgent } from "https";
|
|
|
9
9
|
*/
|
|
10
10
|
export interface NodeHttpHandlerOptions {
|
|
11
11
|
/**
|
|
12
|
+
* @deprecated Use {@link requestTimeout}
|
|
13
|
+
*
|
|
14
|
+
* Note:{@link NodeHttpHandler} will resolve request timeout via nullish coalescing the following fields:
|
|
15
|
+
* {@link requestTimeout} ?? {@link connectionTimeout} ?? {@link socketTimeout} ?? {@link DEFAULT_REQUEST_TIMEOUT}
|
|
16
|
+
*
|
|
12
17
|
* The maximum time in milliseconds that the connection phase of a request
|
|
13
18
|
* may take before the connection attempt is abandoned.
|
|
14
19
|
*/
|
|
15
20
|
connectionTimeout?: number;
|
|
16
21
|
/**
|
|
22
|
+
* The maximum time in milliseconds that the connection phase of a request
|
|
23
|
+
* may take before the connection attempt is abandoned.
|
|
24
|
+
*/
|
|
25
|
+
requestTimeout?: number;
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated Use {@link requestTimeout}
|
|
28
|
+
*
|
|
29
|
+
* Note:{@link NodeHttpHandler} will resolve request timeout via nullish coalescing the following fields:
|
|
30
|
+
* {@link requestTimeout} ?? {@link connectionTimeout} ?? {@link socketTimeout} ?? {@link DEFAULT_REQUEST_TIMEOUT}
|
|
31
|
+
*
|
|
17
32
|
* The maximum time in milliseconds that a socket may remain idle before it
|
|
18
33
|
* is closed.
|
|
19
34
|
*/
|
|
@@ -21,6 +36,7 @@ export interface NodeHttpHandlerOptions {
|
|
|
21
36
|
httpAgent?: hAgent;
|
|
22
37
|
httpsAgent?: hsAgent;
|
|
23
38
|
}
|
|
39
|
+
export declare const DEFAULT_REQUEST_TIMEOUT = 0;
|
|
24
40
|
export declare class NodeHttpHandler implements HttpHandler {
|
|
25
41
|
private config?;
|
|
26
42
|
private readonly configProvider;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { RequestContext } from "@aws-sdk/types";
|
|
3
|
+
import { ConnectConfiguration } from "@aws-sdk/types/src/connection/config";
|
|
4
|
+
import { ConnectionManager, ConnectionManagerConfiguration } from "@aws-sdk/types/src/connection/manager";
|
|
5
|
+
import { ClientHttp2Session } from "http2";
|
|
6
|
+
export declare class NodeHttp2ConnectionManager implements ConnectionManager<ClientHttp2Session> {
|
|
7
|
+
constructor(config: ConnectionManagerConfiguration);
|
|
8
|
+
private config;
|
|
9
|
+
private readonly sessionCache;
|
|
10
|
+
lease(requestContext: RequestContext, connectionConfiguration: ConnectConfiguration): ClientHttp2Session;
|
|
11
|
+
/**
|
|
12
|
+
* Delete a session from the connection pool.
|
|
13
|
+
* @param authority The authority of the session to delete.
|
|
14
|
+
* @param session The session to delete.
|
|
15
|
+
*/
|
|
16
|
+
deleteSession(authority: string, session: ClientHttp2Session): void;
|
|
17
|
+
release(requestContext: RequestContext, session: ClientHttp2Session): void;
|
|
18
|
+
destroy(): void;
|
|
19
|
+
setMaxConcurrentStreams(maxConcurrentStreams: number): void;
|
|
20
|
+
setDisableConcurrentStreams(disableConcurrentStreams: boolean): void;
|
|
21
|
+
private getUrlString;
|
|
22
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ConnectionPool } from "@aws-sdk/types/src/connection/pool";
|
|
3
|
+
import { ClientHttp2Session } from "http2";
|
|
4
|
+
export declare class NodeHttp2ConnectionPool implements ConnectionPool<ClientHttp2Session> {
|
|
5
|
+
private sessions;
|
|
6
|
+
constructor(sessions?: ClientHttp2Session[]);
|
|
7
|
+
poll(): ClientHttp2Session | void;
|
|
8
|
+
offerLast(session: ClientHttp2Session): void;
|
|
9
|
+
contains(session: ClientHttp2Session): boolean;
|
|
10
|
+
remove(session: ClientHttp2Session): void;
|
|
11
|
+
[Symbol.iterator](): IterableIterator<ClientHttp2Session>;
|
|
12
|
+
destroy(connection: ClientHttp2Session): void;
|
|
13
|
+
}
|