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

Implement a UDP client #4648

Merged
merged 1 commit into from
Nov 4, 2015
Merged

Implement a UDP client #4648

merged 1 commit into from
Nov 4, 2015

Conversation

sparrc
Copy link
Contributor

@sparrc sparrc commented Nov 3, 2015

closes #4647

@otoolep
Copy link
Contributor

otoolep commented Nov 3, 2015

Looks good to me.

Should NewClient now be renamed to NewHTTPClient? If this v2 client code is not yet frozen, I think you should consider that. It feels more Go-like.

@sparrc sparrc force-pushed the udp-client branch 2 times, most recently from fcb4066 to 9430117 Compare November 3, 2015 21:52
@sparrc
Copy link
Contributor Author

sparrc commented Nov 3, 2015

@corylanou @jwilder @otoolep My 1st precision implementation wasn't working right, so I've added a function to models.Point, RoundedString(d time.Duration) string. Main use case here is so that we can write UDP points with precision.

@sparrc
Copy link
Contributor Author

sparrc commented Nov 3, 2015

@otoolep That's a good question, maybe I could have NewClient log a warning DEPRECATED message, and call NewHTTPClient. What do you think?

@otoolep
Copy link
Contributor

otoolep commented Nov 3, 2015

@sparrc -- have we made any promises re V2 yet?

@sparrc
Copy link
Contributor Author

sparrc commented Nov 3, 2015

@otoolep I'm not sure what you mean by promises, but we do have this note telling people to use it already: https://github.com/influxdb/influxdb/tree/master/client#description

@otoolep
Copy link
Contributor

otoolep commented Nov 3, 2015

OK, that is what I mean.

OK, I would scrap the idea of renaming and leave NewClient as is, and add NewUDPClient like you are doing. A HTTP client is what most people should be using anyway.

@sparrc sparrc force-pushed the udp-client branch 3 times, most recently from b744f8f to 0552ba6 Compare November 4, 2015 00:24
@sparrc
Copy link
Contributor Author

sparrc commented Nov 4, 2015

@otoolep I made some significant changes based on what we were talking about in Slack. Now the UDP client will write a UDP packet before we hit the maximum size (64kb) and then reset the buffer

}

// Write and reset the buffer if we reach the max size
if b.Len() > UDPMaxSendSize {
Copy link
Contributor

Choose a reason for hiding this comment

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

While this will probably work in practise, this is not watertight. Instead the logic should be checking that if adding the new point to the existing buffer will send the buffer over the limit, then call con.Write() before adding the new point.

Make sense?

Copy link
Contributor

Choose a reason for hiding this comment

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

Unless you can be sure that a point coming in will not be greater than ~1K, but still, this logic shouldn't care if it's watertight.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a better idea, I was worried about the extra processing, but I'll benchmark it and see

@sparrc sparrc force-pushed the udp-client branch 5 times, most recently from 10d2525 to ddcebcd Compare November 4, 2015 19:59
@sparrc
Copy link
Contributor Author

sparrc commented Nov 4, 2015

@otoolep I've pushed the changes you suggested about the buffer size before writing, and I also made changes to make the godoc examples look better, as well as an update to the README

@otoolep
Copy link
Contributor

otoolep commented Nov 4, 2015

Don't forget the CHANGELOG.

}
}

_, err = con.Write(b.Bytes())
Copy link
Contributor

Choose a reason for hiding this comment

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

I presume it's OK to write b if len(b) is 0.

@otoolep
Copy link
Contributor

otoolep commented Nov 4, 2015

I think this looks fine. I do think you need to actually test that packets sent using this code actually works -- code a throwaway client that uses UDP and sends data to an InfluxDB service, and check that the data is in InfluxDB. Since it's UDP, this unit testing doesn't guarantee it is working. Just to be sure.

Once you do that, +1

@sparrc sparrc force-pushed the udp-client branch 2 times, most recently from 3f53c5d to 51b1a42 Compare November 4, 2015 21:17
@sparrc sparrc merged commit e2db577 into master Nov 4, 2015
@sparrc sparrc deleted the udp-client branch November 5, 2015 02:50
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.

InfluxDB Client v2 should support UDP
3 participants