func computeJobXfer()

in ste/xfer.go [80:165]


func computeJobXfer(fromTo common.FromTo, blobType common.BlobType) newJobXfer {

	//local helper functions

	getDownloader := func(sourceType common.Location) downloaderFactory {
		switch sourceType {
		case common.ELocation.Blob():
			return newBlobDownloader
		case common.ELocation.File():
			return newAzureFilesDownloader
		case common.ELocation.BlobFS():
			return newBlobFSDownloader
		default:
			panic("unexpected source type")
		}
	}

	getSenderFactory := func(fromTo common.FromTo) senderFactory {
		isFromRemote := fromTo.From().IsRemote()
		if isFromRemote {
			// sending from remote = doing an S2S copy
			switch fromTo.To() {
			case common.ELocation.Blob(),
				common.ELocation.S3(), common.ELocation.GCP():
				return newURLToBlobCopier
			case common.ELocation.File():
				return newURLToAzureFileCopier
			case common.ELocation.BlobFS():
				return newURLToBlobCopier
			default:
				panic("unexpected target location type")
			}
		} else {
			// we are uploading
			switch fromTo.To() {
			case common.ELocation.Blob():
				return newBlobUploader
			case common.ELocation.File():
				return newAzureFilesUploader
			case common.ELocation.BlobFS():
				return newBlobFSUploader
			default:
				panic("unexpected target location type")
			}
		}
	}

	getSipFactory := func(sourceType common.Location) sourceInfoProviderFactory {
		switch sourceType {
		case common.ELocation.Local():
			return newLocalSourceInfoProvider
		case common.ELocation.Benchmark():
			return newBenchmarkSourceInfoProvider
		case common.ELocation.Blob():
			return newBlobSourceInfoProvider
		case common.ELocation.File():
			return newFileSourceInfoProvider
		case common.ELocation.BlobFS():
			return newBlobSourceInfoProvider // Blob source info provider pulls info from blob and dfs
		case common.ELocation.S3():
			return newS3SourceInfoProvider
		case common.ELocation.GCP():
			return newGCPSourceInfoProvider
		default:
			panic("unexpected source type")
		}
	}

	// main computeJobXfer logic
	switch fromTo {
	case common.EFromTo.BlobTrash():
		return DeleteBlob
	case common.EFromTo.FileTrash():
		return DeleteFile
	case common.EFromTo.BlobFSTrash():
		return DeleteHNSResource
	case common.EFromTo.BlobNone(), common.EFromTo.BlobFSNone(), common.EFromTo.FileNone():
		return SetProperties
	default:
		if fromTo.IsDownload() {
			return parameterizeDownload(remoteToLocal, getDownloader(fromTo.From()))
		} else {
			return parameterizeSend(anyToRemote, getSenderFactory(fromTo), getSipFactory(fromTo.From()))
		}
	}
}