-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 BatchPoints for writing from client library #1868
Conversation
Makes sense so far, let me know when it needs final review. |
@corylanou; Fully aggre with the new approach. I do think that, as the server is already referencing client structs, the use of Altough a working in progress, I have noted that the current code is still:
|
Also noted that:
|
@corylanou Be aware that the omitempty in |
@vladlopes I went back and forth on the As for the "hint" it might provide, I would prefer to have documentation (not written yet) on how to use the client library in which we describe what is optional/not optional. I will also put a comment at the top of the Let me know if that is in line with your concerns and if that satisfies them. I'm very open to suggestions on this. Thanks! |
@corylanou I totally agree with you. On second thought, as the compiler doesn't enforce this, the documentation solution is really the way to go. As you provided custom marshalling for Point Timestamp field, which is the heavy part of the message, and it won't be marshalled if it is Zero, I think it would be a much less concern to always send the BatchPoints Timestamp field. Have you thought about the server response when everything is good (status code == http.StatusOK) ? Sorry if I am bodering you with this little things, thanks for the work and please let me know if I can do anything else to help! |
Ready for review. |
}{ | ||
{ | ||
name: "empty batchpoint", | ||
writeExpected: &client.Results{Err: fmt.Errorf("database is required")}, |
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.
All these tests need to move away from the types, and just do string compares -- using types in the integration tests is too brittle, and too difficult to read.
Can you check out the table-driven tests in the other parts of this file to see what I mean?
dec.UseNumber() | ||
err = dec.Decode(&results) | ||
body, _ := ioutil.ReadAll(resp.Body) | ||
if len(body) > 0 { |
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.
And if len
is 0, what should happen? Isn't that unexpected?
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.
For this endpoint, if it's successful (meaning we wrote the data), we just respond with a status code 200, there is no body to decode.
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.
Should also add that if there IS an error, that is when we write out a body, and then you need to decode 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.
Is the response data always small? If there is any chance it could be large, don't use ReadAll, instead stream decode like was done before.
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.
@evanphx yeah, that's a good point. I looked at it twice when I did my code reviews and felt it kind of smelled. Really I should just check if the error is EOF
, as that is the normal case. If it is, move on. If not, throw an error.
Change generally makes sense, but the integration tests need to be string-compare based. They are too difficult to follow in their current form, and too difficult to maintain. |
2d6eb6f
to
74c84e7
Compare
74c84e7
to
c757137
Compare
Use BatchPoints for writing from client library
Several issues had been logged recently, and most of it was due to the client library taking on too much responsibility. This PR will get rid of a custom type used for writing, and use the
BatchPoints
that are used throughout our system.This will fix #1849 in the process.
omitempty
to bothPoint
andBatchPoint
to cut down on marshaling and http overheadWrite
signature now takesBatchPoint
instead of custom typeBatchPoint
back toclient
package