@@ -26,29 +26,59 @@ var DefaultRetry = wait.Backoff{
2626}
2727
2828type retryClient struct {
29- // embed because we only want to override a few states
30- storage.Interface
29+ // All methods of storage.Interface are implemented directly on *retryClient, even when they
30+ // are purely passthroughs to the delegate. During a rebase, consider whether or not it is
31+ // safe and appropriate for a new method added to the method set of storage.Interface to
32+ // perform retries.
33+ delegate storage.Interface
34+ }
35+
36+ func (c * retryClient ) Count (key string ) (int64 , error ) {
37+ return c .delegate .Count (key )
38+ }
39+
40+ func (c * retryClient ) ReadinessCheck () error {
41+ return c .delegate .ReadinessCheck ()
42+ }
43+
44+ func (c * retryClient ) RequestWatchProgress (ctx context.Context ) error {
45+ return c .delegate .RequestWatchProgress (ctx )
46+ }
47+
48+ func (c * retryClient ) Versioner () storage.Versioner {
49+ return c .delegate .Versioner ()
3150}
3251
3352// New returns an etcd3 implementation of storage.Interface.
3453func NewRetryingEtcdStorage (delegate storage.Interface ) storage.Interface {
35- return & retryClient {Interface : delegate }
54+ return & retryClient {delegate : delegate }
55+ }
56+
57+ func (c * retryClient ) GetCurrentResourceVersion (ctx context.Context ) (uint64 , error ) {
58+ var (
59+ rv uint64
60+ err error
61+ )
62+ return rv , OnError (ctx , DefaultRetry , IsRetriableErrorOnRead , func () error {
63+ rv , err = c .delegate .GetCurrentResourceVersion (ctx )
64+ return err
65+ })
3666}
3767
3868// Create adds a new object at a key unless it already exists. 'ttl' is time-to-live
3969// in seconds (0 means forever). If no error is returned and out is not nil, out will be
4070// set to the read value from database.
4171func (c * retryClient ) Create (ctx context.Context , key string , obj , out runtime.Object , ttl uint64 ) error {
4272 return OnError (ctx , DefaultRetry , IsRetriableErrorOnWrite , func () error {
43- return c .Interface .Create (ctx , key , obj , out , ttl )
73+ return c .delegate .Create (ctx , key , obj , out , ttl )
4474 })
4575}
4676
4777// Delete removes the specified key and returns the value that existed at that spot.
4878// If key didn't exist, it will return NotFound storage error.
4979func (c * retryClient ) Delete (ctx context.Context , key string , out runtime.Object , preconditions * storage.Preconditions , validateDeletion storage.ValidateObjectFunc , cachedExistingObject runtime.Object , opts storage.DeleteOptions ) error {
5080 return OnError (ctx , DefaultRetry , IsRetriableErrorOnWrite , func () error {
51- return c .Interface .Delete (ctx , key , out , preconditions , validateDeletion , cachedExistingObject , opts )
81+ return c .delegate .Delete (ctx , key , out , preconditions , validateDeletion , cachedExistingObject , opts )
5282 })
5383}
5484
@@ -63,7 +93,7 @@ func (c *retryClient) Watch(ctx context.Context, key string, opts storage.ListOp
6393 var ret watch.Interface
6494 err := OnError (ctx , DefaultRetry , IsRetriableErrorOnRead , func () error {
6595 var innerErr error
66- ret , innerErr = c .Interface .Watch (ctx , key , opts )
96+ ret , innerErr = c .delegate .Watch (ctx , key , opts )
6797 return innerErr
6898 })
6999 return ret , err
@@ -76,7 +106,7 @@ func (c *retryClient) Watch(ctx context.Context, key string, opts storage.ListOp
76106// match 'opts.ResourceVersion' according 'opts.ResourceVersionMatch'.
77107func (c * retryClient ) Get (ctx context.Context , key string , opts storage.GetOptions , objPtr runtime.Object ) error {
78108 return OnError (ctx , DefaultRetry , IsRetriableErrorOnRead , func () error {
79- return c .Interface .Get (ctx , key , opts , objPtr )
109+ return c .delegate .Get (ctx , key , opts , objPtr )
80110 })
81111}
82112
@@ -88,7 +118,7 @@ func (c *retryClient) Get(ctx context.Context, key string, opts storage.GetOptio
88118// match 'opts.ResourceVersion' according 'opts.ResourceVersionMatch'.
89119func (c * retryClient ) GetList (ctx context.Context , key string , opts storage.ListOptions , listObj runtime.Object ) error {
90120 return OnError (ctx , DefaultRetry , IsRetriableErrorOnRead , func () error {
91- return c .Interface .GetList (ctx , key , opts , listObj )
121+ return c .delegate .GetList (ctx , key , opts , listObj )
92122 })
93123}
94124
@@ -129,7 +159,7 @@ func (c *retryClient) GetList(ctx context.Context, key string, opts storage.List
129159func (c * retryClient ) GuaranteedUpdate (ctx context.Context , key string , destination runtime.Object , ignoreNotFound bool ,
130160 preconditions * storage.Preconditions , tryUpdate storage.UpdateFunc , cachedExistingObject runtime.Object ) error {
131161 return OnError (ctx , DefaultRetry , IsRetriableErrorOnWrite , func () error {
132- return c .Interface .GuaranteedUpdate (ctx , key , destination , ignoreNotFound , preconditions , tryUpdate , cachedExistingObject )
162+ return c .delegate .GuaranteedUpdate (ctx , key , destination , ignoreNotFound , preconditions , tryUpdate , cachedExistingObject )
133163 })
134164}
135165
0 commit comments