Skip to content

Commit

Permalink
codegen: Ensure event stream events are in sorted order (#3681)
Browse files Browse the repository at this point in the history
Updates the SDK's code generation for event stream member event for
methods to be sorted order. Ensures load order doesn't impact code
generation output.

Fixes #3664
  • Loading branch information
jasdel committed Dec 10, 2020
1 parent 5bf92ba commit ca8954d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions private/model/api/eventstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,10 @@ func (es *EventStreams) GetStream(topShape *Shape, streamShape *Shape) *EventStr
}

if topShape.API.Metadata.Protocol == "json" {
topShape.EventFor = append(topShape.EventFor, stream)
if topShape.EventFor == nil {
topShape.EventFor = map[string]*EventStream{}
}
topShape.EventFor[stream.Name] = stream
}

return stream
Expand Down Expand Up @@ -276,7 +279,10 @@ func setupEventStream(s *Shape) *EventStream {

updateEventPayloadRef(eventRef.Shape)

eventRef.Shape.EventFor = append(eventRef.Shape.EventFor, eventStream)
if eventRef.Shape.EventFor == nil {
eventRef.Shape.EventFor = map[string]*EventStream{}
}
eventRef.Shape.EventFor[eventStream.Name] = eventStream

// Exceptions and events are two different lists to allow the SDK
// to easily generate code with the two handled differently.
Expand Down
2 changes: 1 addition & 1 deletion private/model/api/shape.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ type Shape struct {

OutputEventStreamAPI *EventStreamAPI
EventStream *EventStream
EventFor []*EventStream `json:"-"`
EventFor map[string]*EventStream `json:"-"`

IsInputEventStream bool `json:"-"`
IsOutputEventStream bool `json:"-"`
Expand Down

0 comments on commit ca8954d

Please sign in to comment.