-
Notifications
You must be signed in to change notification settings - Fork 7
Add endpoint rules engine #681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mtdowling
wants to merge
3
commits into
main
Choose a base branch
from
rules-engine
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or 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
sugmanue
reviewed
May 7, 2025
...-rulesengine/src/main/java/software/amazon/smithy/java/client/rulesengine/EndpointUtils.java
Outdated
Show resolved
Hide resolved
9816154
to
d32e674
Compare
sugmanue
approved these changes
May 8, 2025
...-rulesengine/src/main/java/software/amazon/smithy/java/client/rulesengine/RulesCompiler.java
Outdated
Show resolved
Hide resolved
...client-rulesengine/src/main/java/software/amazon/smithy/java/client/rulesengine/RulesVm.java
Outdated
Show resolved
Hide resolved
...client-rulesengine/src/main/java/software/amazon/smithy/java/client/rulesengine/RulesVm.java
Outdated
Show resolved
Hide resolved
...gine/src/main/java/software/amazon/smithy/java/client/rulesengine/EndpointRulesResolver.java
Outdated
Show resolved
Hide resolved
.../client-rulesengine/src/main/java/software/amazon/smithy/java/client/rulesengine/Stdlib.java
Outdated
Show resolved
Hide resolved
a31dfa0
to
f907ec4
Compare
sugmanue
approved these changes
May 9, 2025
...t-rulesengine/src/main/java/software/amazon/smithy/java/client/rulesengine/RulesProgram.java
Outdated
Show resolved
Hide resolved
sugmanue
reviewed
May 9, 2025
...client-core/src/main/java/software/amazon/smithy/java/client/core/endpoint/EndpointImpl.java
Show resolved
Hide resolved
43abf17
to
7aec981
Compare
.../client-rulesengine/src/jmh/java/software/amazon/smithy/java/client/rulesengine/VmBench.java
Outdated
Show resolved
Hide resolved
...client-rulesengine/src/main/java/software/amazon/smithy/java/client/rulesengine/RulesVm.java
Outdated
Show resolved
Hide resolved
...client-rulesengine/src/main/java/software/amazon/smithy/java/client/rulesengine/RulesVm.java
Outdated
Show resolved
Hide resolved
buildSrc/src/main/kotlin/smithy-java.module-conventions.gradle.kts
Outdated
Show resolved
Hide resolved
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This commit implements the Smithy rules engine, which will primarily allow clients to resolve endpoints with the rules engine.
Overview
The rules engine is implemented as a stack-based VM. First it compiles rules engine expressions into bytecode, then evaluates it. These are the main building blocks of the VM:
Bytecode layout
r0
,r1
, etc).Example program
Original endpoint rules definition:
Using the rules engine with clients
Codegenerated clients:
A code generated client will (eventually) use a precompiled rules engine program and apply the
EndpointRulesPlugin
to the client in its constructor. We will eventually code generate the code needed to callRulesEngine#fromPrecompiled
. This will avoid any need to load the complex rules engine traits at runtime or compile them.Dynamic clients:
Dynamic clients can apply the
EndpointRulesPlugin
usingEndpointRulesPlugin#create
. This method will look for the rules engine traits on the service's schema, and if found, compile them and apply an endpoint resolver. If the config already has an endpoint resolver or if no traits are found, the plugin does nothing.Benchmarks
On my M1 mac:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.