@@ -49,7 +49,7 @@ final class EndpointGenerator implements Runnable {
49
49
private final String endpointPrefix ;
50
50
private final String baseSigningService ;
51
51
private final Map <String , Partition > partitions = new TreeMap <>();
52
- private final Map <String , ObjectNode > endpoints = new TreeMap <>();
52
+ private final Map <String , Endpoint > endpoints = new TreeMap <>();
53
53
54
54
EndpointGenerator (ServiceShape service , TypeScriptWriter writer ) {
55
55
this .writer = writer ;
@@ -88,19 +88,17 @@ private void loadServiceEndpoints() {
88
88
ObjectNode serviceData = partition .getService ();
89
89
ObjectNode endpointMap = serviceData .getObjectMember ("endpoints" ).orElse (Node .objectNode ());
90
90
91
- // If partition endpoint is available, data will be populated in PartitionHash.
92
- if (!partition .getPartitionEndpoint ().isPresent ()) {
93
- for (Map .Entry <String , Node > entry : endpointMap .getStringMap ().entrySet ()) {
94
- ObjectNode config = entry .getValue ().expectObjectNode ();
95
- if (config .containsMember ("hostname" )) {
96
- // Resolve the hostname.
97
- String hostName = config .expectStringMember ("hostname" ).getValue ();
98
- hostName = hostName .replace ("{dnsSuffix}" , dnsSuffix );
99
- hostName = hostName .replace ("{service}" , endpointPrefix );
100
- hostName = hostName .replace ("{region}" , entry .getKey ());
101
- config = config .withMember ("hostname" , hostName );
102
- endpoints .put (entry .getKey (), config );
103
- }
91
+ for (Map .Entry <String , Node > entry : endpointMap .getStringMap ().entrySet ()) {
92
+ ObjectNode config = entry .getValue ().expectObjectNode ();
93
+ if (config .containsMember ("hostname" )) {
94
+ // Resolve the hostname.
95
+ String hostName = config .expectStringMember ("hostname" ).getValue ();
96
+ hostName = hostName .replace ("{dnsSuffix}" , dnsSuffix );
97
+ hostName = hostName .replace ("{service}" , endpointPrefix );
98
+ hostName = hostName .replace ("{region}" , entry .getKey ());
99
+ config = config .withMember ("hostname" , hostName );
100
+ Endpoint endpoint = new Endpoint (config , partition .getPartitionEndpoint ().isPresent ());
101
+ endpoints .put (entry .getKey (), endpoint );
104
102
}
105
103
}
106
104
}
@@ -116,8 +114,11 @@ public void run() {
116
114
private void writeRegionHash () {
117
115
writer .addImport ("RegionHash" , "RegionHash" , TypeScriptDependency .CONFIG_RESOLVER .packageName );
118
116
writer .openBlock ("const regionHash: RegionHash = {" , "};" , () -> {
119
- for (Map .Entry <String , ObjectNode > entry : endpoints .entrySet ()) {
120
- writeEndpointSpecificResolver (entry .getKey (), entry .getValue ());
117
+ for (Map .Entry <String , Endpoint > entry : endpoints .entrySet ()) {
118
+ Endpoint endpoint = entry .getValue ();
119
+ if (!endpoint .isPartitionEndpoint ) {
120
+ writeEndpointSpecificResolver (entry .getKey (), endpoint .config );
121
+ }
121
122
}
122
123
});
123
124
writer .write ("" );
@@ -174,6 +175,16 @@ private void writeEndpointSpecificResolver(String region, ObjectNode resolved) {
174
175
}
175
176
}
176
177
178
+ private final class Endpoint {
179
+ final ObjectNode config ;
180
+ final boolean isPartitionEndpoint ;
181
+
182
+ private Endpoint (ObjectNode config , boolean isPartitionEndpoint ) {
183
+ this .config = config ;
184
+ this .isPartitionEndpoint = isPartitionEndpoint ;
185
+ }
186
+ }
187
+
177
188
private final class Partition {
178
189
final ObjectNode defaults ;
179
190
final String hostnameTemplate ;
0 commit comments