datasources: Add support for specifying multiple datasources

If multiple sources are specified, the first available source is used.
This commit is contained in:
Alex Crawford
2014-06-26 15:17:53 -07:00
parent 68dc902ed1
commit c089216cb5
9 changed files with 130 additions and 23 deletions

View File

@@ -88,7 +88,7 @@ func NewHttpClient() *HttpClient {
return hc
}
func expBackoff(interval, max time.Duration) time.Duration {
func ExpBackoff(interval, max time.Duration) time.Duration {
interval = interval * 2
if interval > max {
interval = max
@@ -131,7 +131,7 @@ func (h *HttpClient) GetRetry(rawurl string) ([]byte, error) {
return data, err
}
duration = expBackoff(duration, h.MaxBackoff)
duration = ExpBackoff(duration, h.MaxBackoff)
log.Printf("Sleeping for %v...", duration)
time.Sleep(duration)
}

View File

@@ -14,7 +14,7 @@ func TestExpBackoff(t *testing.T) {
duration := time.Millisecond
max := time.Hour
for i := 0; i < math.MaxUint16; i++ {
duration = expBackoff(duration, max)
duration = ExpBackoff(duration, max)
if duration < 0 {
t.Fatalf("duration too small: %v %v", duration, i)
}