cacher: remove unnecessary initialzation

This commit is contained in:
Xiang Li
2016-06-04 22:49:45 -07:00
parent 411696d5ef
commit c530a5810a

View File

@@ -158,22 +158,18 @@ func NewCacherFromConfig(config CacherConfig) *Cacher {
} }
cacher := &Cacher{ cacher := &Cacher{
usable: sync.RWMutex{},
storage: config.Storage, storage: config.Storage,
watchCache: watchCache, watchCache: watchCache,
reflector: cache.NewReflector(listerWatcher, config.Type, watchCache, 0), reflector: cache.NewReflector(listerWatcher, config.Type, watchCache, 0),
watcherIdx: 0,
watchers: make(map[int]*cacheWatcher), watchers: make(map[int]*cacheWatcher),
versioner: config.Versioner, versioner: config.Versioner,
keyFunc: config.KeyFunc, keyFunc: config.KeyFunc,
stopped: false,
// We need to (potentially) stop both: // We need to (potentially) stop both:
// - wait.Until go-routine // - wait.Until go-routine
// - reflector.ListAndWatch // - reflector.ListAndWatch
// and there are no guarantees on the order that they will stop. // and there are no guarantees on the order that they will stop.
// So we will be simply closing the channel, and synchronizing on the WaitGroup. // So we will be simply closing the channel, and synchronizing on the WaitGroup.
stopCh: make(chan struct{}), stopCh: make(chan struct{}),
stopWg: sync.WaitGroup{},
} }
// See startCaching method for explanation and where this is unlocked. // See startCaching method for explanation and where this is unlocked.
cacher.usable.Lock() cacher.usable.Lock()