Skip to content

Commit fc804a4

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 bd46773 commit fc804a4

File tree

7 files changed

+801
-544
lines changed

7 files changed

+801
-544
lines changed

pkg/cache/cache.go

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

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

6060
// Start runs all the informers known to this cache until the given channel is closed.
6161
// It blocks.
@@ -68,7 +68,24 @@ type Informers interface {
6868
client.FieldIndexer
6969
}
7070

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

0 commit comments

Comments
 (0)