downloader

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMinRetryDelay = 2 * time.Second  // Default minimum delay between retries.
	DefaultMaxDelay      = 60 * time.Second // Default maximum delay between retries.
	DefaultMaxAttempts   = 5                // Default maximum number of retry attempts.
	DefaultFactor        = 1.6              // Default factor to increase the delay between retries.
	DefaultJitter        = 0.2              // Default jitter to add to delays.
)

Variables

This section is empty.

Functions

func Download

func Download(ctx context.Context, params Params, eventRecorder event.EventRecorder) (cfg config.MacPlatformConfigurationOptions, err error)

Download downloads an OCI image and returns a Config. It uses ORAS to pull the image and store it within the local store. It retries the download operation with exponential backoff.

Types

type Manager

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

Manager manages the download of OCI images.

func NewManager

func NewManager(eventRecorder event.EventRecorder, cachePath string) *Manager

NewManager creates a new DownloadManager.

func (*Manager) Download

func (m *Manager) Download(ctx context.Context, ref string, ignoreExisting bool) (cfg config.MacPlatformConfigurationOptions, d time.Duration, err error)

Download ensures that a download operation identified by 'ref' is only initiated once, regardless of how many subscribers request it. It uses sync.Once to ensure the job runs only once, and manages multiple subscribers using a sync.WaitGroup-like approach. Each subscriber either receives the result of the download when it's complete, or an error if the download fails or if their context is canceled. The download job is canceled when the last subscriber unsubscribes (cancels their context).

Parameters:

  • ctx: The context controlling the lifecycle of the subscriber's interest in the download.
  • ref: A unique identifier for the resource being downloaded.
  • ignoreExisting: A flag indicating whether to force a re-download, even if the resource is already cached.

Returns: - config.MacPlatformConfigurationOptions: The result of the download if successful. - error: Any error that occurred during the download, or if the subscriber's context is canceled.

type Params

type Params struct {
	Ref             string
	StorePath       string
	IgnoreExisiting bool

	MinRetryDelay time.Duration
	MaxDelay      time.Duration
	MaxAttempts   int
}

Params contains the parameters for downloading an OCI image.

Jump to

Keyboard shortcuts

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