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 ¶
- func IDFor(id resources.ID) resources.ID
- func LegacyIDFor(id resources.ID) resources.ID
- func LegacyNameFor(id resources.ID) string
- func NameFor(id resources.ID) string
- func ResolveTrackingEntry(ctx context.Context, client database.Client, id resources.ID) (resources.ID, *database.Object, error)
- type InProgressErr
- type Updater
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IDFor ¶
IDFor computes the resource ID of a tracked resource entry from the original resource ID.
func LegacyIDFor ¶ added in v0.60.0
LegacyIDFor computes the resource ID of a tracked resource entry using the legacy SHA-1 name.
Used only to locate tracked resource entries written by older versions of Radius during the migration to SHA-256. See https://github.com/radius-project/radius/issues/8084.
func LegacyNameFor ¶ added in v0.60.0
LegacyNameFor computes the tracked resource name using the legacy SHA-1 hash.
SHA-1 is retained only to locate tracked resource entries written by older versions of Radius during the migration to SHA-256. Use NameFor for new values. See https://github.com/radius-project/radius/issues/8084.
func NameFor ¶
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.
func ResolveTrackingEntry ¶ added in v0.60.0
func ResolveTrackingEntry(ctx context.Context, client database.Client, id resources.ID) (resources.ID, *database.Object, error)
ResolveTrackingEntry reads the tracking entry for id from the database, preferring the current (SHA-256) tracking ID and falling back to the legacy (SHA-1) tracking ID written by older versions of Radius.
It returns the tracking ID to operate under (the current ID when the resource is not yet tracked) and the existing stored object, if any. Existing entries continue to be maintained under whichever ID they were created with until they are deleted; new entries are created under the current ID. This keeps the SHA-1 -> SHA-256 migration non-breaking. See https://github.com/radius-project/radius/issues/8084.
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 {
// DatabaseClient is the database client used to access the database.
DatabaseClient database.Client
// 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 ¶
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)