Create a server-specific bottom-most symbol provider #1724
Labels
high-priority
High priority issue
refactoring
Changes that do not affect our users, mostly focused on maintainability
server
Rust server SDK
Currently, both client and server projects have been using the same bottom-most (i.e. the core symbol provider that sits at the bottom of the hierarchy of "wrappers") symbol provider, defined in
SymbolVisitor.kt
:https://github.com/awslabs/smithy-rs/blob/e3239e1a17ea0165849ce5379ae0fe40bdb16577/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/RustCodegenPlugin.kt#L63
The mapping between a Smithy shape and a
Symbol
, the role of the symbol provider, has become ever more different between the client and the server projects. The first deviation was introduced when the server first decided to generaterequired
member shapes as non-Option
al, in #1148. This was tackled introducing ahandleRequired
configuration flag in theSymbolVisitorConfig
:https://github.com/awslabs/smithy-rs/blob/e3239e1a17ea0165849ce5379ae0fe40bdb16577/codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/SymbolVisitor.kt#L67
We now have more need for deviations:
operation
shape. The currentSymbolVisitor
generates other Rust structs for use by the client.SymbolVisitor
cannot be invoked on aservice
shape.Option
or not for both projects.Introducing more configuration flags and increasing the branching in the current
SymbolVisitor
to accomodate all these different requirements will make the code increasingly complex, hampering maintainability.In this task we will split the current
SymbolVisitor
into at least two classes across three files:CoreSymbolProviderUtilities
will live in the recently introducedcodegen-core
Gradle module (Establish thecodegen-core
module #1697) and will provide utilities to constructSymbol
s, espeically those for core simple Smithy shapes whose associated Rust types are common among all projects.ClientSymbolProvider
will live in the client Gradle module and be specifically tailored and unit-tested for the client project's needs.ServerSymbolProvider
will live in thecodegen-server
Gradle module and be specifically tailored and unit-tested for the server project's needs.Note we get rid of the "visitor" part of the name.
Note the Python server project is using its own bottom-most symbol provider:
https://github.com/awslabs/smithy-rs/blob/e3239e1a17ea0165849ce5379ae0fe40bdb16577/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonCodegenServerPlugin.kt#L72
The text was updated successfully, but these errors were encountered: