From 44c0a1190c3200d249610c2c266c40c3312e6a44 Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Sat, 16 Jul 2016 23:25:48 -0700 Subject: [PATCH] cacher.go: embed storage.Interface into cacher --- pkg/storage/cacher.go | 51 +++---------------------------------------- 1 file changed, 3 insertions(+), 48 deletions(-) diff --git a/pkg/storage/cacher.go b/pkg/storage/cacher.go index 311622289a1..5a67771c4d0 100644 --- a/pkg/storage/cacher.go +++ b/pkg/storage/cacher.go @@ -136,7 +136,7 @@ type Cacher struct { ready *ready // Underlying storage.Interface. - storage Interface + Interface // "sliding window" of recent changes of objects and the current state. watchCache *watchCache @@ -180,7 +180,7 @@ func NewCacherFromConfig(config CacherConfig) *Cacher { cacher := &Cacher{ ready: newReady(), - storage: config.Storage, + Interface: config.Storage, watchCache: watchCache, reflector: cache.NewReflector(listerWatcher, config.Type, watchCache, 0), versioner: config.Versioner, @@ -243,26 +243,6 @@ func (c *Cacher) startCaching(stopChannel <-chan struct{}) { } } -// Implements storage.Interface. -func (c *Cacher) Backends(ctx context.Context) []string { - return c.storage.Backends(ctx) -} - -// Implements storage.Interface. -func (c *Cacher) Versioner() Versioner { - return c.storage.Versioner() -} - -// Implements storage.Interface. -func (c *Cacher) Create(ctx context.Context, key string, obj, out runtime.Object, ttl uint64) error { - return c.storage.Create(ctx, key, obj, out, ttl) -} - -// Implements storage.Interface. -func (c *Cacher) Delete(ctx context.Context, key string, out runtime.Object, preconditions *Preconditions) error { - return c.storage.Delete(ctx, key, out, preconditions) -} - // Implements storage.Interface. func (c *Cacher) Watch(ctx context.Context, key string, resourceVersion string, filter Filter) (watch.Interface, error) { watchRV, err := ParseWatchResourceVersion(resourceVersion) @@ -305,27 +285,12 @@ func (c *Cacher) Watch(ctx context.Context, key string, resourceVersion string, return watcher, nil } -// Implements storage.Interface. -func (c *Cacher) WatchList(ctx context.Context, key string, resourceVersion string, filter Filter) (watch.Interface, error) { - return c.Watch(ctx, key, resourceVersion, filter) -} - -// Implements storage.Interface. -func (c *Cacher) Get(ctx context.Context, key string, objPtr runtime.Object, ignoreNotFound bool) error { - return c.storage.Get(ctx, key, objPtr, ignoreNotFound) -} - -// Implements storage.Interface. -func (c *Cacher) GetToList(ctx context.Context, key string, filter Filter, listObj runtime.Object) error { - return c.storage.GetToList(ctx, key, filter, listObj) -} - // Implements storage.Interface. func (c *Cacher) List(ctx context.Context, key string, resourceVersion string, filter Filter, listObj runtime.Object) error { if resourceVersion == "" { // If resourceVersion is not specified, serve it from underlying // storage (for backward compatibility). - return c.storage.List(ctx, key, resourceVersion, filter, listObj) + return c.Interface.List(ctx, key, resourceVersion, filter, listObj) } // If resourceVersion is specified, serve it from cache. @@ -371,16 +336,6 @@ func (c *Cacher) List(ctx context.Context, key string, resourceVersion string, f return nil } -// Implements storage.Interface. -func (c *Cacher) GuaranteedUpdate(ctx context.Context, key string, ptrToType runtime.Object, ignoreNotFound bool, preconditions *Preconditions, tryUpdate UpdateFunc) error { - return c.storage.GuaranteedUpdate(ctx, key, ptrToType, ignoreNotFound, preconditions, tryUpdate) -} - -// Implements storage.Interface. -func (c *Cacher) Codec() runtime.Codec { - return c.storage.Codec() -} - func (c *Cacher) triggerValues(event *watchCacheEvent) ([]string, bool) { // TODO: Currently we assume that in a given Cacher object, its // is aware of exactly the same trigger (at most one). Thus calling: