-
Notifications
You must be signed in to change notification settings - Fork 5
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
CLOUDP-211581: Improve memory consumption in Atlas SDK #331
Conversation
running tests at mongodb/mongodb-atlas-cli#2979 |
@@ -13,6 +13,7 @@ jobs: | |||
- uses: actions/setup-go@v5 | |||
with: | |||
go-version-file: 'go.mod' | |||
- run: go install golang.org/x/tools/cmd/[email protected] |
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.
golangcilint wraps goimports for checks. Since we need it her for code fixing I think it is nicer to consider adding it to
- make clean_and_generate
- make tools
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.
Basically [super nit] I think we still need it locally (as part of the git hooks - tools) and for generation.
Once we add it there would not be need for any autoupdate workflow changes.
Those are quite hard to test locally and might fail after merge.
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.
it is already in make tools
@@ -4,7 +4,6 @@ STAGED_GO_FILES=$(git diff --cached --name-only | grep ".go$") | |||
|
|||
for FILE in ${STAGED_GO_FILES} | |||
do | |||
gofmt -w -s "${FILE}" |
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.
❤️
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.
There are still some differences between gofmt and goimports ( goimports does less).
My guess is that we want to align SDK hooks in other golang repose like CLI?
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.
goimports is needed because some imports have to be removed after generation to avoid compilation errors (e.g. io
)
Verified locally:
|
} | ||
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, localVarHTTPMethod, localVarPath, v) | ||
newErr.model = v | ||
newErr := a.client.makeApiError(localVarHTTPResponse, localVarHTTPMethod, localVarPath) |
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.
❤️
if err != nil { | ||
defer localVarHTTPResponse.Body.Close() |
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.
[Question] Why closing only on error? Should each method be responsible for closing body independently from if decode succeeded or not?
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.
close only happens in this case because it already happens in decode and makeApiError
When testing error case I noticed that resp.Body is not returned as pointer.
On master that renders:
Is there way to keep previous behaviour? |
@fmenezes Awesome work on making this major improvement! I have done some testing and left couple questions, but everything looks LGTM. |
TL;DR we have to change our examples Basically in our this is misleading because we can't tell what is the state of |
So basically we need documentation to not rely on the resp.Body for printing body from request and follow your advice.
No strong opinion on those. |
Will LGTM once we address the conflict (regenerate code). I'm ok to take follow up documentation actions if you want. |
Description
Improve memory consumption in Atlas SDK (by not reading response.Body when we don't need)
Link to any related issue(s): CLOUDP-211581
Type of change:
Required Checklist:
make fmt
and formatted my codeFurther comments