func New(client ctrlclient.Client, reader ctrlclient.Reader, config Config) types.Retrier
New creates a new instance of RetryClient as a Retrier interface. If not provided via the config then the RetryClient will have the default args:
RequestTimeout: 5 Seconds
InitialBackoff: 0.5 Seconds
BackoffFactor: 1.5
MaxRetries: 3
You can keep all of the defaults or overwrite individual values by only including the values you wish to overwrite in the provided config. You can not set any of these fields to their nil values because these will not overwrite the defaults.
Config is a data structure used to configure the RetryClient. The fields can be used in the following ways:
RequestTimeout: The timeout used for client requests
InitialBackoff: The initial backoff period to wait between failed requests
BackoffFactor: The factor by which to increase the backoff period after each failed attempt
MaxRetries: The maximum number of retries to attempt before returning an error
type Config struct { RequestTimeout time.Duration InitialBackoff time.Duration BackoffFactor float64 MaxRetries int }
RetryClient is a Kubernetes client that incorporates retries in its operations
type RetryClient struct { Config // contains filtered or unexported fields }
func (r *RetryClient) Client() ctrlclient.Client
Client will return the controller runtime client used by the retry client
func (r RetryClient) IgnoreCache() types.Retrier
IgnoreCache returns a retryclient object that can be chained to make direct API server requests without using the client cache. This should be used sparingly as it will increase direct requests to the API server. The original retryclient will not be altered and will continue to use cache. This is done to make sure cache is only ignored where it is absolutely necessary.
func (r *RetryClient) Reader() ctrlclient.Reader
Reader will return the controller runtime API reader used by the retry client
func (r *RetryClient) SafeCreate(ctx context.Context, obj ctrlclient.Object, opts ...ctrlclient.CreateOption) error
SafeCreate attempts to create a Kubernetes object, with retries.
func (r *RetryClient) SafeDelete(ctx context.Context, obj ctrlclient.Object, opts ...ctrlclient.DeleteOption) error
SafeDelete attempts to delete a Kubernetes object, with retries.
func (r *RetryClient) SafeGet(ctx context.Context, objKey ctrlclient.ObjectKey, obj ctrlclient.Object, opts ...ctrlclient.GetOption) error
SafeGet attempts to retrieve a Kubernetes object, with retries.
func (r *RetryClient) SafeList(ctx context.Context, list ctrlclient.ObjectList, opts ...ctrlclient.ListOption) error
SafeList attempts to list Kubernetes objects, with retries.
func (r *RetryClient) SafeUpdate(ctx context.Context, objKey ctrlclient.ObjectKey, obj ctrlclient.Object, fn func(context.Context, ctrlclient.Object) error, updateOpts ...ctrlclient.UpdateOption) error
SafeUpdate attempts to update a Kubernetes object using the provided function, with retries.