9cb07d026f
Introduces Rancher's metadata service as an optional provider source for Traefik, enabled by setting `rancher.MetadataService`. The provider uses a long polling technique to watch the metadata service and obtain near instantaneous updates. Alternatively it can be configured to poll the metadata service every `rancher.RefreshSeconds` by setting `rancher.MetadataPoll`. The refactor splits API and metadata service code into separate source files respectively, and specific configuration is deferred to sub-structs. Incorporates bugfix #1414
19 lines
305 B
Go
19 lines
305 B
Go
package metadata
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
func testConnection(mdClient Client) error {
|
|
var err error
|
|
maxTime := 20 * time.Second
|
|
|
|
for i := 1 * time.Second; i < maxTime; i *= time.Duration(2) {
|
|
if _, err = mdClient.GetVersion(); err != nil {
|
|
time.Sleep(i)
|
|
} else {
|
|
return nil
|
|
}
|
|
}
|
|
return err
|
|
}
|