Skip to content

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 requested review from a team as code owners August 30, 2024 14:52
@kuhe kuhe requested a review from gosar August 30, 2024 14:52
@kuhe kuhe force-pushed the feat/client branch 2 times, most recently from 46a9e3b to 10ed6c1 Compare August 30, 2024 15:42
@kuhe kuhe force-pushed the feat/client branch 4 times, most recently from 42b892d to 659e4f7 Compare September 3, 2024 20:05
@kuhe kuhe marked this pull request as draft September 5, 2024 19:10
@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