Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable ctor arg passthrough for requestHandler #1167

Merged
merged 5 commits into from
Feb 22, 2024

Conversation

kuhe
Copy link
Contributor

@kuhe kuhe commented Feb 21, 2024

This implements step 3 of the following progression mentioned earlier in #1165.

Simplifying provision of custom settings to the requestHandler.

Previously:

import https from "node:https";
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { NodeHttpHandler } from "@smithy/node-http-handler";

const client = new DynamoDBClient({
  requestHandler: new NodeHttpHandler({
    requestTimeout: 3_000,
    httpsAgent: new https.Agent({
      maxSockets: 25
    }),
  }),
});

Step 2 (implemented):

import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { NodeHttpHandler } from "@smithy/node-http-handler";

const client = new DynamoDBClient({
  requestHandler: new NodeHttpHandler({
    requestTimeout: 3_000,
    httpsAgent: { maxSockets: 25 },
  }),
});

Step 3 (this PR):

import { DynamoDBClient } from "@aws-sdk/client-dynamodb";

const client = new DynamoDBClient({
  requestHandler: {
    requestTimeout: 3_000,
    httpsAgent: { maxSockets: 25 },
  },
});

// the longer forms will still be valid

AWS SDK sample diff in aws/aws-sdk-js-v3#5820

@@ -253,11 +253,13 @@ private void generateClientDefaults() {

writer.writeDocs("@public")
.openBlock("export interface ClientDefaults\n"
+ " extends Partial<__SmithyResolvedConfiguration<$T>> {", "}",
+ " extends Partial<__SmithyConfiguration<$T>> {", "}",
Copy link
Contributor Author

@kuhe kuhe Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ClientDefaults is on the input side, and should not have been assigned the ResolvedConfig version of "SmithyConfiguration". This correction is backwards compatible.

MiddlewareStack,
NodeHttpHandlerOptions,
RequestHandler,
} from "@smithy/types";

/**
* @public
*/
export interface SmithyConfiguration<HandlerOptions> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an input config corresponding to the resolved config below. So, it can be loosened.

@kuhe kuhe marked this pull request as ready for review February 21, 2024 22:00
@kuhe kuhe requested review from a team as code owners February 21, 2024 22:00
@kuhe kuhe requested a review from milesziemer February 21, 2024 22:00
@kuhe kuhe merged commit 929801b into smithy-lang:main Feb 22, 2024
7 checks passed
@kuhe kuhe deleted the feat/requestHandler branch February 22, 2024 20:59
kuhe added a commit to aws/aws-sdk-js-v3 that referenced this pull request Feb 23, 2024
SDK Clients' requestHandler field can now accept constructor parameters instead of needing the constructor call itself.
See smithy-lang/smithy-typescript#1167.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants