From 047e032461f9ef6226143b4768331b7f893d2572 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 18 Feb 2022 16:37:59 +0100 Subject: [PATCH] distribution/xfer: define DownloadOption type This is mostly for documentation purposes; defining a type makes the option(s) show up grouped on pkg.go.dev (and in godoc). Signed-off-by: Sebastiaan van Stijn --- distribution/xfer/download.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/distribution/xfer/download.go b/distribution/xfer/download.go index 2d0953191c..b03960761f 100644 --- a/distribution/xfer/download.go +++ b/distribution/xfer/download.go @@ -34,7 +34,7 @@ func (ldm *LayerDownloadManager) SetConcurrency(concurrency int) { } // NewLayerDownloadManager returns a new LayerDownloadManager. -func NewLayerDownloadManager(layerStore layer.Store, concurrencyLimit int, options ...func(*LayerDownloadManager)) *LayerDownloadManager { +func NewLayerDownloadManager(layerStore layer.Store, concurrencyLimit int, options ...DownloadOption) *LayerDownloadManager { manager := LayerDownloadManager{ layerStore: layerStore, tm: newTransferManager(concurrencyLimit), @@ -47,9 +47,12 @@ func NewLayerDownloadManager(layerStore layer.Store, concurrencyLimit int, optio return &manager } +// DownloadOption set options for the LayerDownloadManager. +type DownloadOption func(*LayerDownloadManager) + // WithMaxDownloadAttempts configures the maximum number of download // attempts for a download manager. -func WithMaxDownloadAttempts(max int) func(*LayerDownloadManager) { +func WithMaxDownloadAttempts(max int) DownloadOption { return func(dlm *LayerDownloadManager) { dlm.maxDownloadAttempts = max }