Documentation ¶
Index ¶
- Constants
- func IdleTimeoutCopy(ctx context.Context, cancel context.CancelFunc, src io.ReadCloser, ...) (copied int64, err error)
- 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) 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) SendToPeer(writer http.ResponseWriter, request *http.Request)
- func (s *Service) UploadFromRequest(writer http.ResponseWriter, request *http.Request)
- type SyncingFile
- 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) Send(toAddress string, sender Sender) (err error)
- func (sf *SyncingFile) UpdateProgress(processedSize int64)
- func (sf *SyncingFile) UpdateSyncFileProgress(size int64)
- func (sf *SyncingFile) WaitForStateNonPending() error
Constants ¶
View Source
const ( AutoForgetCheckInterval = time.Hour AutoForgetWaitInterval = 24 * time.Hour )
View Source
const ( RetryInterval = 1 * time.Second RetryCount = 60 LargeRetryCount = 10 * 60 TmpFileSuffix = ".tmp" )
View Source
const (
DownloadBufferSize = 1 << 12
)
View Source
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) (copied int64, err error)
IdleTimeoutCopy relies on ctx of the reader/src or a separate timer to interrupt the processing.
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) 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) 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) 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) UpdateProgress ¶
func (sf *SyncingFile) UpdateProgress(processedSize int64)
func (*SyncingFile) UpdateSyncFileProgress ¶
func (sf *SyncingFile) UpdateSyncFileProgress(size int64)
func (*SyncingFile) WaitForStateNonPending ¶
func (sf *SyncingFile) WaitForStateNonPending() error
Click to show internal directories.
Click to hide internal directories.