-
Notifications
You must be signed in to change notification settings - Fork 105
Generate per-operation ServiceHandlers #304
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
Generate per-operation ServiceHandlers #304
Conversation
writeSerdeContextBase(writer); | ||
writeHandleFunction(writer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't these be somewhere shared?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean written to one TS file that's shared between the two? Seemed more complicated than it was worth to me at the time. Besides, the duplicates should always be tree-shaken out, right?
writer.openBlock("input = await serializer.deserialize(request, {", "});", () -> { | ||
writer.write("endpoint: () => Promise.resolve(request), ...this.serdeContextBase"); | ||
}); | ||
static void generateOperationHandler(SymbolProvider symbolProvider, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be in the operation generator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my head ServerGenerator was for anything related to the higher-level server abstractions -- meaning not deserialization. I could rip this apart and move some of it to ServiceGenerator and some of it to OperationGenerator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well there's the unfortunately named ServerCommandGenerator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's mostly serde right? Maybe the distinction isn't worth it, idk.
operation.getId().getName(), | ||
() -> { | ||
HttpTrait httpTrait = operation.expectTrait(HttpTrait.class); | ||
generateUriSpec(context, operation, httpTrait); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this is overkill, but could this be shared so it's only defined once?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean the UriSpec is only defined in TS once? These end up in different files, so I'd have to have a uri specs file, and generate and export a unique const per spec. Or generate a UriSpec factory that can take in a service and operation and export that. Does not seem worth the upside to me at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I meant define it once in the operation's file and then import it in the service. Doesn't really matter since it's pointless outside of the context of the mux anyway
...escript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServerGenerator.java
Outdated
Show resolved
Hide resolved
...n/src/main/java/software/amazon/smithy/typescript/codegen/integration/ProtocolGenerator.java
Outdated
Show resolved
Hide resolved
This lets service developers choose between a single lambda function per operation, or one lambda function that handles all operations, depending on their preferences.
c5d7032
to
c767ac3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd still prefer to see the other changes, but I don't think they're important enough to hold this back
This lets service developers choose between a single lambda function per operation, or one lambda function that handles all operations, depending on their preferences.
This were missed when 0.2.0 was published Commit: aws/aws-sdk-js-v3@137505b
This were missed when 0.2.0 was published Commit: aws/aws-sdk-js-v3@f55b65e
Description of changes:
This lets service developers choose between a single lambda function per
operation, or one lambda function that handles all operations, depending on
their preferences.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.