Skip to content
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

Use our new JSON coding stack #1307

Merged
merged 1 commit into from
Nov 28, 2023

Conversation

tdeebswihart
Copy link
Contributor

What was changed

I updated go-api to use the less-shoddy JSON coder I added to temporalproto.

Why?

Better performance while still supporting old-style JSON

@tdeebswihart tdeebswihart requested a review from a team as a code owner November 28, 2023 18:59
@tdeebswihart tdeebswihart requested a review from cretz November 28, 2023 18:59
Comment on lines +1466 to 1481
defer func() {
closeErr := reader.Close()
if closeErr != nil && err == nil {
err = closeErr
} else if closeErr != nil {
ilog.NewDefaultLogger().Warn("failed to close json file", "path", jsonfileName, "error", closeErr)
}
}()

hist := &historypb.History{}
dec := temporalproto.NewJSONDecoder(reader, true)
if err := dec.Decode(hist); err != nil {
opts := temporalproto.CustomJSONUnmarshalOptions{
DiscardUnknown: true,
}

bs, err := io.ReadAll(reader)
if err != nil {
return nil, err
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously we would leak the file if decoding failed

@tdeebswihart
Copy link
Contributor Author

NOTE: I will fix the feature tests once this repo merges

@tdeebswihart tdeebswihart merged commit 8f2a3c8 into master Nov 28, 2023
12 of 13 checks passed
@tdeebswihart tdeebswihart deleted the compatible-json-harder-better-faster-stronger branch November 28, 2023 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants