-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
private/model/api: Add EventStream over RPC support #1998
Conversation
445ad54
to
eebb93a
Compare
Change to RESTXML not complete, fails for S3 |
eebb93a
to
35c328d
Compare
fixed RESTXML's handling of unnamed implicit payload marshaling. |
c462eea
to
348b582
Compare
@@ -103,7 +107,15 @@ func (b *xmlBuilder) buildStruct(value reflect.Value, current *XMLNode, tag refl | |||
} | |||
} | |||
|
|||
child := NewXMLElement(xml.Name{Local: tag.Get("locationName")}) |
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.
Move to code gen locationName
for event stream shapes.
private/model/api/eventstream.go
Outdated
@@ -444,6 +466,11 @@ func (r *read{{ $.ShapeName }}) readEventStream() { | |||
return | |||
} | |||
|
|||
if err, ok := event.(awserr.Error); 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.
Cast to error
instead of awserr.Error
private/model/api/eventstream.go
Outdated
@@ -516,22 +622,443 @@ func (s *{{ $.ShapeName }}) UnmarshalEvent( | |||
) error { | |||
{{- range $fieldIdx, $fieldName := $.MemberNames }} |
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.
No need for $fieldIdx
. Just use range which already sorts, which is what fieldIdx
was used for.
private/model/api/eventstream.go
Outdated
if err := payloadUnmarshaler.UnmarshalPayload( | ||
bytes.NewReader(msg.Payload), s, | ||
); err != nil { | ||
return fmt.Errorf("failed to unmarshal payload, %v", err) |
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.
Serialization error should be used here.
private/model/api/eventstream.go
Outdated
} | ||
{{- end }} | ||
{{- end }} | ||
expectEvents = expectEvents[1:] |
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.
Comment on why we are chopping off first element
sess := unit.Session | ||
svc := New(sess, &aws.Config{ | ||
Endpoint: aws.String("https://example.com"), | ||
DisableParamValidation: aws.Bool(true), |
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.
Why is this disabled for benchmarks but not unit tests?
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.
Forgot tests do actually disable the parameter validation in the eventstreamtest.SetupEventStreamSession
helper.
private/model/api/operation.go
Outdated
@@ -253,8 +258,11 @@ func (o *Operation) GoCode() string { | |||
|
|||
if len(o.OutputRef.Shape.EventStreamsMemberName) != 0 { | |||
// TODO need better was of updating protocol unmarshalers | |||
o.API.imports["fmt"] = true |
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.
Can go away with removal of fmt.Errorf
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 to eventstream template generation, needed for a few error messages there.
sess, cleanupFn, err := eventstreamtest.SetupEventStreamSession(t, | ||
eventstreamtest.ServeEventStream{ | ||
T: t, | ||
Events: eventMsgs, | ||
}, | ||
false, | ||
true, |
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.
See if the operation is HTTP/2 and if it is able to be determined.
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.
Doesn't look like it.
private/model/api/eventstream.go
Outdated
{{ end }} | ||
|
||
{{ define "set event message header" }} | ||
{{- if $.memRef.IsEventHeader }} | ||
{{/* Parms: *Shape */}} |
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.
*Params
|
||
{{- $offsetIdx := OptionalAddInt (eq $.Operation.API.Metadata.Protocol "json") 0 1 }} | ||
{{- $exception := index $.Inbound.Exceptions 0 }} | ||
{{- template "set event message" Map "idx" $offsetIdx "parentShape" $exception.Shape "eventName" $exception.Name }} |
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 template will not generate event message as an exception type.
* Use code generation for XML implicit payload location name * swaps awserr.Error for error in event stream reader. * cleanup template iteration. * cleanup typos * Fix test making sure events chan is closed.
e4d4661
to
dd76c95
Compare
Adds support for EventStream over JSON PRC protocol. This adds support for the EventStream's initial-response event, EventStream headers, and EventStream modeled exceptions. Also replaces the hand written tests with generated tests for EventStream usage.
Adds support for EventStream over JSON PRC protocol. This adds support for the EventStream's
initial-response
event, EventStream headers, and EventStream modeled exceptions.Also replaces the hand written tests with generated tests for EventStream usage.