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

Add HTTP JSONPB request method to client and update callers #163

Merged
merged 6 commits into from
Jul 17, 2019

Conversation

robskillington
Copy link
Collaborator

This makes sure that every call site is using the correct JSON marshal/unmarshal and adds helpers so future methods don't have to construct the marshaller themselves and just directly call the DoHTTPJSONPBRequest helper.

Copy link
Collaborator

@schallert schallert left a comment

Choose a reason for hiding this comment

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

Very nice. LGTM once tests pass, please consider the nit too.

func (c *client) DoHTTPJSONPBRequest(
action, url string,
request proto.Message,
response proto.Message,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just curious, is the reason to pass the response so that a user can pass a typed one rather than have to type assert on the way back (if signature returned (proto.Message, error)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well the main thing is I need to unmarshal into a specific proto message, unless the caller wants to do the the whole jsonpb Unmarshal thing (which we're trying to avoid them doing). That's why they need to provide up front.

return nil, errors.New("nil placement fetch")
}
p.logger.Debug("placement retreived")
return m3placement.NewPlacementFromProto(data.Placement)
p.logger.Info("placement retreived")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: I changed this from Info to Debug recently because this happens on every run of the control loop. Since we refresh every N seconds even with no events this means the operator logs could just be "placement retrieved" constantly.

Might be worth keeping this as debug.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah yeah, this was a bad merge, will revert.

@codecov
Copy link

codecov bot commented Jul 17, 2019

Codecov Report

Merging #163 into master will increase coverage by 0.36%.
The diff coverage is 80%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #163      +/-   ##
==========================================
+ Coverage   74.76%   75.13%   +0.36%     
==========================================
  Files          27       28       +1     
  Lines        1922     1918       -4     
==========================================
+ Hits         1437     1441       +4     
+ Misses        368      365       -3     
+ Partials      117      112       -5

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 40eadeb...18a640c. Read the comment docs.

@robskillington robskillington merged commit d574294 into master Jul 17, 2019
@robskillington robskillington deleted the r/add-httpjsonpbrequest branch July 17, 2019 21:43
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