Unverified Commit e751ed69 authored by david-perez's avatar david-perez Committed by GitHub
Browse files

Make `ServerOperationRegistryGenerator` protocol-agnostic (#1525)

`ServerOperationRegistryGenerator` is the only server generator that is
currently not protocol-agnostic, in the sense that it is the only
generator that contains protocol-specific logic, as opposed to
delegating to the `Protocol` interface like other generators do.

With this change, we should be good to implement a
`RustCodegenDecorator` loaded from the classpath that implements support
for any protocol, provided the decorator provides a class implementing
the `Protocol` interface.

This commit also contains some style changes that are making `ktlint`
fail. It seems like our `ktlint` config was recently broken and some
style violations slipped through the cracks in previous commits that
touched these files.
parent 12b4943e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -17,10 +17,10 @@ import software.amazon.smithy.rust.codegen.smithy.BaseSymbolMetadataProvider
import software.amazon.smithy.rust.codegen.smithy.EventStreamSymbolProvider
import software.amazon.smithy.rust.codegen.smithy.ServerCodegenContext
import software.amazon.smithy.rust.codegen.smithy.StreamingShapeMetadataProvider
import software.amazon.smithy.rust.codegen.smithy.StreamingShapeSymbolProvider
import software.amazon.smithy.rust.codegen.smithy.SymbolVisitor
import software.amazon.smithy.rust.codegen.smithy.SymbolVisitorConfig
import software.amazon.smithy.rust.codegen.smithy.customize.CombinedCodegenDecorator
import software.amazon.smithy.rust.codegen.smithy.StreamingShapeSymbolProvider
import java.util.logging.Level
import java.util.logging.Logger

+2 −2
Original line number Diff line number Diff line
@@ -143,8 +143,8 @@ class PythonServerCodegenVisitor(
            rustCrate,
            protocolGenerator,
            protocolGeneratorFactory.support(),
            protocolGeneratorFactory.protocol(codegenContext).httpBindingResolver,
            codegenContext,
            protocolGeneratorFactory.protocol(codegenContext),
            codegenContext
        )
            .render()
    }
+4 −4
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ import software.amazon.smithy.rust.codegen.smithy.CoreCodegenContext
import software.amazon.smithy.rust.codegen.smithy.RustCrate
import software.amazon.smithy.rust.codegen.smithy.generators.protocol.ProtocolGenerator
import software.amazon.smithy.rust.codegen.smithy.generators.protocol.ProtocolSupport
import software.amazon.smithy.rust.codegen.smithy.protocols.HttpBindingResolver
import software.amazon.smithy.rust.codegen.smithy.protocols.Protocol

/**
 * PythonServerServiceGenerator
@@ -25,9 +25,9 @@ class PythonServerServiceGenerator(
    private val rustCrate: RustCrate,
    protocolGenerator: ProtocolGenerator,
    protocolSupport: ProtocolSupport,
    httpBindingResolver: HttpBindingResolver,
    protocol: Protocol,
    private val context: CoreCodegenContext,
) : ServerServiceGenerator(rustCrate, protocolGenerator, protocolSupport, httpBindingResolver, context) {
) : ServerServiceGenerator(rustCrate, protocolGenerator, protocolSupport, protocol, context) {

    override fun renderCombinedErrors(writer: RustWriter, operation: OperationShape) {
        PythonServerCombinedErrorGenerator(context.model, context.symbolProvider, operation).render(writer)
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ class RustCodegenServerPlugin : SmithyBuildPlugin {
            CombinedCodegenDecorator.fromClasspath(context, ServerRequiredCustomizations())

        // ServerCodegenVisitor is the main driver of code generation that traverses the model and generates code
        logger.info("Loaded plugin to generate pure Rust bindings for the server SSDK")
        logger.info("Loaded plugin to generate pure Rust bindings for the server SDK")
        ServerCodegenVisitor(context, codegenDecorator).execute()
    }

+2 −2
Original line number Diff line number Diff line
@@ -223,8 +223,8 @@ open class ServerCodegenVisitor(
            rustCrate,
            protocolGenerator,
            protocolGeneratorFactory.support(),
            protocolGeneratorFactory.protocol(codegenContext).httpBindingResolver,
            codegenContext,
            protocolGeneratorFactory.protocol(codegenContext),
            codegenContext
        )
            .render()
    }
Loading