-
Notifications
You must be signed in to change notification settings - Fork 31
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
feat: Add support for eventstream input & initial request to RPC-based protocols #675
Conversation
…PC-based protocols to runtime & codegen.
…time library be passed in EventStream.Message for an initial request. Necessary changes in codegen that constructs this initial request Message then passes it into EventStreamBodyMiddleware via consturctor is upcoming.
…ddleare constructor codegen. Condition is whether the protocol is an RPC protocl that supports event streaming (awsJson1_0 or awsJson1_1).
…itialRequest to initialRequestMessage & add calling code for getting initial request message from the input struct.
…col is RPC 2) protocol supports event streaming. Exclude streaming union member from this. This encodable conformance is used to serialize the input struct to initial request message.
private fun addEventStreamMiddleware(writer: SwiftWriter, operationStackName: String, inputSymbol: Symbol, outputSymbol: Symbol, payloadSymbol: Symbol, keyPath: String, defaultBody: String) { | ||
private fun addEventStreamMiddleware(writer: SwiftWriter, operationStackName: String, inputSymbol: Symbol, outputSymbol: Symbol, payloadSymbol: Symbol, keyPath: String, defaultBody: String, sendInitialRequest: Boolean) { | ||
if (sendInitialRequest) { | ||
writer.write("let initialRequestMessage = try input.makeInitialRequestMessage(encoder: encoder)") |
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.
Does makeInitialRequestMessage(encoder: encoder)
get generated somewhere?
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.
Moved the codegen for this method from aws-sdk-swift to smithy-swift as pointed out in offline discussion, given initial request is part of the generic Smithy specification.
// marshall event to message | ||
let message = try event.marshall(encoder: requestEncoder) | ||
|
||
let message = try event.marshall(encoder: requestEncoder) |
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.
nit: 2 spaces between let
& message
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.
Fixed.
Issue #
Companion PR: awslabs/aws-sdk-swift#1377
For RPC-based protocols:
Eventstream input ticket: awslabs/aws-sdk-swift#1175
Initial request ticket: awslabs/aws-sdk-swift#1172
Description of changes
func makeInitialRequestMessage
in extension of input structs when: 1) protocol is RPC, 2) protocol supports event streaming, 3) upstream input shape has streaming union member.EventStreamBodyMiddleware
codegen for RPC protocols that support event streaming.EventStreamBodyMiddleware
take ininitialRequestMessage
in constructor. The middleware passes this value toDefaultMessageEncoderStream
constructor.DefaultMessageEncoderStream
returninitialRequestMessage
as the first item in stream if it is non-nil and was set during construction.Scope
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.