-
Notifications
You must be signed in to change notification settings - Fork 10
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
cleanup: manifest improvements #42
Conversation
@@ -217,6 +228,52 @@ type Manifest struct { | |||
Timeout uint64 `json:"timeout_ms,omitempty"` | |||
} | |||
|
|||
type concreteManifest struct { |
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.
I haven't tested this, but we could potentially embed the Manifest
struct into this one (with no field name) and add the Wasm []concreteWasm
field to it.
This way they stay in sync and we avoid duplication. Totally may not work though.
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.
I did try that but got a weird stack overflow error
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.
haha hmm ok, we can always change it later if we want since it's all internal. not worth spending much time now just to avoid a tiny bit of tech debt 😅
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! No issue merging now but maybe @mhmd-azeez can take a peek at some point too that would be great.
} | ||
|
||
func (m *Manifest) UnmarshalJSON(data []byte) error { | ||
tmp := concreteManifest{} |
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.
oh I think this is where the stack overflow happens since UnmarshalJSON gets called recursively when it encounters the embedded type
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.
(but I don't think there's a way around it?)
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.
Yeah, other than splitting all the Manifest
fields out into another struct (which ruins the usability from Go) there doesn't seem to be a good way to re-use them. I will sleep on it though.
Thanks! I will leave it open and merge it tomorrow so he gets a chance to review. |
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.
Looks good, I added a basic unit test to make sure everything works and to act as an example for people in the future.
extism.Manifest
using theconcreteManifest
type (et me know if there is a nicer way to do this in Go)