Skip to content

Commit

Permalink
Add temporary module rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry Barber committed Aug 31, 2022
1 parent be6214e commit c7006d4
Showing 1 changed file with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import software.amazon.smithy.model.knowledge.TopDownIndex
import software.amazon.smithy.model.shapes.OperationShape
import software.amazon.smithy.rust.codegen.rustlang.RustModule
import software.amazon.smithy.rust.codegen.rustlang.RustWriter
import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocol
import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocolTestGenerator
import software.amazon.smithy.rust.codegen.smithy.CoreCodegenContext
import software.amazon.smithy.rust.codegen.smithy.RustCrate
Expand Down Expand Up @@ -52,7 +53,12 @@ open class ServerServiceGenerator(
}
}
}
rustCrate.withModule(RustModule.public("operation_handler", "Operation handlers definition and implementation.")) { writer ->
rustCrate.withModule(
RustModule.public(
"operation_handler",
"Operation handlers definition and implementation.",
),
) { writer ->
renderOperationHandler(writer, operations)
}
rustCrate.withModule(
Expand All @@ -66,11 +72,33 @@ open class ServerServiceGenerator(
) { writer ->
renderOperationRegistry(writer, operations)
}

// TODO: Remove, this is temporary.
rustCrate.withModule(
RustModule.public("operations", "TODO"),
) { writer ->
for (operation in operations) {
ServerOperationGenerator(coreCodegenContext, operation).render(writer)
}
}

// TODO: Remove, this is temporary.
rustCrate.withModule(
RustModule.public("services", "TODO"),
) { writer ->
val serverProtocol = ServerProtocol.fromCoreProtocol(coreCodegenContext.runtimeConfig, protocol)
ServerServiceGeneratorV2(
coreCodegenContext.runtimeConfig,
coreCodegenContext.serviceShape,
serverProtocol,
).render(writer)
}

renderExtras(operations)
}

// Render any extra section needed by subclasses of `ServerServiceGenerator`.
open fun renderExtras(operations: List<OperationShape>) { }
open fun renderExtras(operations: List<OperationShape>) {}

// Render combined errors.
open fun renderCombinedErrors(writer: RustWriter, operation: OperationShape) {
Expand Down

0 comments on commit c7006d4

Please sign in to comment.