-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add protocol resolution priority system (#1370)
* feat(cbor): add protocol resolution priority system * test: update test code comments * subordinate ProtocolPriorityConfig to TypeScriptSettings * use immutable config for protocol priority
- Loading branch information
Showing
8 changed files
with
376 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...main/java/software/amazon/smithy/typescript/codegen/protocols/ProtocolPriorityConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package software.amazon.smithy.typescript.codegen.protocols; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
import software.amazon.smithy.model.shapes.ShapeId; | ||
|
||
|
||
/** | ||
* Allows customization of protocol selection for specific services or a global default ordering. | ||
*/ | ||
public final class ProtocolPriorityConfig { | ||
private final Map<ShapeId, List<ShapeId>> serviceProtocolPriorityCustomizations; | ||
private final List<ShapeId> customDefaultPriority; | ||
|
||
public ProtocolPriorityConfig( | ||
Map<ShapeId, List<ShapeId>> serviceProtocolPriorityCustomizations, | ||
List<ShapeId> customDefaultPriority | ||
) { | ||
this.serviceProtocolPriorityCustomizations = | ||
Objects.requireNonNullElseGet(serviceProtocolPriorityCustomizations, HashMap::new); | ||
this.customDefaultPriority = customDefaultPriority; | ||
} | ||
|
||
/** | ||
* @param serviceShapeId - service scope. | ||
* @return priority order of protocols or null if no override exists. | ||
*/ | ||
public List<ShapeId> getProtocolPriority(ShapeId serviceShapeId) { | ||
return serviceProtocolPriorityCustomizations.getOrDefault( | ||
serviceShapeId, | ||
customDefaultPriority != null ? new ArrayList<>(customDefaultPriority) : null | ||
); | ||
} | ||
} |
Oops, something went wrong.