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(smithy-client): add handler cache #1383

Merged
merged 3 commits into from
Sep 9, 2024
Merged

Conversation

kuhe
Copy link
Contributor

@kuhe kuhe commented Aug 30, 2024

aws/aws-sdk-js-v3#6423

This adds a cache for the handler functions resolved from calls to

command.resolveMiddleware(client.middlewareStack, client.config, (request) options)

when options is undefined. This occurs in the request path and can take 1-2ms, but is redundant for any client/command pair in most cases.

Despite being cached, the handler functions has a reference to the client config, so any changes there will still be visible to the middleware within the resolved handler. Modifying a client's middlewareStack invalidates the cache.

The cache is opt-in and also unique per client, so users retain control that way.

@kuhe kuhe force-pushed the feat/client branch 4 times, most recently from 42b892d to 659e4f7 Compare September 3, 2024 20:05
@kuhe
Copy link
Contributor Author

kuhe commented Sep 5, 2024

putting this into draft while I reevaluate whether this change is worth it or not

update: the main issue was how to detect when to invalidate the cache. Rather than solving that problem, which may have made things worse for the problem the cache is solving, I've made the use of it configurable and opt-in.

@kuhe kuhe marked this pull request as ready for review September 6, 2024 15:43
@kuhe kuhe merged commit d8df7bf into smithy-lang:main Sep 9, 2024
11 checks passed
@kuhe kuhe deleted the feat/client branch September 9, 2024 15:56
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