crud

package
v0.26.0-alpha Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2025 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteWithRetry

func DeleteWithRetry(
	ctx context.Context,
	deleteFunc func(ctx context.Context) error,
	opts DeleteWithRetryOptions,
) error

DeleteWithRetry executes a delete operation with retry logic within the context timeout It repeatedly calls the provided delete function until success or context timeout

func HandleTimeout

func HandleTimeout(ctx context.Context, timeoutFunc func(context.Context, time.Duration) (time.Duration, diag.Diagnostics), defaultTimeout time.Duration, diags *diag.Diagnostics) (context.Context, context.CancelFunc)

HandleTimeout is a helper function to manage context timeouts

func ReadWithRetry

func ReadWithRetry(
	ctx context.Context,
	readFunc func(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse),
	readReq resource.ReadRequest,
	stateContainer StateContainer,
	opts ReadWithRetryOptions,
) error

ReadWithRetry executes a read operation with retry logic within the context timeout It repeatedly calls the provided read function until success or context timeout

Types

type CreateResponseContainer

type CreateResponseContainer struct {
	*resource.CreateResponse
}

CreateResponseContainer wraps resource.CreateResponse to implement StateContainer

func (*CreateResponseContainer) GetState

func (c *CreateResponseContainer) GetState() tfsdk.State

func (*CreateResponseContainer) SetState

func (c *CreateResponseContainer) SetState(state tfsdk.State)

type DeleteWithRetryOptions

type DeleteWithRetryOptions struct {
	// MaxRetries is the maximum number of retry attempts (default: 10)
	MaxRetries int
	// RetryInterval is the time to wait between retries (default: 30 seconds)
	RetryInterval time.Duration
	// Operation is the name of the operation for logging (e.g., "Delete")
	Operation string
	// ResourceTypeName is the optional resource type name for logging
	ResourceTypeName string
	// ResourceID is the resource ID for logging
	ResourceID string
}

DeleteWithRetryOptions configures the retry behavior for delete operations

func DefaultDeleteWithRetryOptions

func DefaultDeleteWithRetryOptions() DeleteWithRetryOptions

DefaultDeleteWithRetryOptions returns sensible default options for delete operations

type ReadWithRetryOptions

type ReadWithRetryOptions struct {
	// MaxRetries is the maximum number of retry attempts (default: 30)
	MaxRetries int
	// RetryInterval is the time to wait between retries (default: 2 seconds)
	RetryInterval time.Duration
	// Operation is the name of the operation for logging (e.g., "Create", "Update")
	Operation string
	// ResourceTypeName is the optional resource type name for logging
	ResourceTypeName string
}

ReadWithRetryOptions configures the retry behavior for reading resource state

func DefaultReadWithRetryOptions

func DefaultReadWithRetryOptions() ReadWithRetryOptions

DefaultReadWithRetryOptions returns sensible default options for most use cases

type StateContainer

type StateContainer interface {
	GetState() tfsdk.State
	SetState(tfsdk.State)
}

StateContainer interface for anything that has a State field

type UpdateResponseContainer

type UpdateResponseContainer struct {
	*resource.UpdateResponse
}

UpdateResponseContainer wraps resource.UpdateResponse to implement StateContainer

func (*UpdateResponseContainer) GetState

func (c *UpdateResponseContainer) GetState() tfsdk.State

func (*UpdateResponseContainer) SetState

func (c *UpdateResponseContainer) SetState(state tfsdk.State)

Directories

Path Synopsis
graph_beta

Jump to

Keyboard shortcuts

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