Skip to content

Commit 7547f30

Browse files
committed
fix: convert identifiers into Map<String,String>
1 parent 28ed0a2 commit 7547f30

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

packages/middleware-endpoint-discovery/src/getCacheKey.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ export const getCacheKey = async (
88
commandName: string,
99
config: AwsAuthResolvedConfig & RegionResolvedConfig,
1010
options: {
11-
endpointDiscoveryId?: string;
11+
identifiers?: Map<String, String>;
1212
}
1313
) => {
1414
const region = await config.region();
1515
const { accessKeyId } = await config.credentials();
16-
const { endpointDiscoveryId } = options;
16+
const { identifiers } = options;
1717
return {
1818
commandName,
1919
...(region && { region }),
2020
...(accessKeyId && { accessKeyId }),
21-
...(endpointDiscoveryId && { endpointDiscoveryId }),
21+
...(identifiers && { identifiers }),
2222
}.toString();
2323
};

packages/middleware-endpoint-discovery/src/getEndpointDiscoveryCommandPlugin.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { HttpRequest } from "@aws-sdk/protocol-http";
22
import {
3-
Command,
43
FinalizeHandler,
54
FinalizeHandlerArguments,
65
FinalizeHandlerOutput,
@@ -23,7 +22,7 @@ export const endpointDiscoveryMiddlewareOptions: FinalizeRequestHandlerOptions =
2322

2423
export type EndpointDiscoveryMiddlewareConfig = {
2524
isDiscoveredEndpointRequired: boolean;
26-
endpointDiscoveryId?: string;
25+
identifiers?: Map<String, String>;
2726
};
2827

2928
export const endpointDiscoveryMiddleware = (
@@ -37,7 +36,7 @@ export const endpointDiscoveryMiddleware = (
3736
): Promise<FinalizeHandlerOutput<Output>> => {
3837
const { client } = config;
3938
const { endpointDiscoveryCommandCtor } = client?.config;
40-
const { isDiscoveredEndpointRequired, endpointDiscoveryId } = middlewareConfig;
39+
const { isDiscoveredEndpointRequired, identifiers } = middlewareConfig;
4140
const { commandName } = context;
4241

4342
if (isDiscoveredEndpointRequired === true) {
@@ -46,20 +45,20 @@ export const endpointDiscoveryMiddleware = (
4645
await updateDiscoveredEndpointInCache(config, {
4746
commandName,
4847
endpointDiscoveryCommandCtor,
49-
endpointDiscoveryId,
48+
identifiers,
5049
});
5150
} else if (isDiscoveredEndpointRequired === false) {
5251
// Do not call await await on Endpoint Discovery API utility so that function
5352
// does not block, the command will use discovered endpoint, if available.
5453
updateDiscoveredEndpointInCache(config, {
5554
commandName,
5655
endpointDiscoveryCommandCtor,
57-
endpointDiscoveryId,
56+
identifiers,
5857
});
5958
}
6059

6160
const { request } = args;
62-
const cacheKey = await getCacheKey(commandName, client?.config, { endpointDiscoveryId });
61+
const cacheKey = await getCacheKey(commandName, client?.config, { identifiers });
6362
if (cacheKey && HttpRequest.isInstance(request)) {
6463
const endpoints = client?.config.endpointCache.get(cacheKey);
6564
if (endpoints && endpoints.length > 0) {

packages/middleware-endpoint-discovery/src/updateDiscoveredEndpointInCache.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { EndpointDiscoveryClientResolvedConfig } from "./resolveEndpointDiscover
66
export type updateDiscoveredEndpointInCacheOptions = {
77
commandName: string;
88
endpointDiscoveryCommandCtor: new (comandConfig: any) => Command<any, any, any, any, any>;
9-
endpointDiscoveryId?: string;
9+
identifiers?: Map<String, String>;
1010
};
1111

1212
export const updateDiscoveredEndpointInCache = async (
@@ -16,8 +16,8 @@ export const updateDiscoveredEndpointInCache = async (
1616
const { client } = config;
1717
const { endpointCache } = client?.config;
1818

19-
const { commandName, endpointDiscoveryId } = options;
20-
const cacheKey = await getCacheKey(commandName, client?.config, { endpointDiscoveryId });
19+
const { commandName, identifiers } = options;
20+
const cacheKey = await getCacheKey(commandName, client?.config, { identifiers });
2121

2222
const endpoints = endpointCache.get(cacheKey);
2323
if (endpoints && endpoints.length === 1 && endpoints[0].Address === "") {
@@ -40,7 +40,7 @@ export const updateDiscoveredEndpointInCache = async (
4040
try {
4141
const command = new options.endpointDiscoveryCommandCtor({
4242
Operation: commandName.substr(0, commandName.length - 7), // strip "Command"
43-
Identifiers: endpointDiscoveryId,
43+
Identifiers: identifiers,
4444
});
4545
const { Endpoints } = await client?.send(command);
4646
endpointCache.set(cacheKey, Endpoints);

0 commit comments

Comments
 (0)