-
Notifications
You must be signed in to change notification settings - Fork 190
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
Break up RustCodegenDecorator
#2099
Conversation
This change creates `ClientCodegenDecorator` and `ServerCodegenDecorator` in `codegen-client` and `codegen-server` respectively to replace `RustCodegenDecorator`. Client/server equivalents are created to replace `CombinedCodegenDecorator` as well. This eliminates the need for the `supportsCodegenContext` method since the decorator interface is no longer generic, so the `ServiceLoader` is now powerful enough to differentiate. The largest benefit, however, is that now clients and servers can have separate customizations.
79db806
to
d74997d
Compare
A new generated diff is ready to view.
A new doc preview is ready to view. |
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.
Looks great!
companion object { | ||
fun fromClasspath( | ||
context: PluginContext, | ||
vararg extras: ClientCodegenDecorator, | ||
logger: Logger = Logger.getLogger("RustClientCodegenSPILoader"), | ||
): CombinedClientCodegenDecorator { | ||
val decorators = ServiceLoader.load( | ||
ClientCodegenDecorator::class.java, | ||
context.pluginClassLoader.orElse(ClientCodegenDecorator::class.java.classLoader), | ||
) | ||
|
||
val filteredDecorators = decorators.asSequence() | ||
.onEach { logger.info("Discovered Codegen Decorator: ${it.javaClass.name}") } | ||
.filter { it.classpathDiscoverable() } | ||
.onEach { logger.info("Adding Codegen Decorator: ${it.javaClass.name}") } | ||
.toList() | ||
return CombinedClientCodegenDecorator(filteredDecorators + extras) | ||
} | ||
} |
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.
Wonderful, this is much more readable than what we had before with generics!
...kotlin/software/amazon/smithy/rust/codegen/server/smithy/customize/ServerCodegenDecorator.kt
Outdated
Show resolved
Hide resolved
* AWS services. A different downstream customer may wish to add a different set of derive | ||
* attributes to the generated classes. | ||
*/ | ||
interface ServerCodegenDecorator { |
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 think it's great that now the interface for the Server Codegen is smaller and completely customizable without interfering with the Client..
...kotlin/software/amazon/smithy/rust/codegen/server/smithy/customize/ServerCodegenDecorator.kt
Outdated
Show resolved
Hide resolved
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.
LGTM—the only issue is it prevents the integration test helper from being usable for the serve . It would be nice if we could unit those but probably not mission critical
references = ["smithy-rs#2099"] | ||
meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "client"} | ||
author = "jdisanti" |
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.
this will break a ton of people...I wonder if we should have a backwards compatibility shim
...kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/ClientCodegenDecorator.kt
Outdated
Show resolved
Hide resolved
...kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/ClientCodegenDecorator.kt
Show resolved
Hide resolved
...rc/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/CodegenIntegrationTest.kt
Show resolved
Hide resolved
...rc/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/CodegenIntegrationTest.kt
Show resolved
Hide resolved
A new generated diff is ready to view.
A new doc preview is ready to view. |
Motivation and Context
This change creates
ClientCodegenDecorator
andServerCodegenDecorator
incodegen-client
andcodegen-server
respectively to replaceRustCodegenDecorator
. Client/server equivalents are created to replaceCombinedCodegenDecorator
as well.This eliminates the need for the
supportsCodegenContext
method since the decorator interface is no longer generic, so theServiceLoader
is now powerful enough to differentiate.The largest benefit, however, is that now clients and servers can have separate customizations.
Checklist
CHANGELOG.next.toml
if I made changes to the smithy-rs codegen or runtime cratesBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.