Skip to content

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

Merged
merged 1 commit into from
Apr 13, 2021

Conversation

adamthom-amzn
Copy link
Contributor

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.

Comment on lines +119 to +120
writeSerdeContextBase(writer);
writeHandleFunction(writer);
Copy link
Contributor

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?

Copy link
Contributor Author

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,
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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);
Copy link
Contributor

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?

Copy link
Contributor Author

@adamthom-amzn adamthom-amzn Apr 7, 2021

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.

Copy link
Contributor

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

This lets service developers choose between a single lambda function per
operation, or one lambda function that handles all operations, depending on
their preferences.
@adamthom-amzn adamthom-amzn force-pushed the operation-per-lambda branch from c5d7032 to c767ac3 Compare April 7, 2021 16:25
@JordonPhillips JordonPhillips self-requested a review April 8, 2021 14:37
Copy link
Contributor

@JordonPhillips JordonPhillips left a 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

@adamthom-amzn adamthom-amzn merged commit b49b293 into smithy-lang:ssdk Apr 13, 2021
@adamthom-amzn adamthom-amzn deleted the operation-per-lambda branch April 13, 2021 18:28
srchase pushed a commit to srchase/smithy-typescript that referenced this pull request Mar 17, 2023
This lets service developers choose between a single lambda function per
operation, or one lambda function that handles all operations, depending on
their preferences.
srchase pushed a commit that referenced this pull request Mar 23, 2023
This were missed when 0.2.0 was published
Commit: aws/aws-sdk-js-v3@137505b
srchase pushed a commit that referenced this pull request Jun 16, 2023
This were missed when 0.2.0 was published
Commit: aws/aws-sdk-js-v3@f55b65e
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.

2 participants