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

feat: Add support for eventstream input & initial request to RPC-based protocols #675

Merged
merged 12 commits into from
Mar 15, 2024

Conversation

sichanyoo
Copy link
Contributor

@sichanyoo sichanyoo commented Mar 4, 2024

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

  • Add a new SwiftIntegration that generates 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.
  • Hook up EventStreamBodyMiddleware codegen for RPC protocols that support event streaming.
  • Make EventStreamBodyMiddleware take in initialRequestMessage in constructor. The middleware passes this value to DefaultMessageEncoderStream constructor.
  • Make DefaultMessageEncoderStream return initialRequestMessage as the first item in stream if it is non-nil and was set during construction.
  • Hook up Encodable conformance codegen for input shapes in RPC protocols if: 1) protocol supports event streaming & 2) input shape has streaming union member. Exclude streaming member in encoding, because the encoding functionality provided by this conformance is used to encode input struct into an initial request message without streaming member.

Scope

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@sichanyoo sichanyoo requested a review from jbelkins March 4, 2024 22:07
Sichan Yoo added 5 commits March 6, 2024 12:42
…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)")
Copy link
Contributor

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?

Copy link
Contributor Author

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)
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@sichanyoo sichanyoo requested a review from jbelkins March 13, 2024 21:48
@sichanyoo sichanyoo merged commit dac24a6 into main Mar 15, 2024
12 checks passed
@sichanyoo sichanyoo deleted the feat/eventstream-input-awsJson branch March 15, 2024 18:04
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