// NewSyncer returns a new consul.Syncer func NewSyncer(consulConfig *config.ConsulConfig, shutdownCh chan struct{}, logger *log.Logger) (*Syncer, error) { var consulClientConfig *consul.Config var err error consulClientConfig, err = consulConfig.ApiConfig() if err != nil { return nil, err } var consulClient *consul.Client if consulClient, err = consul.NewClient(consulClientConfig); err != nil { return nil, err } consulSyncer := Syncer{ client: consulClient, logger: logger, consulAvailable: true, shutdownCh: shutdownCh, servicesGroups: make(map[ServiceDomain]map[ServiceKey]*consul.AgentServiceRegistration), checkGroups: make(map[ServiceDomain]map[ServiceKey][]*consul.AgentCheckRegistration), trackedServices: make(map[consulServiceID]*consul.AgentServiceRegistration), trackedChecks: make(map[consulCheckID]*consul.AgentCheckRegistration), checkRunners: make(map[consulCheckID]*CheckRunner), periodicCallbacks: make(map[string]types.PeriodicCallback), } return &consulSyncer, nil }
// NewSyncer returns a new consul.Syncer func NewSyncer(consulConfig *config.ConsulConfig, shutdownCh chan struct{}, logger *log.Logger) (*Syncer, error) { var consulClientConfig *consul.Config var err error consulClientConfig, err = consulConfig.ApiConfig() if err != nil { return nil, err } var consulClient *consul.Client if consulClient, err = consul.NewClient(consulClientConfig); err != nil { return nil, err } consulSyncer := Syncer{ client: consulClient, logger: logger, consulAvailable: true, shutdownCh: shutdownCh, servicesGroups: make(map[ServiceDomain]map[ServiceKey]*consul.AgentServiceRegistration), checkGroups: make(map[ServiceDomain]map[ServiceKey][]*consul.AgentCheckRegistration), checkRunners: make(map[consulCheckID]*CheckRunner), periodicCallbacks: make(map[string]types.PeriodicCallback), notifySyncCh: make(chan struct{}, 1), // default noop implementation of addrFinder addrFinder: func(string) (string, int) { return "", 0 }, syncInterval: defaultSyncInterval, syncJitter: defaultSyncJitter, } return &consulSyncer, nil }