Added :session-token and :client-id to enable temporary session credentials #28
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
AWS session credentials include a session token so which is now accepted in your
cred
map as:session-token
.Because
s3-client
usesmemoize
to cache clients and temporary session credentials are... temporary, it was necessary to improve the client caching strategy to avoid creating a new client every time the session credentials expire and get refreshed. See #15 for the full rationale.The caching strategy used in this pull request, behaves just like the
memoize
solution, unless a:client-id
is included in thecred
map. The client-id is used as the cache key instead of the map itself so that only one client is cached for each client-id. When the client is cached, the arguments used to create it are cached as well and a new client is created when the arguments change.This solution should continue to avoid issue #3 except in a very limited case where the same client-id is used on multiple threads and the first client gets booted from the cache and GC'd too soon. A better solution may be to return a reference to the client used for each request in the response so the caller can hold onto it until it's ok for the client to be GC'd.