Documentation ¶
Index ¶
- Constants
- func IdleTimeoutCopy(ctx context.Context, cancel context.CancelFunc, src io.ReadCloser, ...) (copied int64, err error)
- func NewDownloadHttpClient() http.Client
- func NewRouter(service *Service) *mux.Router
- func NewServer(parentCtx context.Context, listenAddr string, handler Handler) error
- func RequestBackingImageSending(filePath, receiverAddress string) error
- type HTTPHandler
- type Handler
- type MockHandler
- type ProgressUpdater
- type Sender
- type Service
- func (s *Service) CloneFromBackingImage(writer http.ResponseWriter, request *http.Request)
- func (s *Service) Delete(writer http.ResponseWriter, request *http.Request)
- func (s *Service) DownloadFromURL(writer http.ResponseWriter, request *http.Request)
- func (s *Service) DownloadToDst(writer http.ResponseWriter, request *http.Request)
- func (s *Service) Fetch(writer http.ResponseWriter, request *http.Request)
- func (s *Service) Forget(writer http.ResponseWriter, request *http.Request)
- func (s *Service) Get(writer http.ResponseWriter, request *http.Request)
- func (s *Service) List(writer http.ResponseWriter, request *http.Request)
- func (s *Service) ReceiveFromPeer(writer http.ResponseWriter, request *http.Request)
- func (s *Service) RestoreFromBackupURL(writer http.ResponseWriter, request *http.Request)
- func (s *Service) SendToPeer(writer http.ResponseWriter, request *http.Request)
- func (s *Service) UploadFromRequest(writer http.ResponseWriter, request *http.Request)
- type SyncingFile
- func (sf *SyncingFile) CloneToFileWithEncryption(sourceBackingImage, sourceBackingImageUUID string, ...) (copied int64, err error)
- func (sf *SyncingFile) Delete()
- func (sf *SyncingFile) DownloadFromURL(url string) (written int64, err error)
- func (sf *SyncingFile) Fetch(srcFilePath string) (err error)
- func (sf *SyncingFile) Get() api.FileInfo
- func (sf *SyncingFile) GetFileReader() (io.ReadCloser, error)
- func (sf *SyncingFile) IdleTimeoutCopyToFile(src io.ReadCloser) (copied int64, err error)
- func (sf *SyncingFile) Receive(port int, fileType string) (err error)
- func (sf *SyncingFile) RestoreFromBackupURL(backupURL string, credential map[string]string, concurrentLimit int) (err error)
- func (sf *SyncingFile) Send(toAddress string, sender Sender) (err error)
- func (sf *SyncingFile) UpdateProgress(processedSize int64)
- func (sf *SyncingFile) UpdateRestoreProgress(processedSize int, err error)
- func (sf *SyncingFile) UpdateSyncFileProgress(size int64)
- func (sf *SyncingFile) WaitForStateNonPending() error
Constants ¶
const ( AutoForgetCheckInterval = time.Hour AutoForgetWaitInterval = 24 * time.Hour )
const ( RetryInterval = 1 * time.Second RetryCount = 60 LargeRetryCount = 10 * 60 PeriodicRefreshIntervalInSeconds = 2 TmpFileSuffix = ".tmp" )
const (
DownloadBufferSize = 1 << 12
)
const (
MockFileSize = 4096
)
Variables ¶
This section is empty.
Functions ¶
func IdleTimeoutCopy ¶
func IdleTimeoutCopy(ctx context.Context, cancel context.CancelFunc, src io.ReadCloser, dst io.WriteSeeker, updater ProgressUpdater, writeZero bool) (copied int64, err error)
IdleTimeoutCopy relies on ctx of the reader/src or a separate timer to interrupt the processing.
func NewDownloadHttpClient ¶ added in v1.5.4
Types ¶
type HTTPHandler ¶
type HTTPHandler struct{}
func (*HTTPHandler) DownloadFromURL ¶
func (h *HTTPHandler) DownloadFromURL(ctx context.Context, url, filePath string, updater ProgressUpdater) (written int64, err error)
func (*HTTPHandler) GetSizeFromURL ¶
func (h *HTTPHandler) GetSizeFromURL(url string) (size int64, err error)
type MockHandler ¶
type MockHandler struct{}
func (*MockHandler) DownloadFromURL ¶
func (mh *MockHandler) DownloadFromURL(ctx context.Context, url, filePath string, updater ProgressUpdater) (written int64, err error)
func (*MockHandler) GetSizeFromURL ¶
func (mh *MockHandler) GetSizeFromURL(url string) (fileSize int64, err error)
type ProgressUpdater ¶
type ProgressUpdater interface {
UpdateProgress(size int64)
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func InitService ¶
func (*Service) CloneFromBackingImage ¶ added in v1.7.0
func (s *Service) CloneFromBackingImage(writer http.ResponseWriter, request *http.Request)
func (*Service) Delete ¶
func (s *Service) Delete(writer http.ResponseWriter, request *http.Request)
func (*Service) DownloadFromURL ¶
func (s *Service) DownloadFromURL(writer http.ResponseWriter, request *http.Request)
func (*Service) DownloadToDst ¶
func (s *Service) DownloadToDst(writer http.ResponseWriter, request *http.Request)
func (*Service) Forget ¶
func (s *Service) Forget(writer http.ResponseWriter, request *http.Request)
Forget should be invoked by the caller when the file syncing is done
func (*Service) ReceiveFromPeer ¶
func (s *Service) ReceiveFromPeer(writer http.ResponseWriter, request *http.Request)
func (*Service) RestoreFromBackupURL ¶ added in v1.6.0
func (s *Service) RestoreFromBackupURL(writer http.ResponseWriter, request *http.Request)
func (*Service) SendToPeer ¶
func (s *Service) SendToPeer(writer http.ResponseWriter, request *http.Request)
func (*Service) UploadFromRequest ¶
func (s *Service) UploadFromRequest(writer http.ResponseWriter, request *http.Request)
type SyncingFile ¶
type SyncingFile struct {
// contains filtered or unexported fields
}
func NewSyncingFile ¶
func (*SyncingFile) CloneToFileWithEncryption ¶ added in v1.7.0
func (sf *SyncingFile) CloneToFileWithEncryption(sourceBackingImage, sourceBackingImageUUID string, encryption types.EncryptionType, credential map[string]string) (copied int64, err error)
CloneToFileWithEncryption clone the backing file on the same node to another backing file with the given encryption operation. when doing encryption, it creates a loop device from the target backing file, setup the encrypted device from the loop device and then dump the data from the source file to the target encrypted device. When doing decryption, it creates a loop device from the source backing file, setup the encrypted device from the loop device and then dump the data from the source encrypted device to the target file. When doing ignore clone, it directly dumps the data from the source backing file to the target backing file.
func (*SyncingFile) Delete ¶
func (sf *SyncingFile) Delete()
func (*SyncingFile) DownloadFromURL ¶
func (sf *SyncingFile) DownloadFromURL(url string) (written int64, err error)
func (*SyncingFile) Fetch ¶
func (sf *SyncingFile) Fetch(srcFilePath string) (err error)
func (*SyncingFile) Get ¶
func (sf *SyncingFile) Get() api.FileInfo
func (*SyncingFile) GetFileReader ¶
func (sf *SyncingFile) GetFileReader() (io.ReadCloser, error)
func (*SyncingFile) IdleTimeoutCopyToFile ¶
func (sf *SyncingFile) IdleTimeoutCopyToFile(src io.ReadCloser) (copied int64, err error)
func (*SyncingFile) RestoreFromBackupURL ¶ added in v1.6.0
func (*SyncingFile) UpdateProgress ¶
func (sf *SyncingFile) UpdateProgress(processedSize int64)
func (*SyncingFile) UpdateRestoreProgress ¶ added in v1.6.0
func (sf *SyncingFile) UpdateRestoreProgress(processedSize int, err error)
func (*SyncingFile) UpdateSyncFileProgress ¶
func (sf *SyncingFile) UpdateSyncFileProgress(size int64)
func (*SyncingFile) WaitForStateNonPending ¶
func (sf *SyncingFile) WaitForStateNonPending() error