Skip to content
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

Partial HTTP protocol implementation #1

Merged
merged 6 commits into from
Oct 29, 2020

Conversation

rcoh
Copy link
Collaborator

@rcoh rcoh commented Oct 28, 2020

Description of changes:
This diff adds extremely limited support for AwsJson1.0 and RestJson1. Along the way it fixes lots of bugs & does assorted refactorings to clean up abstractions. It's not really a 10k line diff: 9,150 of the lines are from adding Dynamo and EBS as integration tests.

Currently, the protocol implementations are inside of Smithy—we may decide that that needs to be refactored later, but TBD.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@rcoh rcoh requested a review from kggilmer October 28, 2020 15:42
Copy link

@kggilmer kggilmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Minor items noted.

}
} else {
this.block(outerField)
}
}

fun ListForEach(target: Shape, outerField: String, block: CodeWriter.(field: String, target: ShapeId) -> Unit) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: camelcase

return if (nullableIndex.isNullable(shape) && !shape.hasTrait(HttpLabelTrait::class.java)) {
private fun handleOptionality(symbol: Symbol, member: MemberShape, container: Shape): Symbol {
val httpLabeledInput = container.hasTrait(SyntheticInput::class.java) && member.hasTrait(HttpLabelTrait::class.java)
return if (nullableIndex.isNullable(member) && !httpLabeledInput) {
val builder = Symbol.builder()
val rustType = RustType.Option(symbol.rustType())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One syntatic niceity is with(builder) {} allows you to remove redundant type names when accessing properties/functions on the same instance line over line. (FYI)

@@ -91,6 +92,7 @@ class SymbolVisitor(
) : SymbolProvider,
ShapeVisitor<Symbol> {
private val nullableIndex = NullableIndex(model)
private val bottomUpIndex = BottomUpIndex(model)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems unneeded


fun Symbol.Builder.rustType(rustType: RustType): Symbol.Builder {
return this.putProperty(RUST_TYPE_KEY, rustType)
}

fun Symbol.rename(newName: String): Symbol {
assert(this.rustType() is RustType.Opaque)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider check for this

import software.amazon.smithy.rust.codegen.smithy.RuntimeConfig
import software.amazon.smithy.rust.codegen.smithy.RuntimeType

data class ProtocolConfig(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

val memberType = model.expectShape(memberShape.target)
val memberSymbol = symbolProvider.toSymbol(memberShape)
val memberName = symbolProvider.toMemberName(memberShape)
OptionForEach(memberSymbol, "&self.$memberName") { field ->

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: case of these functions seems off

@@ -22,7 +24,7 @@ fun String.runCommand(workdir: Path? = null): String? {
proc.waitFor(60, TimeUnit.MINUTES)
if (proc.exitValue() != 0) {
val output = proc.errorStream.bufferedReader().readText()
throw AssertionError("Command Failed\n$output")
throw CommandFailed("Command Failed\n$output")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could also just do error("Command Failed...") here.

@rcoh rcoh merged commit ddac680 into main Oct 29, 2020
@rcoh rcoh deleted the russell/initial-http-protocol-impl branch October 29, 2020 19:49
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