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

CLOUDP-82836: Parse service version #248

Merged
merged 5 commits into from
Sep 2, 2021
Merged

CLOUDP-82836: Parse service version #248

merged 5 commits into from
Sep 2, 2021

Conversation

fmenezes
Copy link
Contributor

@fmenezes fmenezes commented Sep 1, 2021

Description

Parse service version header X-MongoDB-Service-Version

Link to any related issue(s): CLOUDP-82836

Type of change:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Required Checklist:

  • I have signed the MongoDB CLA
  • I have added tests that prove my fix is effective or that my feature works
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code

Further comments

@fmenezes fmenezes requested a review from a team as a code owner September 1, 2021 16:32
@fmenezes fmenezes requested review from threebee and removed request for a team September 1, 2021 16:32
}

// GetServiceVersion parses version information returned in the response.
func (resp *Response) GetServiceVersion() *ServiceVersion {
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit] getters are non idiomatic on go

Suggested change
func (resp *Response) GetServiceVersion() *ServiceVersion {
func (resp *Response) ServiceVersion() *ServiceVersion {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know it does not sound right but I did not think Get as a getter here 😄

result.GitHash = keyvalue[1]
case "versionString":
result.Version = keyvalue[1]
}
Copy link
Collaborator

@colm-quinn colm-quinn Sep 2, 2021

Choose a reason for hiding this comment

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

[q] Should we log/fail on any other case? I generally don't like switches without a default, as changes can go undetected. If we had a default error, along with a unit test, a structure change to the client would immediately fail here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your question.

For context, we are using the header X-MongoDB-Service-Version which should contain the format gitHash=[some git hash]; versionString=[some version e.g. 5.0.0.100.20210710T1827Z]

In case I receive keys I do not support I am ignoring them, for instance gitHash=[some git hash]; versionString=[some version e.g. 5.0.0.100.20210710T1827Z]; keyNotKnown=[value]

I think ignoring keys is an acceptable thing to do, that is exactly what the encoding/json package does if you're missing some fields in your struct.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fair enough, if we added logging, the client would get a bunch of warnings constantly as the shape changes as well, which is not a great experience.

Copy link
Collaborator

@gssbzn gssbzn left a comment

Choose a reason for hiding this comment

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

LGTM thanks for those changes

@fmenezes fmenezes merged commit a40fdd6 into master Sep 2, 2021
@fmenezes fmenezes deleted the CLOUDP-82836 branch September 2, 2021 12:16
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.

3 participants