Browse Source

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 <github@gone.nl>
Sebastiaan van Stijn 3 years ago
parent
commit
047e032461
1 changed files with 5 additions and 2 deletions
  1. 5 2
      distribution/xfer/download.go

+ 5 - 2
distribution/xfer/download.go

@@ -34,7 +34,7 @@ func (ldm *LayerDownloadManager) SetConcurrency(concurrency int) {
 }
 }
 
 
 // NewLayerDownloadManager returns a new LayerDownloadManager.
 // 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{
 	manager := LayerDownloadManager{
 		layerStore:          layerStore,
 		layerStore:          layerStore,
 		tm:                  newTransferManager(concurrencyLimit),
 		tm:                  newTransferManager(concurrencyLimit),
@@ -47,9 +47,12 @@ func NewLayerDownloadManager(layerStore layer.Store, concurrencyLimit int, optio
 	return &manager
 	return &manager
 }
 }
 
 
+// DownloadOption set options for the LayerDownloadManager.
+type DownloadOption func(*LayerDownloadManager)
+
 // WithMaxDownloadAttempts configures the maximum number of download
 // WithMaxDownloadAttempts configures the maximum number of download
 // attempts for a download manager.
 // attempts for a download manager.
-func WithMaxDownloadAttempts(max int) func(*LayerDownloadManager) {
+func WithMaxDownloadAttempts(max int) DownloadOption {
 	return func(dlm *LayerDownloadManager) {
 	return func(dlm *LayerDownloadManager) {
 		dlm.maxDownloadAttempts = max
 		dlm.maxDownloadAttempts = max
 	}
 	}