Conversation
ef07899 to
799e7a1
Compare
799e7a1 to
cd2a45f
Compare
|
relates #458 |
aws-protocols/awsjson10/awsjson10.go
Outdated
| return nil | ||
| } | ||
|
|
||
| // TODO get the intermediate reader out of this thing and just operate on the |
There was a problem hiding this comment.
Don't we still need access to the headers?
There was a problem hiding this comment.
I don't even understand this reading it back, the implementation looks fine to me, I just removed it.
| goTemplate("d.ReadDocument(s.ListMember(), &vv)"); | ||
|
|
||
| case BIG_INTEGER, BIG_DECIMAL -> | ||
| throw new CodegenException("big integer / big decimal unsupported"); |
There was a problem hiding this comment.
has this always been unsupported?
| )); | ||
| } | ||
|
|
||
| // TODO sparse |
There was a problem hiding this comment.
🤔 did the protocol tests literally not have sparse collections? i'll have to check
There was a problem hiding this comment.
evidently i put this here and then completely forgot about sparse lists maps, so that needs to be addressed here, the protocol tests just don't have them to catch this i guess
| var operations = TopDownIndex.of(model).getContainedOperations(service()); | ||
|
|
||
| var shapes = new HashSet<Shape>(); | ||
| shapes.addAll(operations.stream() |
There was a problem hiding this comment.
hate to see this being walked thrice, but I don't know if there's a better way
| .collect(toSet())); | ||
|
|
||
| return shapes.stream() | ||
| .sorted() |
There was a problem hiding this comment.
how are they sorted naturally, by type+name?
There was a problem hiding this comment.
I'm not sure but when we do the shape walking they go into a set to not get duplicated, which ruins whatever order was there originally.
| writeInternalDocumentPackage("document.go", writer -> { | ||
| Symbol marshalerSymbol = getInternalDocumentSymbol("documentMarshaler", | ||
| true); | ||
| Symbol unmarshalerSymbol = getInternalDocumentSymbol("documentUnmarshaler", true); |
There was a problem hiding this comment.
unrelated, but really hate these get(thing, true) signatures
| case BIG_DECIMAL -> writer.write("s.WriteBigDecimal($L, v.Value)", schemaName); | ||
| case STRUCTURE -> writer.write("s.WriteStruct($L, &v.Value)", schemaName); // struct variants are value types | ||
| case LIST, SET, MAP -> writer.write("serialize$L(s, $L, v.Value)", target.getId().getName(), schemaName); | ||
| default -> writer.write("// TODO: serialize union member type $L", target.getType()); |
There was a problem hiding this comment.
didn't we already had the code for union types?
There was a problem hiding this comment.
yes, this was an old thing for when i was adding in stuff here. replaced it with a throw on the remaining stuff
|
|
||
| writer.write(""); | ||
| writer.writeDocs("Initialize schema members after all schemas are declared to avoid initialization cycles"); | ||
| writer.openBlock("func init() {", "}", () -> { |
There was a problem hiding this comment.
This is the first time we have init on generated clients, right? Don't think there's any negative about it, just want to clarify it
There was a problem hiding this comment.
I am sort of concerned about this actually, i would like to benchmark how long we're actually in this, because it could affect binary startups (or like lambda coldstarts etc).
There is a route where we lazy-load schemas but I'm not sure all the sync.Once we'd have to add for that is worth the tradeoff.
There was a problem hiding this comment.
I'd be curious to followup on this. Even if we do sync.Once we would just shuffle when we execute this, but maybe you have something else in mind
Co-authored-by: Luis Madrigal <599908+Madrigal@users.noreply.github.com>
Co-authored-by: Luis Madrigal <599908+Madrigal@users.noreply.github.com>
* implement awsjson10 minus event streams * forgot about sparse * Update serde.go Co-authored-by: Luis Madrigal <599908+Madrigal@users.noreply.github.com> * Update serde.go Co-authored-by: Luis Madrigal <599908+Madrigal@users.noreply.github.com> * idk what this was about * drop the old todo stuff --------- Co-authored-by: Luis Madrigal <599908+Madrigal@users.noreply.github.com>
* implement awsjson10 minus event streams * forgot about sparse * Update serde.go Co-authored-by: Luis Madrigal <599908+Madrigal@users.noreply.github.com> * Update serde.go Co-authored-by: Luis Madrigal <599908+Madrigal@users.noreply.github.com> * idk what this was about * drop the old todo stuff --------- Co-authored-by: Luis Madrigal <599908+Madrigal@users.noreply.github.com>
tl;dr
documents
There is some trickery with documents here. Basically we would like to support new documents that can deserialize to and from shapes, but we are locked in with the existing public APIs (per-service document.Interface). This supports the "old" way, where you pass any value into document.NewLazyDocument in the input, and it will reflection over that value and turn it into json.
The shape ser/deser interfaces accept a new sealed document.Value, which supports this old mechanism through the variant document.Opaque, but it will also support the new stuff which I've hinted at by filling out the other variants (e.g. document.Structure). Work to support that would be in a future PR.
performance notes
The JSON deserializer should be way more performant than what we had before, since we were deserializing the entire thing into a map[string]any and then re-copying that into the target output. Benchmarks pending.
The serializer is probably a slight regression because of how we have to wrap to the old encoder but there's a way out of this. We will basically just need to drop the old encoder and roll a new one that's better tailored to how the ShapeSerializer APIs work.
testing
I have regenerated the jsonrpc10 protocol tests downstream with this and they all pass. It wouldn't be possible to get that working in CI atm with how we have this new module though.