-
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: Support RPCv2 CBOR wire protocol #887
base: main
Are you sure you want to change the base?
Conversation
self.children = Self.children(from: cborValue, parent: self) | ||
} | ||
|
||
public static func from(data: Data) throws -> Reader { |
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.
this function calls CBORDecoder which is defined in CRT for actually decoding individual types
return Reader(nodeInfo: "", cborValue: rootValue, parent: nil) | ||
} | ||
|
||
private static func children(from cborValue: CBORType?, parent: Reader) -> [Reader] { |
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.
This function helps form a graph for nested and complex types
} | ||
} | ||
|
||
public func writeMap<T>( |
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.
map and array encoding is particularly complex due to the possibility of nested types. A map can be within an array and vice versa
try valueWritingClosure(val, writer) | ||
|
||
// If the writer itself doesn't have a cborValue, build it from its children | ||
if writer.cborValue == nil, !writer.children.isEmpty { |
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.
its possible cborValue wasnt yet assigned, in that case let's move on and parse the children first then come back
import Foundation | ||
@_spi(SmithyReadWrite) import SmithyCBOR | ||
|
||
public struct CBORComparator { |
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.
this is solely used for testing. we need to compare the semantic values rather than the exact binary values. CRT should have sufficiently tested their de-serializer against SEP prescribed tests to ensure that using the Decoder in protocol test comparison is ok
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.
Is the testing in CRT side done already? If not, what's the known timeline?
operationMiddleware.appendMiddleware(operation, AuthSchemeMiddleware(ctx.model, ctx.symbolProvider)) | ||
for (integration in ctx.integrations) { | ||
integration.customizeMiddleware(ctx, operation, operationMiddleware) | ||
} | ||
// must be last to support adding business metrics | ||
addUserAgentMiddleware(ctx, operation) |
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.
bug fix: addUserAgentMiddleware handles feature id (business metric) tracking. This was supposed to be last in the stack but it never was prior to this change due to protocol-specific middleware
val bodyContent = test.body.get().replace("\\\"", "\\\\\"") | ||
val data: String = if (isCbor) { | ||
// Attempt to decode Base64 data once for CBOR | ||
try { |
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.
CBOR data is binary data but for protocol tests it need to be passed as a base64 encoded string
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.
Mostly Qs
import Foundation | ||
@_spi(SmithyReadWrite) import SmithyCBOR | ||
|
||
public struct CBORComparator { |
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.
Is the testing in CRT side done already? If not, what's the known timeline?
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.
LGTM; should be good to merge after Josh's review as well
Issue #
Description of changes
Scope
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.