framework_crud

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2025 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 ErrorInfo

type ErrorInfo struct {
	StatusCode int
	ErrorCode  string
}

ErrorInfo represents error information extracted from diagnostics

type ReadWithRetryOptions

type ReadWithRetryOptions struct {
	// MaxRetries is the maximum number of retry attempts (default: 30)
	MaxRetries int
	// InitialRetryInterval is the initial time to wait between retries (default: 2 seconds)
	InitialRetryInterval time.Duration
	// MaxRetryInterval is the maximum time to wait between retries (default: 30 seconds)
	MaxRetryInterval time.Duration
	// BackoffMultiplier is the multiplier for exponential backoff (default: 1.5)
	BackoffMultiplier float64
	// 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)

Jump to

Keyboard shortcuts

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