agent-relay 4.0.32 → 4.0.34
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/bin/agent-relay-broker-darwin-arm64 +0 -0
- package/bin/agent-relay-broker-darwin-x64 +0 -0
- package/bin/agent-relay-broker-linux-arm64 +0 -0
- package/bin/agent-relay-broker-linux-x64 +0 -0
- package/dist/index.cjs +1 -3
- package/dist/src/cli/commands/on/start.d.ts.map +1 -1
- package/dist/src/cli/commands/on/start.js +149 -111
- package/dist/src/cli/commands/on/start.js.map +1 -1
- package/dist/src/cli/commands/setup.js +2 -2
- package/dist/src/cli/commands/setup.js.map +1 -1
- package/node_modules/@agent-relay/cloud/package.json +2 -2
- package/node_modules/@agent-relay/config/package.json +1 -1
- package/node_modules/@agent-relay/hooks/package.json +4 -4
- package/node_modules/@agent-relay/sdk/dist/workflows/runner.d.ts.map +1 -1
- package/node_modules/@agent-relay/sdk/dist/workflows/runner.js +7 -5
- package/node_modules/@agent-relay/sdk/dist/workflows/runner.js.map +1 -1
- package/node_modules/@agent-relay/sdk/package.json +2 -2
- package/node_modules/@agent-relay/telemetry/dist/config.d.ts +1 -1
- package/node_modules/@agent-relay/telemetry/dist/config.d.ts.map +1 -1
- package/node_modules/@agent-relay/telemetry/dist/config.js +6 -3
- package/node_modules/@agent-relay/telemetry/dist/config.js.map +1 -1
- package/node_modules/@agent-relay/telemetry/package.json +1 -1
- package/node_modules/@agent-relay/trajectory/package.json +2 -2
- package/node_modules/@agent-relay/user-directory/package.json +2 -2
- package/node_modules/@agent-relay/utils/package.json +2 -2
- package/node_modules/@aws-sdk/core/dist-cjs/index.js +18 -10
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/protocols/index.js +18 -10
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/JsonShapeDeserializer.js +6 -4
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/JsonShapeSerializer.js +6 -3
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/experimental/SinglePassJsonShapeSerializer.js +2 -1
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/query/QueryShapeSerializer.js +2 -1
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/xml/XmlShapeSerializer.js +4 -2
- package/node_modules/@aws-sdk/core/package.json +1 -1
- package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-http/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +9 -9
- package/node_modules/@aws-sdk/credential-provider-login/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
- package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
- package/node_modules/@aws-sdk/middleware-flexible-checksums/package.json +2 -2
- package/node_modules/@aws-sdk/middleware-sdk-s3/package.json +2 -2
- package/node_modules/@aws-sdk/middleware-user-agent/package.json +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/endpoint/bdd.js +100 -0
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/endpoint/endpointResolver.js +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/endpoint/bdd.js +90 -0
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/endpoint/endpointResolver.js +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/endpoint/bdd.js +80 -0
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/endpoint/endpointResolver.js +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/endpoint/bdd.js +80 -0
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/endpoint/endpointResolver.js +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/STSClient.js +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/auth/httpAuthSchemeProvider.js +87 -5
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/endpoint/bdd.js +150 -0
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/endpoint/endpointResolver.js +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/runtimeConfig.js +6 -0
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/runtimeConfig.shared.js +7 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/cognito-identity/endpoint/bdd.js +97 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/cognito-identity/endpoint/endpointResolver.js +3 -3
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/signin/endpoint/bdd.js +87 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/signin/endpoint/endpointResolver.js +3 -3
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso/endpoint/bdd.js +77 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso/endpoint/endpointResolver.js +3 -3
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso-oidc/endpoint/bdd.js +77 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso-oidc/endpoint/endpointResolver.js +3 -3
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/STSClient.js +1 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/auth/httpAuthSchemeProvider.js +88 -4
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/endpoint/bdd.js +147 -0
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/endpoint/endpointResolver.js +3 -3
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/runtimeConfig.js +7 -1
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/runtimeConfig.shared.js +8 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/endpoint/bdd.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/endpoint/bdd.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/endpoint/bdd.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/endpoint/bdd.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/auth/httpAuthSchemeProvider.d.ts +15 -7
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/endpoint/bdd.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/runtimeConfig.browser.d.ts +3 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/runtimeConfig.d.ts +10 -4
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/runtimeConfig.native.d.ts +3 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/runtimeConfig.shared.d.ts +3 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/endpoint/bdd.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/endpoint/bdd.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/endpoint/bdd.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/endpoint/bdd.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/auth/httpAuthSchemeProvider.d.ts +20 -9
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/endpoint/bdd.d.ts +2 -0
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/runtimeConfig.browser.d.ts +11 -5
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/runtimeConfig.d.ts +35 -16
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/runtimeConfig.native.d.ts +11 -5
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/runtimeConfig.shared.d.ts +8 -1
- package/node_modules/@aws-sdk/nested-clients/package.json +5 -4
- package/node_modules/@aws-sdk/signature-v4-multi-region/package.json +2 -2
- package/node_modules/@aws-sdk/token-providers/package.json +3 -3
- package/node_modules/@aws-sdk/util-user-agent-node/package.json +2 -2
- package/node_modules/@relayfile/local-mount/README.md +215 -0
- package/node_modules/@relayfile/local-mount/dist/auto-sync.d.ts +31 -0
- package/node_modules/@relayfile/local-mount/dist/auto-sync.js +466 -0
- package/node_modules/@relayfile/local-mount/dist/dotfiles.d.ts +18 -0
- package/node_modules/@relayfile/local-mount/dist/dotfiles.js +43 -0
- package/node_modules/@relayfile/local-mount/dist/index.d.ts +4 -0
- package/node_modules/@relayfile/local-mount/dist/index.js +3 -0
- package/node_modules/@relayfile/local-mount/dist/launch.d.ts +50 -0
- package/node_modules/@relayfile/local-mount/dist/launch.js +129 -0
- package/node_modules/@relayfile/local-mount/dist/symlink-mount.d.ts +23 -0
- package/{dist/src/cli/commands/on → node_modules/@relayfile/local-mount/dist}/symlink-mount.js +88 -20
- package/node_modules/@relayfile/local-mount/node_modules/chokidar/LICENSE +21 -0
- package/node_modules/@relayfile/local-mount/node_modules/chokidar/README.md +305 -0
- package/node_modules/@relayfile/local-mount/node_modules/chokidar/esm/handler.d.ts +90 -0
- package/node_modules/@relayfile/local-mount/node_modules/chokidar/esm/handler.js +629 -0
- package/node_modules/@relayfile/local-mount/node_modules/chokidar/esm/index.d.ts +215 -0
- package/node_modules/@relayfile/local-mount/node_modules/chokidar/esm/index.js +798 -0
- package/node_modules/@relayfile/local-mount/node_modules/chokidar/esm/package.json +1 -0
- package/node_modules/@relayfile/local-mount/node_modules/chokidar/handler.d.ts +90 -0
- package/node_modules/@relayfile/local-mount/node_modules/chokidar/handler.js +635 -0
- package/node_modules/@relayfile/local-mount/node_modules/chokidar/index.d.ts +215 -0
- package/node_modules/@relayfile/local-mount/node_modules/chokidar/index.js +804 -0
- package/node_modules/@relayfile/local-mount/node_modules/chokidar/package.json +69 -0
- package/node_modules/@relayfile/local-mount/node_modules/readdirp/LICENSE +21 -0
- package/node_modules/@relayfile/local-mount/node_modules/readdirp/README.md +120 -0
- package/node_modules/@relayfile/local-mount/node_modules/readdirp/esm/index.d.ts +108 -0
- package/node_modules/@relayfile/local-mount/node_modules/readdirp/esm/index.js +257 -0
- package/node_modules/@relayfile/local-mount/node_modules/readdirp/esm/package.json +1 -0
- package/node_modules/@relayfile/local-mount/node_modules/readdirp/index.d.ts +108 -0
- package/node_modules/@relayfile/local-mount/node_modules/readdirp/index.js +263 -0
- package/node_modules/@relayfile/local-mount/node_modules/readdirp/package.json +70 -0
- package/node_modules/@relayfile/local-mount/package.json +47 -0
- package/node_modules/@smithy/config-resolver/package.json +2 -2
- package/node_modules/@smithy/core/dist-cjs/index.js +2 -1
- package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +32 -14
- package/node_modules/@smithy/core/dist-cjs/submodules/endpoints/index.js +2 -2
- package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.js +16 -8
- package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +17 -10
- package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +6 -1
- package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js +6 -3
- package/node_modules/@smithy/core/dist-cjs/util-identity-and-auth/DefaultIdentityProviderConfig.js +2 -1
- package/node_modules/@smithy/core/dist-es/submodules/cbor/CborCodec.js +23 -11
- package/node_modules/@smithy/core/dist-es/submodules/cbor/parseCborBody.js +9 -3
- package/node_modules/@smithy/core/dist-es/submodules/endpoints/toEndpointV1.js +2 -2
- package/node_modules/@smithy/core/dist-es/submodules/event-streams/EventStreamSerde.js +16 -8
- package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpBindingProtocol.js +9 -4
- package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpProtocol.js +8 -6
- package/node_modules/@smithy/core/dist-es/submodules/schema/TypeRegistry.js +6 -1
- package/node_modules/@smithy/core/dist-es/submodules/serde/parse-utils.js +6 -3
- package/node_modules/@smithy/core/dist-es/util-identity-and-auth/DefaultIdentityProviderConfig.js +2 -1
- package/node_modules/@smithy/core/dist-types/submodules/schema/TypeRegistry.d.ts +1 -1
- package/node_modules/@smithy/core/package.json +2 -2
- package/node_modules/@smithy/middleware-endpoint/package.json +3 -3
- package/node_modules/@smithy/middleware-retry/package.json +5 -5
- package/node_modules/@smithy/middleware-serde/package.json +2 -2
- package/node_modules/@smithy/node-http-handler/dist-cjs/index.js +188 -93
- package/node_modules/@smithy/node-http-handler/dist-es/http2/ClientHttp2SessionRef.js +45 -0
- package/node_modules/@smithy/node-http-handler/dist-es/node-http2-connection-manager.js +71 -35
- package/node_modules/@smithy/node-http-handler/dist-es/node-http2-connection-pool.js +32 -18
- package/node_modules/@smithy/node-http-handler/dist-es/node-http2-handler.js +41 -40
- package/node_modules/@smithy/node-http-handler/dist-types/http2/ClientHttp2SessionRef.d.ts +42 -0
- package/node_modules/@smithy/node-http-handler/dist-types/node-http2-connection-manager.d.ts +34 -14
- package/node_modules/@smithy/node-http-handler/dist-types/node-http2-connection-pool.d.ts +32 -8
- package/node_modules/@smithy/node-http-handler/dist-types/node-http2-handler.d.ts +0 -5
- package/node_modules/@smithy/node-http-handler/package.json +1 -1
- package/node_modules/@smithy/service-error-classification/dist-cjs/index.js +5 -0
- package/node_modules/@smithy/service-error-classification/dist-es/index.js +4 -0
- package/node_modules/@smithy/service-error-classification/dist-types/index.d.ts +6 -0
- package/node_modules/@smithy/service-error-classification/package.json +1 -1
- package/node_modules/@smithy/smithy-client/package.json +4 -4
- package/node_modules/@smithy/util-defaults-mode-browser/package.json +2 -2
- package/node_modules/@smithy/util-defaults-mode-node/package.json +3 -3
- package/node_modules/@smithy/util-endpoints/dist-cjs/index.js +65 -53
- package/node_modules/@smithy/util-endpoints/dist-es/utils/evaluateCondition.js +9 -7
- package/node_modules/@smithy/util-endpoints/dist-es/utils/evaluateConditions.js +12 -8
- package/node_modules/@smithy/util-endpoints/dist-es/utils/evaluateEndpointRule.js +14 -13
- package/node_modules/@smithy/util-endpoints/dist-es/utils/evaluateErrorRule.js +7 -4
- package/node_modules/@smithy/util-endpoints/dist-es/utils/evaluateExpression.js +10 -8
- package/node_modules/@smithy/util-endpoints/dist-es/utils/evaluateRules.js +4 -4
- package/node_modules/@smithy/util-endpoints/dist-es/utils/getEndpointHeaders.js +5 -5
- package/node_modules/@smithy/util-endpoints/dist-es/utils/getEndpointProperties.js +4 -4
- package/node_modules/@smithy/util-endpoints/dist-types/types/shared.d.ts +3 -3
- package/node_modules/@smithy/util-endpoints/dist-types/utils/endpointFunctions.d.ts +2 -15
- package/node_modules/@smithy/util-endpoints/dist-types/utils/evaluateCondition.d.ts +6 -3
- package/node_modules/@smithy/util-endpoints/dist-types/utils/evaluateConditions.d.ts +3 -3
- package/node_modules/@smithy/util-endpoints/dist-types/utils/getEndpointHeaders.d.ts +1 -1
- package/node_modules/@smithy/util-endpoints/dist-types/utils/getEndpointProperties.d.ts +2 -2
- package/node_modules/@smithy/util-endpoints/dist-types/utils/getReferenceValue.d.ts +2 -2
- package/node_modules/@smithy/util-endpoints/package.json +1 -1
- package/node_modules/@smithy/util-retry/package.json +2 -2
- package/node_modules/@smithy/util-stream/package.json +2 -2
- package/package.json +25 -11
- package/packages/cloud/package.json +2 -2
- package/packages/config/package.json +1 -1
- package/packages/hooks/package.json +4 -4
- package/packages/sdk/dist/workflows/runner.d.ts.map +1 -1
- package/packages/sdk/dist/workflows/runner.js +7 -5
- package/packages/sdk/dist/workflows/runner.js.map +1 -1
- package/packages/sdk/package.json +2 -2
- package/packages/telemetry/dist/config.d.ts +1 -1
- package/packages/telemetry/dist/config.d.ts.map +1 -1
- package/packages/telemetry/dist/config.js +6 -3
- package/packages/telemetry/dist/config.js.map +1 -1
- package/packages/telemetry/package.json +1 -1
- package/packages/trajectory/package.json +2 -2
- package/packages/user-directory/package.json +2 -2
- package/packages/utils/package.json +2 -2
- package/dist/src/cli/commands/on/symlink-mount.d.ts +0 -12
- package/dist/src/cli/commands/on/symlink-mount.d.ts.map +0 -1
- package/dist/src/cli/commands/on/symlink-mount.js.map +0 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/endpoint/ruleset.js +0 -146
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/endpoint/ruleset.js +0 -133
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/endpoint/ruleset.js +0 -106
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/endpoint/ruleset.js +0 -106
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/endpoint/ruleset.js +0 -145
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/cognito-identity/endpoint/ruleset.js +0 -143
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/signin/endpoint/ruleset.js +0 -130
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso/endpoint/ruleset.js +0 -103
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso-oidc/endpoint/ruleset.js +0 -103
- package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/endpoint/ruleset.js +0 -142
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/endpoint/ruleset.d.ts +0 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/endpoint/ruleset.d.ts +0 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/endpoint/ruleset.d.ts +0 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/endpoint/ruleset.d.ts +0 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/endpoint/ruleset.d.ts +0 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/endpoint/ruleset.d.ts +0 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/endpoint/ruleset.d.ts +0 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/endpoint/ruleset.d.ts +0 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/endpoint/ruleset.d.ts +0 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/endpoint/ruleset.d.ts +0 -2
|
@@ -425,58 +425,119 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
427
|
|
|
428
|
+
const ids = new Uint16Array(1);
|
|
429
|
+
class ClientHttp2SessionRef {
|
|
430
|
+
id = ids[0]++;
|
|
431
|
+
total = 0;
|
|
432
|
+
max = 0;
|
|
433
|
+
session;
|
|
434
|
+
refs = 0;
|
|
435
|
+
constructor(session) {
|
|
436
|
+
session.unref();
|
|
437
|
+
this.session = session;
|
|
438
|
+
}
|
|
439
|
+
retain() {
|
|
440
|
+
if (this.session.destroyed) {
|
|
441
|
+
throw new Error("@smithy/node-http-handler - cannot acquire reference to destroyed session.");
|
|
442
|
+
}
|
|
443
|
+
this.refs += 1;
|
|
444
|
+
this.total += 1;
|
|
445
|
+
this.max = Math.max(this.refs, this.max);
|
|
446
|
+
this.session.ref();
|
|
447
|
+
}
|
|
448
|
+
free() {
|
|
449
|
+
if (this.session.destroyed) {
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
this.refs -= 1;
|
|
453
|
+
if (this.refs === 0) {
|
|
454
|
+
this.session.unref();
|
|
455
|
+
}
|
|
456
|
+
if (this.refs < 0) {
|
|
457
|
+
throw new Error("@smithy/node-http-handler - ClientHttp2Session refcount at zero, cannot decrement.");
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
deref() {
|
|
461
|
+
return this.session;
|
|
462
|
+
}
|
|
463
|
+
destroy() {
|
|
464
|
+
this.refs = 0;
|
|
465
|
+
if (!this.session.destroyed) {
|
|
466
|
+
this.session.destroy();
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
useCount() {
|
|
470
|
+
return this.refs;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
428
474
|
class NodeHttp2ConnectionPool {
|
|
429
475
|
sessions = [];
|
|
476
|
+
maxConcurrency = 0;
|
|
430
477
|
constructor(sessions) {
|
|
431
|
-
this.sessions = sessions ?? [];
|
|
478
|
+
this.sessions = (sessions ?? []).map((session) => new ClientHttp2SessionRef(session));
|
|
432
479
|
}
|
|
433
480
|
poll() {
|
|
434
|
-
|
|
435
|
-
|
|
481
|
+
let cleanup = false;
|
|
482
|
+
for (const session of this.sessions) {
|
|
483
|
+
if (session.deref().destroyed) {
|
|
484
|
+
cleanup = true;
|
|
485
|
+
continue;
|
|
486
|
+
}
|
|
487
|
+
if (!this.maxConcurrency || session.useCount() < this.maxConcurrency) {
|
|
488
|
+
return session;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
if (cleanup) {
|
|
492
|
+
for (const session of this.sessions) {
|
|
493
|
+
if (session.deref().destroyed) {
|
|
494
|
+
this.remove(session);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
436
497
|
}
|
|
437
498
|
}
|
|
438
|
-
offerLast(
|
|
439
|
-
this.sessions.push(
|
|
440
|
-
}
|
|
441
|
-
contains(session) {
|
|
442
|
-
return this.sessions.includes(session);
|
|
499
|
+
offerLast(ref) {
|
|
500
|
+
this.sessions.push(ref);
|
|
443
501
|
}
|
|
444
|
-
remove(
|
|
445
|
-
|
|
502
|
+
remove(ref) {
|
|
503
|
+
const ix = this.sessions.indexOf(ref);
|
|
504
|
+
if (ix > -1) {
|
|
505
|
+
this.sessions.splice(ix, 1);
|
|
506
|
+
}
|
|
446
507
|
}
|
|
447
508
|
[Symbol.iterator]() {
|
|
448
509
|
return this.sessions[Symbol.iterator]();
|
|
449
510
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
}
|
|
457
|
-
}
|
|
511
|
+
setMaxConcurrency(maxConcurrency) {
|
|
512
|
+
this.maxConcurrency = maxConcurrency;
|
|
513
|
+
}
|
|
514
|
+
destroy(ref) {
|
|
515
|
+
this.remove(ref);
|
|
516
|
+
ref.destroy();
|
|
458
517
|
}
|
|
459
518
|
}
|
|
460
519
|
|
|
461
520
|
class NodeHttp2ConnectionManager {
|
|
521
|
+
config;
|
|
522
|
+
connectionPools = new Map();
|
|
462
523
|
constructor(config) {
|
|
463
524
|
this.config = config;
|
|
464
525
|
if (this.config.maxConcurrency && this.config.maxConcurrency <= 0) {
|
|
465
526
|
throw new RangeError("maxConcurrency must be greater than zero.");
|
|
466
527
|
}
|
|
467
528
|
}
|
|
468
|
-
config;
|
|
469
|
-
sessionCache = new Map();
|
|
470
529
|
lease(requestContext, connectionConfiguration) {
|
|
471
530
|
const url = this.getUrlString(requestContext);
|
|
472
|
-
const
|
|
473
|
-
if (
|
|
474
|
-
const
|
|
475
|
-
if (
|
|
476
|
-
|
|
531
|
+
const pool = this.getPool(url);
|
|
532
|
+
if (!this.config.disableConcurrency && !connectionConfiguration.isEventStream) {
|
|
533
|
+
const available = pool.poll();
|
|
534
|
+
if (available) {
|
|
535
|
+
available.retain();
|
|
536
|
+
return available;
|
|
477
537
|
}
|
|
478
538
|
}
|
|
479
|
-
const
|
|
539
|
+
const ref = new ClientHttp2SessionRef(http2.connect(url));
|
|
540
|
+
const session = ref.deref();
|
|
480
541
|
if (this.config.maxConcurrency) {
|
|
481
542
|
session.settings({ maxConcurrentStreams: this.config.maxConcurrency }, (err) => {
|
|
482
543
|
if (err) {
|
|
@@ -487,47 +548,48 @@ class NodeHttp2ConnectionManager {
|
|
|
487
548
|
}
|
|
488
549
|
});
|
|
489
550
|
}
|
|
490
|
-
session.unref();
|
|
491
551
|
const destroySessionCb = () => {
|
|
492
552
|
session.destroy();
|
|
493
|
-
this.
|
|
553
|
+
this.removeFromPool(url, ref);
|
|
494
554
|
};
|
|
495
555
|
session.on("goaway", destroySessionCb);
|
|
496
556
|
session.on("error", destroySessionCb);
|
|
497
557
|
session.on("frameError", destroySessionCb);
|
|
498
|
-
session.on("close", () => this.
|
|
558
|
+
session.on("close", () => this.removeFromPool(url, ref));
|
|
499
559
|
if (connectionConfiguration.requestTimeout) {
|
|
500
560
|
session.setTimeout(connectionConfiguration.requestTimeout, destroySessionCb);
|
|
501
561
|
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
return session;
|
|
562
|
+
pool.offerLast(ref);
|
|
563
|
+
ref.retain();
|
|
564
|
+
return ref;
|
|
506
565
|
}
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
if (!existingConnectionPool) {
|
|
510
|
-
return;
|
|
511
|
-
}
|
|
512
|
-
if (!existingConnectionPool.contains(session)) {
|
|
513
|
-
return;
|
|
514
|
-
}
|
|
515
|
-
existingConnectionPool.remove(session);
|
|
516
|
-
this.sessionCache.set(authority, existingConnectionPool);
|
|
566
|
+
release(_requestContext, ref) {
|
|
567
|
+
ref.free();
|
|
517
568
|
}
|
|
518
|
-
|
|
519
|
-
const
|
|
520
|
-
|
|
569
|
+
createIsolatedSession(requestContext, connectionConfiguration) {
|
|
570
|
+
const url = this.getUrlString(requestContext);
|
|
571
|
+
const ref = new ClientHttp2SessionRef(http2.connect(url));
|
|
572
|
+
const session = ref.deref();
|
|
573
|
+
session.settings({ maxConcurrentStreams: 1 });
|
|
574
|
+
const destroySession = () => {
|
|
575
|
+
session.destroy();
|
|
576
|
+
};
|
|
577
|
+
session.on("goaway", destroySession);
|
|
578
|
+
session.on("error", destroySession);
|
|
579
|
+
session.on("frameError", destroySession);
|
|
580
|
+
session.on("close", destroySession);
|
|
581
|
+
if (connectionConfiguration.requestTimeout) {
|
|
582
|
+
session.setTimeout(connectionConfiguration.requestTimeout, destroySession);
|
|
583
|
+
}
|
|
584
|
+
ref.retain();
|
|
585
|
+
return ref;
|
|
521
586
|
}
|
|
522
587
|
destroy() {
|
|
523
|
-
for (const [
|
|
524
|
-
for (const session of connectionPool) {
|
|
525
|
-
|
|
526
|
-
session.destroy();
|
|
527
|
-
}
|
|
528
|
-
connectionPool.remove(session);
|
|
588
|
+
for (const [url, connectionPool] of this.connectionPools) {
|
|
589
|
+
for (const session of [...connectionPool]) {
|
|
590
|
+
session.destroy();
|
|
529
591
|
}
|
|
530
|
-
this.
|
|
592
|
+
this.connectionPools.delete(url);
|
|
531
593
|
}
|
|
532
594
|
}
|
|
533
595
|
setMaxConcurrentStreams(maxConcurrentStreams) {
|
|
@@ -535,10 +597,42 @@ class NodeHttp2ConnectionManager {
|
|
|
535
597
|
throw new RangeError("maxConcurrentStreams must be greater than zero.");
|
|
536
598
|
}
|
|
537
599
|
this.config.maxConcurrency = maxConcurrentStreams;
|
|
600
|
+
for (const pool of this.connectionPools.values()) {
|
|
601
|
+
pool.setMaxConcurrency(maxConcurrentStreams);
|
|
602
|
+
}
|
|
538
603
|
}
|
|
539
604
|
setDisableConcurrentStreams(disableConcurrentStreams) {
|
|
540
605
|
this.config.disableConcurrency = disableConcurrentStreams;
|
|
541
606
|
}
|
|
607
|
+
debug() {
|
|
608
|
+
const pools = {};
|
|
609
|
+
for (const [url, pool] of this.connectionPools) {
|
|
610
|
+
const sessions = [];
|
|
611
|
+
for (const ref of pool) {
|
|
612
|
+
sessions.push({
|
|
613
|
+
id: ref.id,
|
|
614
|
+
active: ref.useCount(),
|
|
615
|
+
maxConcurrent: ref.max,
|
|
616
|
+
totalRequests: ref.total,
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
pools[url] = { sessions };
|
|
620
|
+
}
|
|
621
|
+
return pools;
|
|
622
|
+
}
|
|
623
|
+
removeFromPool(authority, ref) {
|
|
624
|
+
this.connectionPools.get(authority)?.remove(ref);
|
|
625
|
+
}
|
|
626
|
+
getPool(url) {
|
|
627
|
+
if (!this.connectionPools.has(url)) {
|
|
628
|
+
const pool = new NodeHttp2ConnectionPool();
|
|
629
|
+
if (this.config.maxConcurrency) {
|
|
630
|
+
pool.setMaxConcurrency(this.config.maxConcurrency);
|
|
631
|
+
}
|
|
632
|
+
this.connectionPools.set(url, pool);
|
|
633
|
+
}
|
|
634
|
+
return this.connectionPools.get(url);
|
|
635
|
+
}
|
|
542
636
|
getUrlString(request) {
|
|
543
637
|
return request.destination.toString();
|
|
544
638
|
}
|
|
@@ -575,12 +669,14 @@ class NodeHttp2Handler {
|
|
|
575
669
|
async handle(request, { abortSignal, requestTimeout, isEventStream } = {}) {
|
|
576
670
|
if (!this.config) {
|
|
577
671
|
this.config = await this.configProvider;
|
|
578
|
-
this.
|
|
579
|
-
|
|
580
|
-
|
|
672
|
+
const { disableConcurrentStreams, maxConcurrentStreams } = this.config;
|
|
673
|
+
this.connectionManager.setDisableConcurrentStreams(disableConcurrentStreams ?? false);
|
|
674
|
+
if (maxConcurrentStreams) {
|
|
675
|
+
this.connectionManager.setMaxConcurrentStreams(maxConcurrentStreams);
|
|
581
676
|
}
|
|
582
677
|
}
|
|
583
678
|
const { requestTimeout: configRequestTimeout, disableConcurrentStreams } = this.config;
|
|
679
|
+
const useIsolatedSession = disableConcurrentStreams || isEventStream;
|
|
584
680
|
const effectiveRequestTimeout = requestTimeout ?? configRequestTimeout;
|
|
585
681
|
return new Promise((_resolve, _reject) => {
|
|
586
682
|
let fulfilled = false;
|
|
@@ -608,13 +704,17 @@ class NodeHttp2Handler {
|
|
|
608
704
|
}
|
|
609
705
|
const authority = `${protocol}//${auth}${hostname}${port ? `:${port}` : ""}`;
|
|
610
706
|
const requestContext = { destination: new URL(authority) };
|
|
611
|
-
const
|
|
707
|
+
const connectConfig = {
|
|
612
708
|
requestTimeout: this.config?.sessionTimeout,
|
|
613
709
|
isEventStream,
|
|
614
|
-
}
|
|
710
|
+
};
|
|
711
|
+
const ref = useIsolatedSession
|
|
712
|
+
? this.connectionManager.createIsolatedSession(requestContext, connectConfig)
|
|
713
|
+
: this.connectionManager.lease(requestContext, connectConfig);
|
|
714
|
+
const session = ref.deref();
|
|
615
715
|
const rejectWithDestroy = (err) => {
|
|
616
|
-
if (
|
|
617
|
-
|
|
716
|
+
if (useIsolatedSession) {
|
|
717
|
+
ref.destroy();
|
|
618
718
|
}
|
|
619
719
|
fulfilled = true;
|
|
620
720
|
reject(err);
|
|
@@ -627,28 +727,14 @@ class NodeHttp2Handler {
|
|
|
627
727
|
if (request.fragment) {
|
|
628
728
|
path += `#${request.fragment}`;
|
|
629
729
|
}
|
|
630
|
-
const
|
|
730
|
+
const clientHttp2Stream = session.request({
|
|
631
731
|
...request.headers,
|
|
632
732
|
[http2.constants.HTTP2_HEADER_PATH]: path,
|
|
633
733
|
[http2.constants.HTTP2_HEADER_METHOD]: method,
|
|
634
734
|
});
|
|
635
|
-
session.ref();
|
|
636
|
-
req.on("response", (headers) => {
|
|
637
|
-
const httpResponse = new protocolHttp.HttpResponse({
|
|
638
|
-
statusCode: headers[":status"] ?? -1,
|
|
639
|
-
headers: getTransformedHeaders(headers),
|
|
640
|
-
body: req,
|
|
641
|
-
});
|
|
642
|
-
fulfilled = true;
|
|
643
|
-
resolve({ response: httpResponse });
|
|
644
|
-
if (disableConcurrentStreams) {
|
|
645
|
-
session.close();
|
|
646
|
-
this.connectionManager.deleteSession(authority, session);
|
|
647
|
-
}
|
|
648
|
-
});
|
|
649
735
|
if (effectiveRequestTimeout) {
|
|
650
|
-
|
|
651
|
-
|
|
736
|
+
clientHttp2Stream.setTimeout(effectiveRequestTimeout, () => {
|
|
737
|
+
clientHttp2Stream.close();
|
|
652
738
|
const timeoutError = new Error(`Stream timed out because of no activity for ${effectiveRequestTimeout} ms`);
|
|
653
739
|
timeoutError.name = "TimeoutError";
|
|
654
740
|
rejectWithDestroy(timeoutError);
|
|
@@ -656,36 +742,50 @@ class NodeHttp2Handler {
|
|
|
656
742
|
}
|
|
657
743
|
if (abortSignal) {
|
|
658
744
|
const onAbort = () => {
|
|
659
|
-
|
|
745
|
+
clientHttp2Stream.close();
|
|
660
746
|
const abortError = buildAbortError(abortSignal);
|
|
661
747
|
rejectWithDestroy(abortError);
|
|
662
748
|
};
|
|
663
749
|
if (typeof abortSignal.addEventListener === "function") {
|
|
664
750
|
const signal = abortSignal;
|
|
665
751
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
666
|
-
|
|
752
|
+
clientHttp2Stream.once("close", () => signal.removeEventListener("abort", onAbort));
|
|
667
753
|
}
|
|
668
754
|
else {
|
|
669
755
|
abortSignal.onabort = onAbort;
|
|
670
756
|
}
|
|
671
757
|
}
|
|
672
|
-
|
|
758
|
+
clientHttp2Stream.on("frameError", (type, code, id) => {
|
|
673
759
|
rejectWithDestroy(new Error(`Frame type id ${type} in stream id ${id} has failed with code ${code}.`));
|
|
674
760
|
});
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
rejectWithDestroy(new Error(`HTTP/2 stream is abnormally aborted in mid-communication with result code ${
|
|
761
|
+
clientHttp2Stream.on("error", rejectWithDestroy);
|
|
762
|
+
clientHttp2Stream.on("aborted", () => {
|
|
763
|
+
rejectWithDestroy(new Error(`HTTP/2 stream is abnormally aborted in mid-communication with result code ${clientHttp2Stream.rstCode}.`));
|
|
678
764
|
});
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
765
|
+
clientHttp2Stream.on("response", (headers) => {
|
|
766
|
+
const httpResponse = new protocolHttp.HttpResponse({
|
|
767
|
+
statusCode: headers[":status"] ?? -1,
|
|
768
|
+
headers: getTransformedHeaders(headers),
|
|
769
|
+
body: clientHttp2Stream,
|
|
770
|
+
});
|
|
771
|
+
fulfilled = true;
|
|
772
|
+
resolve({ response: httpResponse });
|
|
773
|
+
if (useIsolatedSession) {
|
|
774
|
+
session.close();
|
|
775
|
+
}
|
|
776
|
+
});
|
|
777
|
+
clientHttp2Stream.on("close", () => {
|
|
778
|
+
if (useIsolatedSession) {
|
|
779
|
+
ref.destroy();
|
|
780
|
+
}
|
|
781
|
+
else {
|
|
782
|
+
this.connectionManager.release(requestContext, ref);
|
|
683
783
|
}
|
|
684
784
|
if (!fulfilled) {
|
|
685
785
|
rejectWithDestroy(new Error("Unexpected error: http2 request did not get a response"));
|
|
686
786
|
}
|
|
687
787
|
});
|
|
688
|
-
writeRequestBodyPromise = writeRequestBody(
|
|
788
|
+
writeRequestBodyPromise = writeRequestBody(clientHttp2Stream, request, effectiveRequestTimeout);
|
|
689
789
|
});
|
|
690
790
|
}
|
|
691
791
|
updateHttpClientConfig(key, value) {
|
|
@@ -700,11 +800,6 @@ class NodeHttp2Handler {
|
|
|
700
800
|
httpHandlerConfigs() {
|
|
701
801
|
return this.config ?? {};
|
|
702
802
|
}
|
|
703
|
-
destroySession(session) {
|
|
704
|
-
if (!session.destroyed) {
|
|
705
|
-
session.destroy();
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
803
|
}
|
|
709
804
|
|
|
710
805
|
class Collector extends node_stream.Writable {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const ids = new Uint16Array(1);
|
|
2
|
+
export class ClientHttp2SessionRef {
|
|
3
|
+
id = ids[0]++;
|
|
4
|
+
total = 0;
|
|
5
|
+
max = 0;
|
|
6
|
+
session;
|
|
7
|
+
refs = 0;
|
|
8
|
+
constructor(session) {
|
|
9
|
+
session.unref();
|
|
10
|
+
this.session = session;
|
|
11
|
+
}
|
|
12
|
+
retain() {
|
|
13
|
+
if (this.session.destroyed) {
|
|
14
|
+
throw new Error("@smithy/node-http-handler - cannot acquire reference to destroyed session.");
|
|
15
|
+
}
|
|
16
|
+
this.refs += 1;
|
|
17
|
+
this.total += 1;
|
|
18
|
+
this.max = Math.max(this.refs, this.max);
|
|
19
|
+
this.session.ref();
|
|
20
|
+
}
|
|
21
|
+
free() {
|
|
22
|
+
if (this.session.destroyed) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
this.refs -= 1;
|
|
26
|
+
if (this.refs === 0) {
|
|
27
|
+
this.session.unref();
|
|
28
|
+
}
|
|
29
|
+
if (this.refs < 0) {
|
|
30
|
+
throw new Error("@smithy/node-http-handler - ClientHttp2Session refcount at zero, cannot decrement.");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
deref() {
|
|
34
|
+
return this.session;
|
|
35
|
+
}
|
|
36
|
+
destroy() {
|
|
37
|
+
this.refs = 0;
|
|
38
|
+
if (!this.session.destroyed) {
|
|
39
|
+
this.session.destroy();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
useCount() {
|
|
43
|
+
return this.refs;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
import http2 from "node:http2";
|
|
2
|
+
import { ClientHttp2SessionRef } from "./http2/ClientHttp2SessionRef";
|
|
2
3
|
import { NodeHttp2ConnectionPool } from "./node-http2-connection-pool";
|
|
3
4
|
export class NodeHttp2ConnectionManager {
|
|
5
|
+
config;
|
|
6
|
+
connectionPools = new Map();
|
|
4
7
|
constructor(config) {
|
|
5
8
|
this.config = config;
|
|
6
9
|
if (this.config.maxConcurrency && this.config.maxConcurrency <= 0) {
|
|
7
10
|
throw new RangeError("maxConcurrency must be greater than zero.");
|
|
8
11
|
}
|
|
9
12
|
}
|
|
10
|
-
config;
|
|
11
|
-
sessionCache = new Map();
|
|
12
13
|
lease(requestContext, connectionConfiguration) {
|
|
13
14
|
const url = this.getUrlString(requestContext);
|
|
14
|
-
const
|
|
15
|
-
if (
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
18
|
-
|
|
15
|
+
const pool = this.getPool(url);
|
|
16
|
+
if (!this.config.disableConcurrency && !connectionConfiguration.isEventStream) {
|
|
17
|
+
const available = pool.poll();
|
|
18
|
+
if (available) {
|
|
19
|
+
available.retain();
|
|
20
|
+
return available;
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
|
-
const
|
|
23
|
+
const ref = new ClientHttp2SessionRef(http2.connect(url));
|
|
24
|
+
const session = ref.deref();
|
|
22
25
|
if (this.config.maxConcurrency) {
|
|
23
26
|
session.settings({ maxConcurrentStreams: this.config.maxConcurrency }, (err) => {
|
|
24
27
|
if (err) {
|
|
@@ -29,47 +32,48 @@ export class NodeHttp2ConnectionManager {
|
|
|
29
32
|
}
|
|
30
33
|
});
|
|
31
34
|
}
|
|
32
|
-
session.unref();
|
|
33
35
|
const destroySessionCb = () => {
|
|
34
36
|
session.destroy();
|
|
35
|
-
this.
|
|
37
|
+
this.removeFromPool(url, ref);
|
|
36
38
|
};
|
|
37
39
|
session.on("goaway", destroySessionCb);
|
|
38
40
|
session.on("error", destroySessionCb);
|
|
39
41
|
session.on("frameError", destroySessionCb);
|
|
40
|
-
session.on("close", () => this.
|
|
42
|
+
session.on("close", () => this.removeFromPool(url, ref));
|
|
41
43
|
if (connectionConfiguration.requestTimeout) {
|
|
42
44
|
session.setTimeout(connectionConfiguration.requestTimeout, destroySessionCb);
|
|
43
45
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return session;
|
|
46
|
+
pool.offerLast(ref);
|
|
47
|
+
ref.retain();
|
|
48
|
+
return ref;
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (!existingConnectionPool) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
if (!existingConnectionPool.contains(session)) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
existingConnectionPool.remove(session);
|
|
58
|
-
this.sessionCache.set(authority, existingConnectionPool);
|
|
50
|
+
release(_requestContext, ref) {
|
|
51
|
+
ref.free();
|
|
59
52
|
}
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
53
|
+
createIsolatedSession(requestContext, connectionConfiguration) {
|
|
54
|
+
const url = this.getUrlString(requestContext);
|
|
55
|
+
const ref = new ClientHttp2SessionRef(http2.connect(url));
|
|
56
|
+
const session = ref.deref();
|
|
57
|
+
session.settings({ maxConcurrentStreams: 1 });
|
|
58
|
+
const destroySession = () => {
|
|
59
|
+
session.destroy();
|
|
60
|
+
};
|
|
61
|
+
session.on("goaway", destroySession);
|
|
62
|
+
session.on("error", destroySession);
|
|
63
|
+
session.on("frameError", destroySession);
|
|
64
|
+
session.on("close", destroySession);
|
|
65
|
+
if (connectionConfiguration.requestTimeout) {
|
|
66
|
+
session.setTimeout(connectionConfiguration.requestTimeout, destroySession);
|
|
67
|
+
}
|
|
68
|
+
ref.retain();
|
|
69
|
+
return ref;
|
|
63
70
|
}
|
|
64
71
|
destroy() {
|
|
65
|
-
for (const [
|
|
66
|
-
for (const session of connectionPool) {
|
|
67
|
-
|
|
68
|
-
session.destroy();
|
|
69
|
-
}
|
|
70
|
-
connectionPool.remove(session);
|
|
72
|
+
for (const [url, connectionPool] of this.connectionPools) {
|
|
73
|
+
for (const session of [...connectionPool]) {
|
|
74
|
+
session.destroy();
|
|
71
75
|
}
|
|
72
|
-
this.
|
|
76
|
+
this.connectionPools.delete(url);
|
|
73
77
|
}
|
|
74
78
|
}
|
|
75
79
|
setMaxConcurrentStreams(maxConcurrentStreams) {
|
|
@@ -77,10 +81,42 @@ export class NodeHttp2ConnectionManager {
|
|
|
77
81
|
throw new RangeError("maxConcurrentStreams must be greater than zero.");
|
|
78
82
|
}
|
|
79
83
|
this.config.maxConcurrency = maxConcurrentStreams;
|
|
84
|
+
for (const pool of this.connectionPools.values()) {
|
|
85
|
+
pool.setMaxConcurrency(maxConcurrentStreams);
|
|
86
|
+
}
|
|
80
87
|
}
|
|
81
88
|
setDisableConcurrentStreams(disableConcurrentStreams) {
|
|
82
89
|
this.config.disableConcurrency = disableConcurrentStreams;
|
|
83
90
|
}
|
|
91
|
+
debug() {
|
|
92
|
+
const pools = {};
|
|
93
|
+
for (const [url, pool] of this.connectionPools) {
|
|
94
|
+
const sessions = [];
|
|
95
|
+
for (const ref of pool) {
|
|
96
|
+
sessions.push({
|
|
97
|
+
id: ref.id,
|
|
98
|
+
active: ref.useCount(),
|
|
99
|
+
maxConcurrent: ref.max,
|
|
100
|
+
totalRequests: ref.total,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
pools[url] = { sessions };
|
|
104
|
+
}
|
|
105
|
+
return pools;
|
|
106
|
+
}
|
|
107
|
+
removeFromPool(authority, ref) {
|
|
108
|
+
this.connectionPools.get(authority)?.remove(ref);
|
|
109
|
+
}
|
|
110
|
+
getPool(url) {
|
|
111
|
+
if (!this.connectionPools.has(url)) {
|
|
112
|
+
const pool = new NodeHttp2ConnectionPool();
|
|
113
|
+
if (this.config.maxConcurrency) {
|
|
114
|
+
pool.setMaxConcurrency(this.config.maxConcurrency);
|
|
115
|
+
}
|
|
116
|
+
this.connectionPools.set(url, pool);
|
|
117
|
+
}
|
|
118
|
+
return this.connectionPools.get(url);
|
|
119
|
+
}
|
|
84
120
|
getUrlString(request) {
|
|
85
121
|
return request.destination.toString();
|
|
86
122
|
}
|
|
@@ -1,32 +1,46 @@
|
|
|
1
|
+
import { ClientHttp2SessionRef } from "./http2/ClientHttp2SessionRef";
|
|
1
2
|
export class NodeHttp2ConnectionPool {
|
|
2
3
|
sessions = [];
|
|
4
|
+
maxConcurrency = 0;
|
|
3
5
|
constructor(sessions) {
|
|
4
|
-
this.sessions = sessions ?? [];
|
|
6
|
+
this.sessions = (sessions ?? []).map((session) => new ClientHttp2SessionRef(session));
|
|
5
7
|
}
|
|
6
8
|
poll() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
let cleanup = false;
|
|
10
|
+
for (const session of this.sessions) {
|
|
11
|
+
if (session.deref().destroyed) {
|
|
12
|
+
cleanup = true;
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
if (!this.maxConcurrency || session.useCount() < this.maxConcurrency) {
|
|
16
|
+
return session;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (cleanup) {
|
|
20
|
+
for (const session of this.sessions) {
|
|
21
|
+
if (session.deref().destroyed) {
|
|
22
|
+
this.remove(session);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
9
25
|
}
|
|
10
26
|
}
|
|
11
|
-
offerLast(
|
|
12
|
-
this.sessions.push(
|
|
13
|
-
}
|
|
14
|
-
contains(session) {
|
|
15
|
-
return this.sessions.includes(session);
|
|
27
|
+
offerLast(ref) {
|
|
28
|
+
this.sessions.push(ref);
|
|
16
29
|
}
|
|
17
|
-
remove(
|
|
18
|
-
|
|
30
|
+
remove(ref) {
|
|
31
|
+
const ix = this.sessions.indexOf(ref);
|
|
32
|
+
if (ix > -1) {
|
|
33
|
+
this.sessions.splice(ix, 1);
|
|
34
|
+
}
|
|
19
35
|
}
|
|
20
36
|
[Symbol.iterator]() {
|
|
21
37
|
return this.sessions[Symbol.iterator]();
|
|
22
38
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
}
|
|
39
|
+
setMaxConcurrency(maxConcurrency) {
|
|
40
|
+
this.maxConcurrency = maxConcurrency;
|
|
41
|
+
}
|
|
42
|
+
destroy(ref) {
|
|
43
|
+
this.remove(ref);
|
|
44
|
+
ref.destroy();
|
|
31
45
|
}
|
|
32
46
|
}
|