retry

package
v0.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewRetryingClient

func NewRetryingClient(c client.Client) *Client

NewRetryingClient returns a retry.Client that implements client.Client, but retries each operation that can fail with the specified parameters. Returns nil if the provided client is nil. The default parameters are: - interval: 100 milliseconds - backoffMultiplier: 1.0 (no backoff) - maxAttempts: 0 (no limit on attempts) - timeout: 1 second (timeout for retries) Use the builder-style With... methods to adapt the parameters.

func (*Client) BackoffMultiplier

func (rc *Client) BackoffMultiplier() float64

BackoffMultiplier returns the configured backoff multiplier for retries.

func (*Client) Create

func (rc *Client) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) (err error)

Create wraps the client's Create method and retries it on failure.

func (*Client) CreateOrPatch

func (rc *Client) CreateOrPatch(ctx context.Context, obj client.Object, f controllerutil.MutateFn) (res controllerutil.OperationResult, err error)

CreateOrPatch wraps the controllerutil.CreateOrPatch function and retries it on failure.

func (*Client) CreateOrUpdate

func (rc *Client) CreateOrUpdate(ctx context.Context, obj client.Object, f controllerutil.MutateFn) (res controllerutil.OperationResult, err error)

CreateOrUpdate wraps the controllerutil.CreateOrUpdate function and retries it on failure.

func (*Client) Delete

func (rc *Client) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) (err error)

Delete wraps the client's Delete method and retries it on failure.

func (*Client) DeleteAllOf

func (rc *Client) DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) (err error)

DeleteAllOf wraps the client's DeleteAllOf method and retries it on failure.

func (*Client) Get

func (rc *Client) Get(ctx context.Context, key client.ObjectKey, obj client.Object, opts ...client.GetOption) (err error)

Get wraps the client's Get method and retries it on failure.

func (*Client) GroupVersionKindFor

func (rc *Client) GroupVersionKindFor(obj runtime.Object) (gvk schema.GroupVersionKind, err error)

GroupVersionKindFor wraps the client's GroupVersionKindFor method and retries it on failure.

func (*Client) Interval

func (rc *Client) Interval() time.Duration

Interval returns the configured retry interval.

func (*Client) IsObjectNamespaced

func (rc *Client) IsObjectNamespaced(obj runtime.Object) (namespaced bool, err error)

IsObjectNamespaced wraps the client's IsObjectNamespaced method and retries it on failure.

func (*Client) List

func (rc *Client) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) (err error)

List wraps the client's List method and retries it on failure.

func (*Client) MaxAttempts

func (rc *Client) MaxAttempts() int

MaxAttempts returns the configured maximum number of retries.

func (*Client) Patch

func (rc *Client) Patch(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption) (err error)

Patch wraps the client's Patch method and retries it on failure.

func (*Client) RESTMapper

func (rc *Client) RESTMapper() meta.RESTMapper

RESTMapper calls the internal client's RESTMapper method.

func (*Client) Scheme

func (rc *Client) Scheme() *runtime.Scheme

Scheme calls the internal client's Scheme method.

func (*Client) Status

func (rc *Client) Status() client.SubResourceWriter

Status calls the internal client's Status method.

func (*Client) SubResource

func (rc *Client) SubResource(subResource string) client.SubResourceClient

SubResource calls the internal client's SubResource method.

func (*Client) Timeout

func (rc *Client) Timeout() time.Duration

Timeout returns the configured timeout for retries.

func (*Client) Update

func (rc *Client) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) (err error)

Update wraps the client's Update method and retries it on failure.

func (*Client) WithBackoffMultiplier

func (rc *Client) WithBackoffMultiplier(multiplier float64) *Client

WithBackoffMultiplier sets the backoff multiplier for the Client. After each retry, the configured interval is multiplied by this factor. Setting it to a value less than 1 will default it to 1. Default is 1.0, meaning no backoff. Noop if the multiplier is less than 1. It returns the Client for chaining.

func (*Client) WithContext

func (rc *Client) WithContext(ctx context.Context) *Client

WithContext sets the context for the next call of either GroupVersionKindFor or IsObjectNamespaced. Since the signature of these methods does not allow passing a context, and the retrying can not be cancelled without one, this method is required to inject the context to be used for the aforementioned methods. Note that any function of this Client that actually retries an operation will reset this context, but only for GroupVersionKindFor and IsObjectNamespaced it will actually be used. The intended use of this method is something like this:

c.WithContext(ctx).GroupVersionKindFor(obj)
c.WithContext(ctx).IsObjectNamespaced(obj)

If no context is injected via this method, both GroupVersionKindFor and IsObjectNamespaced will use the default context.Background(). It returns the Client for chaining.

func (*Client) WithInterval

func (rc *Client) WithInterval(interval time.Duration) *Client

WithInterval sets the retry interval for the Client. Default is 100 milliseconds. Noop if the interval is less than or equal to 0. It returns the Client for chaining.

func (*Client) WithMaxAttempts

func (rc *Client) WithMaxAttempts(maxAttempts int) *Client

WithMaxAttempts sets the maximum number of attempts for the Client. If set to 0, it will retry indefinitely until the timeout is reached. Default is 0, meaning no limit on attempts. Noop if the maxAttempts is less than 0. It returns the Client for chaining.

func (*Client) WithTimeout

func (rc *Client) WithTimeout(timeout time.Duration) *Client

WithTimeout sets the timeout for retries in the Client. If set to 0, there is no timeout and it will retry until the maximum number of retries is reached. Default is 1 second. Noop if the timeout is less than 0. It returns the Client for chaining.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL