From 79ea1b16b1579147aa366282444bd22d7c44be96 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 18 Feb 2022 16:54:12 +0100 Subject: [PATCH] distribution/xfer: un-export DoFunc type It's only used internally and by non-exported functions, so it doesn't have to be exported. Signed-off-by: Sebastiaan van Stijn --- distribution/xfer/download.go | 6 +++--- distribution/xfer/transfer.go | 6 +++--- distribution/xfer/transfer_test.go | 12 ++++++------ distribution/xfer/upload.go | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/distribution/xfer/download.go b/distribution/xfer/download.go index 8ccccbcbfb..af1a3995d2 100644 --- a/distribution/xfer/download.go +++ b/distribution/xfer/download.go @@ -166,7 +166,7 @@ func (ldm *LayerDownloadManager) Download(ctx context.Context, initialRootFS ima // Layer is not known to exist - download and register it. progress.Update(progressOutput, descriptor.ID(), "Pulling fs layer") - var xferFunc DoFunc + var xferFunc doFunc if topDownload != nil { xferFunc = ldm.makeDownloadFunc(descriptor, "", topDownload) defer topDownload.transfer.release(watcher) @@ -228,7 +228,7 @@ func (ldm *LayerDownloadManager) Download(ctx context.Context, initialRootFS ima // complete before the registration step, and registers the downloaded data // on top of parentDownload's resulting layer. Otherwise, it registers the // layer on top of the ChainID given by parentLayer. -func (ldm *LayerDownloadManager) makeDownloadFunc(descriptor DownloadDescriptor, parentLayer layer.ChainID, parentDownload *downloadTransfer) DoFunc { +func (ldm *LayerDownloadManager) makeDownloadFunc(descriptor DownloadDescriptor, parentLayer layer.ChainID, parentDownload *downloadTransfer) doFunc { return func(progressChan chan<- progress.Progress, start <-chan struct{}, inactive chan<- struct{}) transfer { d := &downloadTransfer{ transfer: newTransfer(), @@ -392,7 +392,7 @@ func (ldm *LayerDownloadManager) makeDownloadFunc(descriptor DownloadDescriptor, // parentDownload. This function does not log progress output because it would // interfere with the progress reporting for sourceDownload, which has the same // Key. -func (ldm *LayerDownloadManager) makeDownloadFuncFromDownload(descriptor DownloadDescriptor, sourceDownload *downloadTransfer, parentDownload *downloadTransfer) DoFunc { +func (ldm *LayerDownloadManager) makeDownloadFuncFromDownload(descriptor DownloadDescriptor, sourceDownload *downloadTransfer, parentDownload *downloadTransfer) doFunc { return func(progressChan chan<- progress.Progress, start <-chan struct{}, inactive chan<- struct{}) transfer { d := &downloadTransfer{ transfer: newTransfer(), diff --git a/distribution/xfer/transfer.go b/distribution/xfer/transfer.go index 1693708778..d5f96c8aea 100644 --- a/distribution/xfer/transfer.go +++ b/distribution/xfer/transfer.go @@ -263,13 +263,13 @@ func (t *xfer) close() { t.mu.Unlock() } -// DoFunc is a function called by the transferManager to actually perform +// doFunc is a function called by the transferManager to actually perform // a transfer. It should be non-blocking. It should wait until the start channel // is closed before transferring any data. If the function closes inactive, that // signals to the transferManager that the job is no longer actively moving // data - for example, it may be waiting for a dependent transfer to finish. // This prevents it from taking up a slot. -type DoFunc func(progressChan chan<- progress.Progress, start <-chan struct{}, inactive chan<- struct{}) transfer +type doFunc func(progressChan chan<- progress.Progress, start <-chan struct{}, inactive chan<- struct{}) transfer // transferManager is used by LayerDownloadManager and LayerUploadManager to // schedule and deduplicate transfers. It is up to the transferManager @@ -301,7 +301,7 @@ func (tm *transferManager) setConcurrency(concurrency int) { // transfer checks if a transfer matching the given key is in progress. If not, // it starts one by calling xferFunc. The caller supplies a channel which // receives progress output from the transfer. -func (tm *transferManager) transfer(key string, xferFunc DoFunc, progressOutput progress.Output) (transfer, *watcher) { +func (tm *transferManager) transfer(key string, xferFunc doFunc, progressOutput progress.Output) (transfer, *watcher) { tm.mu.Lock() defer tm.mu.Unlock() diff --git a/distribution/xfer/transfer_test.go b/distribution/xfer/transfer_test.go index 9faecb8766..305bb91662 100644 --- a/distribution/xfer/transfer_test.go +++ b/distribution/xfer/transfer_test.go @@ -9,7 +9,7 @@ import ( ) func TestTransfer(t *testing.T) { - makeXferFunc := func(id string) DoFunc { + makeXferFunc := func(id string) doFunc { return func(progressChan chan<- progress.Progress, start <-chan struct{}, _ chan<- struct{}) transfer { select { case <-start: @@ -71,7 +71,7 @@ func TestConcurrencyLimit(t *testing.T) { const concurrencyLimit = 3 var runningJobs int32 - makeXferFunc := func(id string) DoFunc { + makeXferFunc := func(id string) doFunc { return func(progressChan chan<- progress.Progress, start <-chan struct{}, _ chan<- struct{}) transfer { xfer := newTransfer() go func() { @@ -130,7 +130,7 @@ func TestInactiveJobs(t *testing.T) { var runningJobs int32 testDone := make(chan struct{}) - makeXferFunc := func(id string) DoFunc { + makeXferFunc := func(id string) doFunc { return func(progressChan chan<- progress.Progress, start <-chan struct{}, inactive chan<- struct{}) transfer { xfer := newTransfer() go func() { @@ -190,7 +190,7 @@ func TestInactiveJobs(t *testing.T) { func TestWatchRelease(t *testing.T) { ready := make(chan struct{}) - makeXferFunc := func(id string) DoFunc { + makeXferFunc := func(id string) doFunc { return func(progressChan chan<- progress.Progress, start <-chan struct{}, _ chan<- struct{}) transfer { xfer := newTransfer() go func() { @@ -279,7 +279,7 @@ func TestWatchRelease(t *testing.T) { } func TestWatchFinishedTransfer(t *testing.T) { - makeXferFunc := func(id string) DoFunc { + makeXferFunc := func(id string) doFunc { return func(progressChan chan<- progress.Progress, _ <-chan struct{}, _ chan<- struct{}) transfer { xfer := newTransfer() go func() { @@ -321,7 +321,7 @@ func TestDuplicateTransfer(t *testing.T) { var xferFuncCalls int32 - makeXferFunc := func(id string) DoFunc { + makeXferFunc := func(id string) doFunc { return func(progressChan chan<- progress.Progress, _ <-chan struct{}, _ chan<- struct{}) transfer { atomic.AddInt32(&xferFuncCalls, 1) xfer := newTransfer() diff --git a/distribution/xfer/upload.go b/distribution/xfer/upload.go index 9f870afb6e..40705bad6c 100644 --- a/distribution/xfer/upload.go +++ b/distribution/xfer/upload.go @@ -102,7 +102,7 @@ func (lum *LayerUploadManager) Upload(ctx context.Context, layers []UploadDescri return nil } -func (lum *LayerUploadManager) makeUploadFunc(descriptor UploadDescriptor) DoFunc { +func (lum *LayerUploadManager) makeUploadFunc(descriptor UploadDescriptor) doFunc { return func(progressChan chan<- progress.Progress, start <-chan struct{}, inactive chan<- struct{}) transfer { u := &uploadTransfer{ transfer: newTransfer(),