mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-04 18:56:21 +00:00
finished pass over comments on Controller, and commented sharedIndexInformer
Kubernetes-commit: f2a8e2d9c9cadc8a969efa1d4edef833ff701e2f
This commit is contained in:
parent
edca648925
commit
c68732b808
14
tools/cache/controller.go
vendored
14
tools/cache/controller.go
vendored
@ -87,10 +87,22 @@ type controller struct {
|
||||
clock clock.Clock
|
||||
}
|
||||
|
||||
// Controller is a low-level controller used in sharedIndexInformer.
|
||||
// Controller is a low-level controller that is parameterized by a
|
||||
// Config and used in sharedIndexInformer.
|
||||
type Controller interface {
|
||||
// Run does two things. One is to construct and run a Reflector
|
||||
// to pump objects/notifications from the Config's ListerWatcher
|
||||
// to the Config's Queue and possibly invoke the occasional Resync
|
||||
// on that Queue. The other is to repeatedly Pop from the Queue
|
||||
// and process with the Config's ProcessFunc. Both of these
|
||||
// continue until `stopCh` is closed.
|
||||
Run(stopCh <-chan struct{})
|
||||
|
||||
// HasSynced delegates to the Queue
|
||||
HasSynced() bool
|
||||
|
||||
// LastSyncResourceVersion delegates to the Reflector when there
|
||||
// is one, otherwise returns the empty string
|
||||
LastSyncResourceVersion() string
|
||||
}
|
||||
|
||||
|
15
tools/cache/shared_informer.go
vendored
15
tools/cache/shared_informer.go
vendored
@ -144,7 +144,7 @@ type SharedInformer interface {
|
||||
AddEventHandlerWithResyncPeriod(handler ResourceEventHandler, resyncPeriod time.Duration)
|
||||
// GetStore returns the informer's local cache as a Store.
|
||||
GetStore() Store
|
||||
// GetController gives back a synthetic interface that "votes" to start the informer
|
||||
// GetController is deprecated, it does nothing useful
|
||||
GetController() Controller
|
||||
// Run starts and runs the shared informer, returning after it stops.
|
||||
// The informer will be stopped when stopCh is closed.
|
||||
@ -237,6 +237,19 @@ func WaitForCacheSync(stopCh <-chan struct{}, cacheSyncs ...InformerSynced) bool
|
||||
return true
|
||||
}
|
||||
|
||||
// `*sharedIndexInformer` implements SharedIndexInformer and has three
|
||||
// main components. One is an indexed local cache, `indexer Indexer`.
|
||||
// The second main component is a Controller that pulls
|
||||
// objects/notifications using the ListerWatcher and pushes them into
|
||||
// a DeltaFIFO --- whose knownObjects is the informer's local cache
|
||||
// --- while concurrently Popping Deltas values from that fifo and
|
||||
// processing them with `sharedIndexInformer::HandleDeltas`. Each
|
||||
// invocation of HandleDeltas, which is done with the fifo's lock
|
||||
// held, processes each Delta in turn. For each Delta this both
|
||||
// updates the local cache and stuffs the relevant notification into
|
||||
// the sharedProcessor. The third main component is that
|
||||
// sharedProcessor, which is responsible for relaying those
|
||||
// notifications to each of the informer's clients.
|
||||
type sharedIndexInformer struct {
|
||||
indexer Indexer
|
||||
controller Controller
|
||||
|
Loading…
Reference in New Issue
Block a user