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 IDGenerator
- type Logger
- type PieceDownloader
- type PieceInfo
- type PieceManager
- type ProgressState
- type SeedTask
- type SeedTaskProgress
- type SeedTaskRequest
- type SeedTaskResponse
- type StreamTask
- type StreamTaskRequest
- type SubscribeResponse
- 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 Callsystem string Range *clientutil.Range KeepOriginalOffset bool }
type IDGenerator ¶ added in v2.0.2
type IDGenerator interface {
PeerID() string
}
func NewPeerIDGenerator ¶ added in v2.0.2
func NewPeerIDGenerator(ip string) IDGenerator
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) ImportFile(ctx context.Context, ptm storage.PeerTaskMetadata, tsd storage.TaskStorageDriver, req *dfdaemon.ImportTaskRequest) error }
func NewPieceManager ¶
func NewPieceManager(pieceDownloadTimeout time.Duration, opts ...func(*pieceManager)) (PieceManager, error)
type SeedTask ¶ added in v2.0.3
type SeedTask interface {
Start(ctx context.Context) (chan *SeedTaskProgress, error)
}
SeedTask represents a seed peer task
type SeedTaskProgress ¶ added in v2.0.3
type SeedTaskRequest ¶ added in v2.0.3
type SeedTaskRequest struct { scheduler.PeerTaskRequest Limit float64 Callsystem string Range *clientutil.Range }
type SeedTaskResponse ¶ added in v2.0.3
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 StreamTaskRequest struct { // universal resource locator for different kind of storage URL string // url meta info URLMeta *base.UrlMeta // http range Range *clientutil.Range // peer's id and must be global uniqueness PeerID string // Pattern to register to scheduler Pattern scheduler.Pattern }
type SubscribeResponse ¶ added in v2.0.3
type SubscribeResponse struct { Storage storage.TaskStorageDriver PieceInfoChannel chan *PieceInfo Success chan struct{} Fail chan struct{} }
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 StartStreamTask(ctx context.Context, req *StreamTaskRequest) ( readCloser io.ReadCloser, attribute map[string]string, err error) // StartSeedTask starts a seed peer task StartSeedTask(ctx context.Context, req *SeedTaskRequest) ( seedTaskResult *SeedTaskResponse, reuse bool, err error) Subscribe(request *base.PieceTaskRequest) (*SubscribeResponse, bool) IsPeerTaskRunning(taskID string) (Task, bool) // StatTask checks whether the given task exists in P2P network StatTask(ctx context.Context, taskID string) (*scheduler.Task, error) // AnnouncePeerTask announces peer task info to P2P network AnnouncePeerTask(ctx context.Context, meta storage.PeerTaskMetadata, cid string, urlMeta *base.UrlMeta) error GetPieceManager() PieceManager // 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.Client, schedulerOption config.SchedulerOption, perPeerRateLimit rate.Limit, multiplex bool, prefetch bool, calculateDigest bool, getPiecesMaxRetry int, watchdog time.Duration) (TaskManager, error)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.