Skip to content
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

Smithy Rules engine #1356

Merged
merged 44 commits into from
Oct 10, 2022
Merged

Smithy Rules engine #1356

merged 44 commits into from
Oct 10, 2022

Conversation

skmcgrail
Copy link
Contributor

@skmcgrail skmcgrail commented Aug 17, 2022

Implementation of the Smithy Rules Engine Language

Copy link
Contributor

@kstich kstich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partially through, posting so edits can be made while review continues.

* The type of validation error that has occurred.
*/
@SmithyUnstableApi
public enum ValidationErrorType {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be an inner enum of ValidationError as Type if it sticks around, otherwise it seems like these are event ids.

builder.type(ParameterType.BOOLEAN);
break;
default:
throw new IllegalArgumentException(java.lang.String.format(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a separate exception and not a validation event?

public final class EndpointTestsTraitValidator extends AbstractValidator {
@Override
public List<ValidationEvent> validate(Model model) {
return null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this validation is missing or somewhere else meaning the class isn't needed anymore.

private StandaloneRulesetValidator() {
}

public static Stream<ValidationError> validate(EndpointRuleSet ruleset, EndpointTestsTrait testSuite) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this wired up to validate definitions automatically?

Why do the validators listed here not use the built in ValidationEvent system? I don't see anything in the validators that preclude using it. Multiple event IDs can be generated from the same validator by using the Builder instead of the ease-of-use functions.

* A set of EndpointRules. Endpoint Rules describe the endpoint resolution behavior for a service.
*/
@SmithyUnstableApi
public final class EndpointRuleSet extends MandatorySourceLocation implements TypeCheck, ToNode {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Public methods are missing javadoc.

}

@Override
public Type typeCheck(Scope<Type> scope) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use some internal documentation.

});
}

public void typecheck() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has different casing from typeCheck. It's also only used in a test and doesn't have the same return type. Is it needed?

private Node rulesNode() {
ArrayNode.Builder node = ArrayNode.builder();
rules.forEach(node::withValue);
return node.build();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will return an empty array node [] even if there are no rules.

* permissions and limitations under the License.
*/

package software.amazon.smithy.rulesengine.language.impl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only thing in this package and it's AWS specific, should it move?

this.service = SmithyBuilder.requiredState("service", builder.service);
this.region = SmithyBuilder.requiredState("region", builder.region);
this.accountId = SmithyBuilder.requiredState("accountId", builder.accountId);
this.resource = builder.resource.copy();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this required as well?

* An AWS ARN.
*/
@SmithyUnstableApi
public final class AwsArn implements ToSmithyBuilder<AwsArn> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs builder and method level javadoc.

* permissions and limitations under the License.
*/

package software.amazon.smithy.rulesengine.language.stdlib;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe functions instead of stdlib?

@kstich
Copy link
Contributor

kstich commented Oct 4, 2022

Looks like Windows CI is failing as well, these are usually due to a path issue around / characters here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants