Commit Graph

62 Commits

Author SHA1 Message Date
James Phillips bd605e330c
Adds basic support for node IDs. 2017-01-17 22:47:59 -08:00
Sean Chittenden d695bcaae6 Use a cryptographically secure seed
`SeededSecurely` is present if someone or something wants to query the way the library was seeded.

Obtained from: nomad
2016-05-02 23:52:37 -07:00
Sean Chittenden da298f527d Guard against divide by zero in lib.RandomStagger()
While I'm at it, add a DurationMinusBufferDomain() function to calculate the min/max for a given call to DurationMinusBuffer() in order to keep the implementation details self-contained.
2016-04-23 13:11:32 -07:00
Sean Chittenden 3a6be9cab0 Add a helper function DurationMinusBuffer() to calculate an interval
used to schedule a TTL check.  e.g.

d := lib.DurationMinusBuffer(60 * time.Duration, 10 * time.Second, 16)

will return a duration between 46.875s and 50s.
2016-04-23 09:06:54 -07:00
Sean Chittenden 4584e70636 Add lib.AbsInt() helper function 2016-03-30 11:47:37 -07:00
Sean Chittenden 88c42f4056 Move lib's tests to lib_test
This suite of tests is only testing the exported functions
2016-03-29 19:51:37 -07:00
Sean Chittenden 9fb64ab114 Allow adjusting the number of DNS records in a response...
Based on work done by @fusiondog in #1583, extend the concept to use an integer instead of a boolean.

Fixes: #1583 && #1481
2016-03-29 19:23:56 -07:00
Sean Chittenden 4fec6a9608 Guard against very small or negative rates
Pointed out by: slackpad
2016-03-25 13:31:55 -07:00
Sean Chittenden 81e1e1c05d Cull unused function and its unit test.
Pointed out by: @slackpad
2016-02-01 22:40:19 -08:00
Sean Chittenden 6c1bb78d06 Cull unused function and its unit test.
Pointed out by: @slackpad
2016-02-01 22:26:57 -08:00
Sean Chittenden 4382c1f7aa Always seed math/rand on consul startup
Required for jitter calcs.  This could be done in consul/agent, but this makes it clear it is done only once process-wide.
2016-01-29 17:00:08 -08:00
Sean Chittenden 7af6a94edb Factor out duplicate functions into a lib package
Consolidate code duplication and tests into a single lib package.  Most of these functions were from various **/util.go functions that couldn't be imported due to cyclic imports.  The consul/lib package is intended to be a terminal node in an import DAG and a place to stash various consul-only helper functions.  Pulled in hashicorp/go-uuid instead of consolidating UUID access.
2016-01-29 16:57:45 -08:00