Documentation ¶
Index ¶
- func WithCalculateDigest(enable bool) func(*pieceManager)
- func WithLimiter(limiter *rate.Limiter) func(*pieceManager)
- func WithTransport(rt http.RoundTripper) func(*pieceDownloader) error
- func WithTransportOption(opt *config.TransportOption) func(*pieceManager)
- type Bitmap
- type DownloadPieceRequest
- type DownloadPieceResult
- type FileTask
- type FileTaskProgress
- type FileTaskRequest
- type Logger
- type PieceDownloader
- type PieceManager
- type ProgressState
- type StreamTask
- type StreamTaskRequest
- type Task
- type TaskManager
- type TinyData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithCalculateDigest ¶
func WithCalculateDigest(enable bool) func(*pieceManager)
func WithLimiter ¶
WithLimiter sets upload rate limiter, the burst size must be bigger than piece size
func WithTransport ¶
func WithTransport(rt http.RoundTripper) func(*pieceDownloader) error
func WithTransportOption ¶ added in v2.0.1
func WithTransportOption(opt *config.TransportOption) func(*pieceManager)
Types ¶
type Bitmap ¶
type Bitmap struct {
// contains filtered or unexported fields
}
func NewBitmapWithCap ¶
type DownloadPieceRequest ¶
type DownloadPieceResult ¶ added in v2.0.2
type FileTask ¶ added in v2.0.2
type FileTask interface {
Start(ctx context.Context) (chan *FileTaskProgress, error)
}
FileTask represents a peer task to download a file
type FileTaskProgress ¶ added in v2.0.2
type FileTaskRequest ¶ added in v2.0.2
type FileTaskRequest struct { scheduler.PeerTaskRequest Output string Limit float64 DisableBackSource bool Pattern string Callsystem string Range *clientutil.Range KeepOriginalOffset bool }
type Logger ¶ added in v2.0.2
type Logger interface {
Log() *logger.SugaredLoggerOnWith
}
type PieceDownloader ¶
type PieceDownloader interface {
DownloadPiece(context.Context, *DownloadPieceRequest) (io.Reader, io.Closer, error)
}
func NewPieceDownloader ¶
func NewPieceDownloader(timeout time.Duration, opts ...func(*pieceDownloader) error) (PieceDownloader, error)
type PieceManager ¶
type PieceManager interface { DownloadSource(ctx context.Context, pt Task, request *scheduler.PeerTaskRequest) error DownloadPiece(ctx context.Context, request *DownloadPieceRequest) (*DownloadPieceResult, error) }
func NewPieceManager ¶
func NewPieceManager(s storage.TaskStorageDriver, pieceDownloadTimeout time.Duration, opts ...func(*pieceManager)) (PieceManager, error)
type StreamTask ¶ added in v2.0.2
type StreamTask interface { // Start starts the special peer task, return an io.Reader for stream io // when all data transferred, reader return an io.EOF // attribute stands some extra data, like HTTP response Header Start(ctx context.Context) (rc io.ReadCloser, attribute map[string]string, err error) }
StreamTask represents a peer task with stream io for reading directly without once more disk io
type StreamTaskRequest ¶ added in v2.0.2
type Task ¶
type Task interface { Logger Context() context.Context Log() *logger.SugaredLoggerOnWith GetStorage() storage.TaskStorageDriver GetPeerID() string GetTaskID() string GetTotalPieces() int32 SetTotalPieces(int32) GetContentLength() int64 SetContentLength(int64) AddTraffic(uint64) GetTraffic() uint64 SetPieceMd5Sign(string) GetPieceMd5Sign() string PublishPieceInfo(pieceNum int32, size uint32) ReportPieceResult(request *DownloadPieceRequest, result *DownloadPieceResult, err error) }
Task represents common interface to operate a peer task
type TaskManager ¶
type TaskManager interface { // StartFileTask starts a peer task to download a file // return a progress channel for request download progress // tiny stands task file is tiny and task is done StartFileTask(ctx context.Context, req *FileTaskRequest) ( progress chan *FileTaskProgress, tiny *TinyData, err error) // StartStreamTask starts a peer task with stream io // tiny stands task file is tiny and task is done StartStreamTask(ctx context.Context, req *StreamTaskRequest) ( readCloser io.ReadCloser, attribute map[string]string, err error) IsPeerTaskRunning(id string) bool // Stop stops the PeerTaskManager Stop(ctx context.Context) error }
TaskManager processes all peer tasks request
func NewPeerTaskManager ¶
func NewPeerTaskManager( host *scheduler.PeerHost, pieceManager PieceManager, storageManager storage.Manager, schedulerClient schedulerclient.SchedulerClient, schedulerOption config.SchedulerOption, perPeerRateLimit rate.Limit, multiplex bool, prefetch bool, calculateDigest bool, getPiecesMaxRetry int) (TaskManager, error)
Click to show internal directories.
Click to hide internal directories.