trackedresource

package
v0.30.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

package trackedresource provides utility functionality for working with tracked resources. This functionality is shared between frontend and backend controllers for tracked resources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IDFor

func IDFor(id resources.ID) resources.ID

IDFor computes the resource ID of a tracked resource entry from the original resource ID.

func NameFor

func NameFor(id resources.ID) string

NameFor computes the resource name of a tracked resource from its ID.

This can be used to compute the name of a tracked resource based on the resource that it is tracking.

Names are computed by taking the name of the resource being tracked and appending a suffix to it based on the hash of the resource ID. This ensures that the name is unique and deterministic.

Types

type InProgressErr

type InProgressErr struct {
}

InProgressErr signifies that the resource is currently in a non-terminal state.

func (*InProgressErr) Error

func (e *InProgressErr) Error() string

Error returns the error message.

func (*InProgressErr) Is

func (e *InProgressErr) Is(other error) bool

Is returns true if the other error is an InProgressErr.

type Updater

type Updater struct {
	// Store is the storage client used to access the database.
	Store store.StorageClient

	// Client is the HTTP client used to make requests to the downstream API.
	Client *http.Client

	// AttemptCount is the number of times to attempt a request and database update.
	AttemptCount int

	// RetryDelay is the delay between retries.
	RetryDelay time.Duration

	// RequestTimeout is the timeout used for requests to the downstream API.
	RequestTimeout time.Duration
}

Updater is a utility struct that can perform updates on tracked resources.

func NewUpdater

func NewUpdater(storeClient store.StorageClient, httpClient *http.Client) *Updater

NewUpdater creates a new Updater.

func (*Updater) Update

func (u *Updater) Update(ctx context.Context, downstream string, id resources.ID, apiVersion string) error

Update updates a tracked resource.

This function return attempt to update the state using optimistic concurrency and will retry on the following conditions:

- Downstream failure or timeout - Database failure - Optimistic concurrency failure - Resource is still being provisioned (provisioning state is non-terminal)

Jump to

Keyboard shortcuts

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