Update service fabric

This commit is contained in:
SALLEYRON Julien 2018-07-13 18:04:03 +02:00 committed by Traefiker Bot
parent 5afc8f2b12
commit 5774d100c1
3 changed files with 21 additions and 18 deletions

7
Gopkg.lock generated
View file

@ -276,10 +276,10 @@
version = "v3.1.1" version = "v3.1.1"
[[projects]] [[projects]]
branch = "init-provider"
name = "github.com/containous/traefik-extra-service-fabric" name = "github.com/containous/traefik-extra-service-fabric"
packages = ["."] packages = ["."]
revision = "eb4d5cf161b3213bf45be611dc1f56e8b2161e46" revision = "6e90a9eef2ac9d320e55d6e994d169673a8d8b0f"
version = "v1.3.0"
[[projects]] [[projects]]
name = "github.com/coreos/bbolt" name = "github.com/coreos/bbolt"
@ -781,7 +781,6 @@
revision = "9b66602d496a139e4722bdde32f0f1ac1c12d4a8" revision = "9b66602d496a139e4722bdde32f0f1ac1c12d4a8"
[[projects]] [[projects]]
branch = "master"
name = "github.com/jjcollinge/servicefabric" name = "github.com/jjcollinge/servicefabric"
packages = ["."] packages = ["."]
revision = "8eebe170fa1ba25d3dfb928b3f86a7313b13b9fe" revision = "8eebe170fa1ba25d3dfb928b3f86a7313b13b9fe"
@ -1756,6 +1755,6 @@
[solve-meta] [solve-meta]
analyzer-name = "dep" analyzer-name = "dep"
analyzer-version = 1 analyzer-version = 1
inputs-digest = "c228c6029e36e15b6c74bdfa587ee0fa39787af0dc0d4047752d80ee2fb690c1" inputs-digest = "2b7ffb1d01d8a14224fcc9964900fb5a39fbf38cfacba45f49b931136e4fee9b"
solver-name = "gps-cdcl" solver-name = "gps-cdcl"
solver-version = 1 solver-version = 1

View file

@ -66,7 +66,7 @@
[[constraint]] [[constraint]]
name = "github.com/containous/traefik-extra-service-fabric" name = "github.com/containous/traefik-extra-service-fabric"
branch = "init-provider" version = "1.3.0"
[[constraint]] [[constraint]]
name = "github.com/coreos/go-systemd" name = "github.com/coreos/go-systemd"

View file

@ -39,17 +39,16 @@ type Provider struct {
AppInsightsKey string `description:"Application Insights Instrumentation Key"` AppInsightsKey string `description:"Application Insights Instrumentation Key"`
AppInsightsBatchSize int `description:"Number of trace lines per batch, optional"` AppInsightsBatchSize int `description:"Number of trace lines per batch, optional"`
AppInsightsInterval flaeg.Duration `description:"The interval for sending data to Application Insights, optional"` AppInsightsInterval flaeg.Duration `description:"The interval for sending data to Application Insights, optional"`
sfClient sfClient
} }
// Init the provider // Init the provider
func (p *Provider) Init(constraints types.Constraints) error { func (p *Provider) Init(constraints types.Constraints) error {
p.BaseProvider.Init(constraints) err := p.BaseProvider.Init(constraints)
return nil if err != nil {
} return err
}
// Provide allows the ServiceFabric provider to provide configurations to traefik
// using the given configuration channel.
func (p *Provider) Provide(configurationChan chan<- types.ConfigMessage, pool *safe.Pool) error {
if p.APIVersion == "" { if p.APIVersion == "" {
p.APIVersion = sf.DefaultAPIVersion p.APIVersion = sf.DefaultAPIVersion
} }
@ -59,7 +58,7 @@ func (p *Provider) Provide(configurationChan chan<- types.ConfigMessage, pool *s
return err return err
} }
sfClient, err := sf.NewClient(http.DefaultClient, p.ClusterManagementURL, p.APIVersion, tlsConfig) p.sfClient, err = sf.NewClient(http.DefaultClient, p.ClusterManagementURL, p.APIVersion, tlsConfig)
if err != nil { if err != nil {
return err return err
} }
@ -77,11 +76,16 @@ func (p *Provider) Provide(configurationChan chan<- types.ConfigMessage, pool *s
} }
createAppInsightsHook(p.AppInsightsClientName, p.AppInsightsKey, p.AppInsightsBatchSize, p.AppInsightsInterval) createAppInsightsHook(p.AppInsightsClientName, p.AppInsightsKey, p.AppInsightsBatchSize, p.AppInsightsInterval)
} }
return nil
return p.updateConfig(configurationChan, pool, sfClient, time.Duration(p.RefreshSeconds))
} }
func (p *Provider) updateConfig(configurationChan chan<- types.ConfigMessage, pool *safe.Pool, sfClient sfClient, pollInterval time.Duration) error { // Provide allows the ServiceFabric provider to provide configurations to traefik
// using the given configuration channel.
func (p *Provider) Provide(configurationChan chan<- types.ConfigMessage, pool *safe.Pool) error {
return p.updateConfig(configurationChan, pool, time.Duration(p.RefreshSeconds))
}
func (p *Provider) updateConfig(configurationChan chan<- types.ConfigMessage, pool *safe.Pool, pollInterval time.Duration) error {
pool.Go(func(stop chan bool) { pool.Go(func(stop chan bool) {
operation := func() error { operation := func() error {
ticker := time.NewTicker(pollInterval) ticker := time.NewTicker(pollInterval)
@ -96,7 +100,7 @@ func (p *Provider) updateConfig(configurationChan chan<- types.ConfigMessage, po
log.Info("Checking service fabric config") log.Info("Checking service fabric config")
} }
configuration, err := p.getConfiguration(sfClient) configuration, err := p.getConfiguration()
if err != nil { if err != nil {
return err return err
} }
@ -120,8 +124,8 @@ func (p *Provider) updateConfig(configurationChan chan<- types.ConfigMessage, po
return nil return nil
} }
func (p *Provider) getConfiguration(sfClient sfClient) (*types.Configuration, error) { func (p *Provider) getConfiguration() (*types.Configuration, error) {
services, err := getClusterServices(sfClient) services, err := getClusterServices(p.sfClient)
if err != nil { if err != nil {
return nil, err return nil, err
} }