xfer

package
v26.1.2+incompatible Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDoNotRetryError

func IsDoNotRetryError(err error) bool

IsDoNotRetryError returns true if the error is caused by DoNotRetry error, and the transfer should not be retried.

Types

type DigestRegisterer

type DigestRegisterer interface {
	Registered(diffID layer.DiffID)
}

DigestRegisterer can be implemented by a DownloadDescriptor, and provides a Registered method which gets called after a downloaded layer is registered. This allows the user of the download manager to know the DiffID of each registered layer. This method is called if a cast to DigestRegisterer is successful.

type DoNotRetry

type DoNotRetry struct {
	Err error
}

DoNotRetry is an error wrapper indicating that the error cannot be resolved with a retry.

func (DoNotRetry) Error

func (e DoNotRetry) Error() string

Error returns the stringified representation of the encapsulated error.

type DownloadDescriptor

type DownloadDescriptor interface {
	// Key returns the key used to deduplicate downloads.
	Key() string
	// ID returns the ID for display purposes.
	ID() string
	// DiffID should return the DiffID for this layer, or an error
	// if it is unknown (for example, if it has not been downloaded
	// before).
	DiffID() (layer.DiffID, error)
	// Download is called to perform the download.
	Download(ctx context.Context, progressOutput progress.Output) (io.ReadCloser, int64, error)
	// Close is called when the download manager is finished with this
	// descriptor and will not call Download again or read from the reader
	// that Download returned.
	Close()
}

A DownloadDescriptor references a layer that may need to be downloaded.

type DownloadOption

type DownloadOption func(*LayerDownloadManager)

DownloadOption set options for the LayerDownloadManager.

func WithMaxDownloadAttempts

func WithMaxDownloadAttempts(max int) DownloadOption

WithMaxDownloadAttempts configures the maximum number of download attempts for a download manager.

type LayerDownloadManager

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

LayerDownloadManager figures out which layers need to be downloaded, then registers and downloads those, taking into account dependencies between layers.

func NewLayerDownloadManager

func NewLayerDownloadManager(layerStore layer.Store, concurrencyLimit int, options ...DownloadOption) *LayerDownloadManager

NewLayerDownloadManager returns a new LayerDownloadManager.

func (*LayerDownloadManager) Download

func (ldm *LayerDownloadManager) Download(ctx context.Context, initialRootFS image.RootFS, layers []DownloadDescriptor, progressOutput progress.Output) (image.RootFS, func(), error)

Download is a blocking function which ensures the requested layers are present in the layer store. It uses the string returned by the Key method to deduplicate downloads. If a given layer is not already known to present in the layer store, and the key is not used by an in-progress download, the Download method is called to get the layer tar data. Layers are then registered in the appropriate order. The caller must call the returned release function once it is done with the returned RootFS object.

func (*LayerDownloadManager) SetConcurrency added in v1.12.0

func (ldm *LayerDownloadManager) SetConcurrency(concurrency int)

SetConcurrency sets the max concurrent downloads for each pull

type LayerUploadManager

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

LayerUploadManager provides task management and progress reporting for uploads.

func NewLayerUploadManager

func NewLayerUploadManager(concurrencyLimit int, options ...func(*LayerUploadManager)) *LayerUploadManager

NewLayerUploadManager returns a new LayerUploadManager.

func (*LayerUploadManager) SetConcurrency added in v1.12.0

func (lum *LayerUploadManager) SetConcurrency(concurrency int)

SetConcurrency sets the max concurrent uploads for each push

func (*LayerUploadManager) Upload

func (lum *LayerUploadManager) Upload(ctx context.Context, layers []UploadDescriptor, progressOutput progress.Output) error

Upload is a blocking function which ensures the listed layers are present on the remote registry. It uses the string returned by the Key method to deduplicate uploads.

type UploadDescriptor

type UploadDescriptor interface {
	// Key returns the key used to deduplicate uploads.
	Key() string
	// ID returns the ID for display purposes.
	ID() string
	// DiffID should return the DiffID for this layer.
	DiffID() layer.DiffID
	// Upload is called to perform the Upload.
	Upload(ctx context.Context, progressOutput progress.Output) (distribution.Descriptor, error)
	// SetRemoteDescriptor provides the distribution.Descriptor that was
	// returned by Upload. This descriptor is not to be confused with
	// the UploadDescriptor interface, which is used for internally
	// identifying layers that are being uploaded.
	SetRemoteDescriptor(descriptor distribution.Descriptor)
}

An UploadDescriptor references a layer that may need to be uploaded.

Jump to

Keyboard shortcuts

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