Skip to content

Commit b8dca46

Browse files
author
Shawn Hurley
committed
⚠️ Adding multinamespaced cache
* Add Multinamespace Cache type * ⚠️ Change the GetInformer methods to return a controller runtime Informer interface * Add multinamespace Informer type to handle namespaced infromers * ⚠️ move NewCacheFunc from manager package to Cache pacakge
1 parent 2027a41 commit b8dca46

File tree

7 files changed

+792
-542
lines changed

7 files changed

+792
-542
lines changed

pkg/cache/cache.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ type Cache interface {
4848
type Informers interface {
4949
// GetInformer fetches or constructs an informer for the given object that corresponds to a single
5050
// API kind and resource.
51-
GetInformer(obj runtime.Object) (toolscache.SharedIndexInformer, error)
51+
GetInformer(obj runtime.Object) (Informer, error)
5252

5353
// GetInformerForKind is similar to GetInformer, except that it takes a group-version-kind, instead
5454
// of the underlying object.
55-
GetInformerForKind(gvk schema.GroupVersionKind) (toolscache.SharedIndexInformer, error)
55+
GetInformerForKind(gvk schema.GroupVersionKind) (Informer, error)
5656

5757
// Start runs all the informers known to this cache until the given channel is closed.
5858
// It blocks.
@@ -69,6 +69,23 @@ type Informers interface {
6969
IndexField(obj runtime.Object, field string, extractValue client.IndexerFunc) error
7070
}
7171

72+
// Informer - informer allows you interact with the underlying informer
73+
type Informer interface {
74+
// AddEventHandler adds an event handler to the shared informer using the shared informer's resync
75+
// period. Events to a single handler are delivered sequentially, but there is no coordination
76+
// between different handlers.
77+
AddEventHandler(handler toolscache.ResourceEventHandler)
78+
// AddEventHandlerWithResyncPeriod adds an event handler to the shared informer using the
79+
// specified resync period. Events to a single handler are delivered sequentially, but there is
80+
// no coordination between different handlers.
81+
AddEventHandlerWithResyncPeriod(handler toolscache.ResourceEventHandler, resyncPeriod time.Duration)
82+
// AddIndexers adds more indexers to this store. If you call this after you already have data
83+
// in the store, the results are undefined.
84+
AddIndexers(indexers toolscache.Indexers) error
85+
//HasSynced return true if the informers underlying store has synced
86+
HasSynced() bool
87+
}
88+
7289
// Options are the optional arguments for creating a new InformersMap object
7390
type Options struct {
7491
// Scheme is the scheme to use for mapping objects to GroupVersionKinds

0 commit comments

Comments
 (0)