Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
ee19c1ec
Unverified
Commit
ee19c1ec
authored
May 09, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
May 09, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #77636 from MikeSpreitzer/fix77634
Made the comment on SharedInformer give a complete description
parents
bb00054b
121e4741
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
14 deletions
+66
-14
shared_informer.go
staging/src/k8s.io/client-go/tools/cache/shared_informer.go
+66
-14
No files found.
staging/src/k8s.io/client-go/tools/cache/shared_informer.go
View file @
ee19c1ec
...
@@ -31,31 +31,83 @@ import (
...
@@ -31,31 +31,83 @@ import (
"k8s.io/klog"
"k8s.io/klog"
)
)
// SharedInformer has a shared data cache and is capable of distributing notifications for changes
// SharedInformer provides eventually consistent linkage of its
// to the cache to multiple listeners who registered via AddEventHandler. If you use this, there is
// clients to the authoritative state of a given collection of
// one behavior change compared to a standard Informer. When you receive a notification, the cache
// objects. An object is identified by its API group, kind/resource,
// will be AT LEAST as fresh as the notification, but it MAY be more fresh. You should NOT depend
// namespace, and name. One SharedInfomer provides linkage to objects
// on the contents of the cache exactly matching the notification you've received in handler
// of a particular API group and kind/resource. The linked object
// functions. If there was a create, followed by a delete, the cache may NOT have your item. This
// collection of a SharedInformer may be further restricted to one
// has advantages over the broadcaster since it allows us to share a common cache across many
// namespace and/or by label selector and/or field selector.
// controllers. Extending the broadcaster would have required us keep duplicate caches for each
//
// watch.
// The authoritative state of an object is what apiservers provide
// access to, and an object goes through a strict sequence of states.
// A state is either "absent" or present with a ResourceVersion and
// other appropriate content.
//
// A SharedInformer maintains a local cache, exposed by Store(), of
// the state of each relevant object. This cache is eventually
// consistent with the authoritative state. This means that, unless
// prevented by persistent communication problems, if ever a
// particular object ID X is authoritatively associated with a state S
// then for every SharedInformer I whose collection includes (X, S)
// eventually either (1) I's cache associates X with S or a later
// state of X, (2) I is stopped, or (3) the authoritative state
// service for X terminates. To be formally complete, we say that the
// absent state meets any restriction by label selector or field
// selector.
//
// As a simple example, if a collection of objects is henceforeth
// unchanging and a SharedInformer is created that links to that
// collection then that SharedInformer's cache eventually holds an
// exact copy of that collection (unless it is stopped too soon, the
// authoritative state service ends, or communication problems between
// the two persistently thwart achievement).
//
// As another simple example, if the local cache ever holds a
// non-absent state for some object ID and the object is eventually
// removed from the authoritative state then eventually the object is
// removed from the local cache (unless the SharedInformer is stopped
// too soon, the authoritative state service emnds, or communication
// problems persistently thwart the desired result).
//
// The keys in Store() are of the form namespace/name for namespaced
// objects, and are simply the name for non-namespaced objects.
//
// A client is identified here by a ResourceEventHandler. For every
// update to the SharedInformer's local cache and for every client,
// eventually either the SharedInformer is stopped or the client is
// notified of the update. These notifications happen after the
// corresponding cache update and, in the case of a
// SharedIndexInformer, after the corresponding index updates. It is
// possible that additional cache and index updates happen before such
// a prescribed notification. For a given SharedInformer and client,
// all notifications are delivered sequentially. For a given
// SharedInformer, client, and object ID, the notifications are
// delivered in order.
//
// A delete notification exposes the last locally known non-absent
// state, except that its ResourceVersion is replaced with a
// ResourceVersion in which the object is actually absent.
type
SharedInformer
interface
{
type
SharedInformer
interface
{
// AddEventHandler adds an event handler to the shared informer using the shared informer's resync
// AddEventHandler adds an event handler to the shared informer using the shared informer's resync
// period. Events to a single handler are delivered sequentially, but there is no coordination
// period. Events to a single handler are delivered sequentially, but there is no coordination
// between different handlers.
// between different handlers.
AddEventHandler
(
handler
ResourceEventHandler
)
AddEventHandler
(
handler
ResourceEventHandler
)
// AddEventHandlerWithResyncPeriod adds an event handler to the shared informer using the
// AddEventHandlerWithResyncPeriod adds an event handler to the
// specified resync period. Events to a single handler are delivered sequentially, but there is
// shared informer using the specified resync period. The resync
// no coordination between different handlers.
// operation consists of delivering to the handler a create
// notification for every object in the informer's local cache; it
// does not add any interactions with the authoritative storage.
AddEventHandlerWithResyncPeriod
(
handler
ResourceEventHandler
,
resyncPeriod
time
.
Duration
)
AddEventHandlerWithResyncPeriod
(
handler
ResourceEventHandler
,
resyncPeriod
time
.
Duration
)
// GetStore returns the Store.
// GetStore returns the
informer's local cache as a
Store.
GetStore
()
Store
GetStore
()
Store
// GetController gives back a synthetic interface that "votes" to start the informer
// GetController gives back a synthetic interface that "votes" to start the informer
GetController
()
Controller
GetController
()
Controller
// Run starts the shared informer, which will be stopped when stopCh is closed.
// Run starts the shared informer, which will be stopped when stopCh is closed.
Run
(
stopCh
<-
chan
struct
{})
Run
(
stopCh
<-
chan
struct
{})
// HasSynced returns true if the shared informer's store has synced.
// HasSynced returns true if the shared informer's store has been
// informed by at least one full LIST of the authoritative state
// of the informer's object collection. This is unrelated to "resync".
HasSynced
()
bool
HasSynced
()
bool
// LastSyncResourceVersion is the resource version observed when last synced with the underlying
// LastSyncResourceVersion is the resource version observed when last synced with the underlying
// store. The value returned is not synchronized with access to the underlying store and is not
// store. The value returned is not synchronized with access to the underlying store and is not
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment