DataDog / kvexpress

## Auto-archived due to inactivity. ## Go program to move data in and out of Consul's KV store.
Apache License 2.0
128 stars 13 forks source link

Refactor Consul connection. All unit and integration tests pass. #74

Closed darron closed 8 years ago

darron commented 8 years ago

The previous Consul connection logic was pretty weak - if it didn't connect on the first try for a Get/Set or Del it just failed. This one tries consulTries times over approximately 15 seconds - if it can't get a connection then there's likely something wrong - most Consul interruptions are 5-10 seconds at maximum.

The called functions basically just wrap their counterpart with retry logic:

  1. Get calls consulGet
  2. Set calls consulSet
  3. Del calls consulDel

You can see the logs in your local Console app:

http://shared.froese.org/2015/23c7l-10-30.jpg

To setup you need Go and a local installation of Consul:

make deps
make
make test

I've been using Go 1.5.x - haven't tried it on Go 1.4.

First of all - is this sane?

Second - any big red flags?

Thanks @calebdoxsey

calebdoxsey commented 8 years ago

I added some suggestions. I think the idea is sound - the exponential backoff pattern is very common. There are some retry libraries out there that you could try, but I think a simple function is sufficient.

darron commented 8 years ago

Thanks for the look @calebdoxsey - I have so much to learn around Go - appreciate the pointers. Will take a look at this tonight and see how I can tighten things up.

calebdoxsey commented 8 years ago

:+1:

darron commented 8 years ago

Going to test in staging now.