Always create a consul.Syncer. Use a default Consul Config if necessary.

This commit is contained in:
Sean Chittenden 2016-06-10 11:19:02 -04:00
parent e69232dd73
commit f6a0459ae5
No known key found for this signature in database
GPG key ID: 4EBC9DC16C2E5E16
2 changed files with 14 additions and 0 deletions

View file

@ -205,7 +205,14 @@ type UniversalExecutor struct {
// NewExecutor returns an Executor
func NewExecutor(logger *log.Logger) Executor {
shutdownCh := make(chan struct{})
cs, err := consul.NewSyncer(nil, shutdownCh, logger)
if err != nil {
return err
}
exec := &UniversalExecutor{
consulSyncer: cs,
logger: logger,
processExited: make(chan interface{}),
shutdownCh: make(chan struct{}),

View file

@ -111,7 +111,14 @@ type Syncer struct {
func NewSyncer(config *config.ConsulConfig, shutdownCh chan struct{}, logger *log.Logger) (*Syncer, error) {
var err error
var c *consul.Client
cfg := consul.DefaultConfig()
// If a nil config was provided, fall back to the default config
if config == nil {
config = cfg
}
if config.Addr != "" {
cfg.Address = config.Addr
}