Documentation ¶
Overview ¶
Code generated by MockGen. DO NOT EDIT. Source: peertask_manager.go
Generated by this command:
mockgen -destination peertask_manager_mock.go -source peertask_manager.go -package peer
Package peer is a generated GoMock package.
Code generated by MockGen. DO NOT EDIT. Source: piece_downloader.go
Generated by this command:
mockgen -destination piece_downloader_mock.go -source piece_downloader.go -package peer
Package peer is a generated GoMock package.
Code generated by MockGen. DO NOT EDIT. Source: piece_manager.go
Generated by this command:
mockgen -destination piece_manager_mock.go -source piece_manager.go -package peer
Package peer is a generated GoMock package.
Index ¶
- Constants
- Variables
- func WithCalculateDigest(enable bool) func(*pieceManager)
- func WithConcurrentOption(opt *config.ConcurrentOption) func(*pieceManager)
- func WithLimiter(limiter *rate.Limiter) func(*pieceManager)
- func WithSyncPieceViaHTTPS(caCertPEM string) func(*pieceManager)
- func WithTransportOption(opt *config.TransportOption) func(*pieceManager)
- type Bitmap
- type DownloadPieceRequest
- type DownloadPieceResult
- type FileTask
- type FileTaskProgress
- type FileTaskRequest
- type IDGenerator
- type Logger
- type MockLogger
- type MockLoggerMockRecorder
- type MockPieceDownloader
- type MockPieceDownloaderMockRecorder
- type MockPieceManager
- func (m *MockPieceManager) DownloadPiece(ctx context.Context, request *DownloadPieceRequest) (*DownloadPieceResult, error)
- func (m *MockPieceManager) DownloadSource(ctx context.Context, pt Task, request *scheduler.PeerTaskRequest, ...) error
- func (m *MockPieceManager) EXPECT() *MockPieceManagerMockRecorder
- func (m *MockPieceManager) Import(ctx context.Context, ptm storage.PeerTaskMetadata, ...) error
- func (m *MockPieceManager) ImportFile(ctx context.Context, ptm storage.PeerTaskMetadata, ...) error
- type MockPieceManagerMockRecorder
- func (mr *MockPieceManagerMockRecorder) DownloadPiece(ctx, request any) *gomock.Call
- func (mr *MockPieceManagerMockRecorder) DownloadSource(ctx, pt, request, parsedRange any) *gomock.Call
- func (mr *MockPieceManagerMockRecorder) Import(ctx, ptm, tsd, contentLength, reader any) *gomock.Call
- func (mr *MockPieceManagerMockRecorder) ImportFile(ctx, ptm, tsd, req any) *gomock.Call
- type MockTask
- func (m *MockTask) AddTraffic(arg0 uint64)
- func (m *MockTask) Context() context.Context
- func (m *MockTask) EXPECT() *MockTaskMockRecorder
- func (m *MockTask) GetContentLength() int64
- func (m *MockTask) GetPeerID() string
- func (m *MockTask) GetPieceMd5Sign() string
- func (m *MockTask) GetStorage() storage.TaskStorageDriver
- func (m *MockTask) GetTaskID() string
- func (m *MockTask) GetTotalPieces() int32
- func (m *MockTask) GetTraffic() uint64
- func (m *MockTask) Log() *logger.SugaredLoggerOnWith
- func (m *MockTask) PublishPieceInfo(pieceNum int32, size uint32)
- func (m *MockTask) ReportPieceResult(request *DownloadPieceRequest, result *DownloadPieceResult, err error)
- func (m *MockTask) SetContentLength(arg0 int64)
- func (m *MockTask) SetPieceMd5Sign(arg0 string)
- func (m *MockTask) SetTotalPieces(arg0 int32)
- func (m *MockTask) UpdateSourceErrorStatus(st *status.Status)
- type MockTaskManager
- func (m *MockTaskManager) AnnouncePeerTask(ctx context.Context, meta storage.PeerTaskMetadata, url string, ...) error
- func (m *MockTaskManager) EXPECT() *MockTaskManagerMockRecorder
- func (m *MockTaskManager) GetPieceManager() PieceManager
- func (m *MockTaskManager) IsPeerTaskRunning(taskID, peerID string) (Task, bool)
- func (m *MockTaskManager) StartFileTask(ctx context.Context, req *FileTaskRequest) (chan *FileTaskProgress, error)
- func (m *MockTaskManager) StartSeedTask(ctx context.Context, req *SeedTaskRequest) (*SeedTaskResponse, bool, error)
- func (m *MockTaskManager) StartStreamTask(ctx context.Context, req *StreamTaskRequest) (io.ReadCloser, map[string]string, error)
- func (m *MockTaskManager) StatTask(ctx context.Context, taskID string) (*scheduler.Task, error)
- func (m *MockTaskManager) Stop(ctx context.Context) error
- func (m *MockTaskManager) Subscribe(request *common.PieceTaskRequest) (*SubscribeResponse, bool)
- type MockTaskManagerMockRecorder
- func (mr *MockTaskManagerMockRecorder) AnnouncePeerTask(ctx, meta, url, taskType, urlMeta any) *gomock.Call
- func (mr *MockTaskManagerMockRecorder) GetPieceManager() *gomock.Call
- func (mr *MockTaskManagerMockRecorder) IsPeerTaskRunning(taskID, peerID any) *gomock.Call
- func (mr *MockTaskManagerMockRecorder) StartFileTask(ctx, req any) *gomock.Call
- func (mr *MockTaskManagerMockRecorder) StartSeedTask(ctx, req any) *gomock.Call
- func (mr *MockTaskManagerMockRecorder) StartStreamTask(ctx, req any) *gomock.Call
- func (mr *MockTaskManagerMockRecorder) StatTask(ctx, taskID any) *gomock.Call
- func (mr *MockTaskManagerMockRecorder) Stop(ctx any) *gomock.Call
- func (mr *MockTaskManagerMockRecorder) Subscribe(request any) *gomock.Call
- type MockTaskMockRecorder
- func (mr *MockTaskMockRecorder) AddTraffic(arg0 any) *gomock.Call
- func (mr *MockTaskMockRecorder) Context() *gomock.Call
- func (mr *MockTaskMockRecorder) GetContentLength() *gomock.Call
- func (mr *MockTaskMockRecorder) GetPeerID() *gomock.Call
- func (mr *MockTaskMockRecorder) GetPieceMd5Sign() *gomock.Call
- func (mr *MockTaskMockRecorder) GetStorage() *gomock.Call
- func (mr *MockTaskMockRecorder) GetTaskID() *gomock.Call
- func (mr *MockTaskMockRecorder) GetTotalPieces() *gomock.Call
- func (mr *MockTaskMockRecorder) GetTraffic() *gomock.Call
- func (mr *MockTaskMockRecorder) Log() *gomock.Call
- func (mr *MockTaskMockRecorder) PublishPieceInfo(pieceNum, size any) *gomock.Call
- func (mr *MockTaskMockRecorder) ReportPieceResult(request, result, err any) *gomock.Call
- func (mr *MockTaskMockRecorder) SetContentLength(arg0 any) *gomock.Call
- func (mr *MockTaskMockRecorder) SetPieceMd5Sign(arg0 any) *gomock.Call
- func (mr *MockTaskMockRecorder) SetTotalPieces(arg0 any) *gomock.Call
- func (mr *MockTaskMockRecorder) UpdateSourceErrorStatus(st any) *gomock.Call
- type PieceDispatcher
- type PieceDownloader
- type PieceDownloaderOption
- type PieceInfo
- type PieceManager
- type PieceManagerOption
- type ProgressState
- type SeedTask
- type SeedTaskProgress
- type SeedTaskRequest
- type SeedTaskResponse
- type StreamTask
- type StreamTaskRequest
- type SubscribeResponse
- type Task
- type TaskManager
- type TaskManagerOption
- type TaskOption
- type TinyData
- type TrafficShaper
Constants ¶
const ( TypePlainTrafficShaper = "plain" TypeSamplingTrafficShaper = "sampling" )
Variables ¶
var ErrNoValidPieceTemporarily = errors.New("no valid piece temporarily")
Functions ¶
func WithCalculateDigest ¶
func WithCalculateDigest(enable bool) func(*pieceManager)
func WithConcurrentOption ¶ added in v2.0.5
func WithConcurrentOption(opt *config.ConcurrentOption) func(*pieceManager)
func WithLimiter ¶
WithLimiter sets upload rate limiter, the burst size must be bigger than piece size
func WithSyncPieceViaHTTPS ¶ added in v2.0.6
func WithSyncPieceViaHTTPS(caCertPEM string) func(*pieceManager)
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 { schedulerv1.PeerTaskRequest Output string Limit float64 DisableBackSource bool Range *http.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 MockLogger ¶ added in v2.0.4
type MockLogger struct {
// contains filtered or unexported fields
}
MockLogger is a mock of Logger interface.
func NewMockLogger ¶ added in v2.0.4
func NewMockLogger(ctrl *gomock.Controller) *MockLogger
NewMockLogger creates a new mock instance.
func (*MockLogger) EXPECT ¶ added in v2.0.4
func (m *MockLogger) EXPECT() *MockLoggerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockLogger) Log ¶ added in v2.0.4
func (m *MockLogger) Log() *logger.SugaredLoggerOnWith
Log mocks base method.
type MockLoggerMockRecorder ¶ added in v2.0.4
type MockLoggerMockRecorder struct {
// contains filtered or unexported fields
}
MockLoggerMockRecorder is the mock recorder for MockLogger.
func (*MockLoggerMockRecorder) Log ¶ added in v2.0.4
func (mr *MockLoggerMockRecorder) Log() *gomock.Call
Log indicates an expected call of Log.
type MockPieceDownloader ¶ added in v2.0.4
type MockPieceDownloader struct {
// contains filtered or unexported fields
}
MockPieceDownloader is a mock of PieceDownloader interface.
func NewMockPieceDownloader ¶ added in v2.0.4
func NewMockPieceDownloader(ctrl *gomock.Controller) *MockPieceDownloader
NewMockPieceDownloader creates a new mock instance.
func (*MockPieceDownloader) DownloadPiece ¶ added in v2.0.4
func (m *MockPieceDownloader) DownloadPiece(arg0 context.Context, arg1 *DownloadPieceRequest) (io.Reader, io.Closer, error)
DownloadPiece mocks base method.
func (*MockPieceDownloader) EXPECT ¶ added in v2.0.4
func (m *MockPieceDownloader) EXPECT() *MockPieceDownloaderMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockPieceDownloaderMockRecorder ¶ added in v2.0.4
type MockPieceDownloaderMockRecorder struct {
// contains filtered or unexported fields
}
MockPieceDownloaderMockRecorder is the mock recorder for MockPieceDownloader.
func (*MockPieceDownloaderMockRecorder) DownloadPiece ¶ added in v2.0.4
func (mr *MockPieceDownloaderMockRecorder) DownloadPiece(arg0, arg1 any) *gomock.Call
DownloadPiece indicates an expected call of DownloadPiece.
type MockPieceManager ¶ added in v2.0.7
type MockPieceManager struct {
// contains filtered or unexported fields
}
MockPieceManager is a mock of PieceManager interface.
func NewMockPieceManager ¶ added in v2.0.7
func NewMockPieceManager(ctrl *gomock.Controller) *MockPieceManager
NewMockPieceManager creates a new mock instance.
func (*MockPieceManager) DownloadPiece ¶ added in v2.0.7
func (m *MockPieceManager) DownloadPiece(ctx context.Context, request *DownloadPieceRequest) (*DownloadPieceResult, error)
DownloadPiece mocks base method.
func (*MockPieceManager) DownloadSource ¶ added in v2.0.7
func (m *MockPieceManager) DownloadSource(ctx context.Context, pt Task, request *scheduler.PeerTaskRequest, parsedRange *http.Range) error
DownloadSource mocks base method.
func (*MockPieceManager) EXPECT ¶ added in v2.0.7
func (m *MockPieceManager) EXPECT() *MockPieceManagerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockPieceManager) Import ¶ added in v2.0.7
func (m *MockPieceManager) Import(ctx context.Context, ptm storage.PeerTaskMetadata, tsd storage.TaskStorageDriver, contentLength int64, reader io.Reader) error
Import mocks base method.
func (*MockPieceManager) ImportFile ¶ added in v2.0.7
func (m *MockPieceManager) ImportFile(ctx context.Context, ptm storage.PeerTaskMetadata, tsd storage.TaskStorageDriver, req *dfdaemon.ImportTaskRequest) error
ImportFile mocks base method.
type MockPieceManagerMockRecorder ¶ added in v2.0.7
type MockPieceManagerMockRecorder struct {
// contains filtered or unexported fields
}
MockPieceManagerMockRecorder is the mock recorder for MockPieceManager.
func (*MockPieceManagerMockRecorder) DownloadPiece ¶ added in v2.0.7
func (mr *MockPieceManagerMockRecorder) DownloadPiece(ctx, request any) *gomock.Call
DownloadPiece indicates an expected call of DownloadPiece.
func (*MockPieceManagerMockRecorder) DownloadSource ¶ added in v2.0.7
func (mr *MockPieceManagerMockRecorder) DownloadSource(ctx, pt, request, parsedRange any) *gomock.Call
DownloadSource indicates an expected call of DownloadSource.
func (*MockPieceManagerMockRecorder) Import ¶ added in v2.0.7
func (mr *MockPieceManagerMockRecorder) Import(ctx, ptm, tsd, contentLength, reader any) *gomock.Call
Import indicates an expected call of Import.
func (*MockPieceManagerMockRecorder) ImportFile ¶ added in v2.0.7
func (mr *MockPieceManagerMockRecorder) ImportFile(ctx, ptm, tsd, req any) *gomock.Call
ImportFile indicates an expected call of ImportFile.
type MockTask ¶ added in v2.0.4
type MockTask struct {
// contains filtered or unexported fields
}
MockTask is a mock of Task interface.
func NewMockTask ¶ added in v2.0.4
func NewMockTask(ctrl *gomock.Controller) *MockTask
NewMockTask creates a new mock instance.
func (*MockTask) AddTraffic ¶ added in v2.0.4
AddTraffic mocks base method.
func (*MockTask) EXPECT ¶ added in v2.0.4
func (m *MockTask) EXPECT() *MockTaskMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockTask) GetContentLength ¶ added in v2.0.4
GetContentLength mocks base method.
func (*MockTask) GetPieceMd5Sign ¶ added in v2.0.4
GetPieceMd5Sign mocks base method.
func (*MockTask) GetStorage ¶ added in v2.0.4
func (m *MockTask) GetStorage() storage.TaskStorageDriver
GetStorage mocks base method.
func (*MockTask) GetTotalPieces ¶ added in v2.0.4
GetTotalPieces mocks base method.
func (*MockTask) GetTraffic ¶ added in v2.0.4
GetTraffic mocks base method.
func (*MockTask) Log ¶ added in v2.0.4
func (m *MockTask) Log() *logger.SugaredLoggerOnWith
Log mocks base method.
func (*MockTask) PublishPieceInfo ¶ added in v2.0.4
PublishPieceInfo mocks base method.
func (*MockTask) ReportPieceResult ¶ added in v2.0.4
func (m *MockTask) ReportPieceResult(request *DownloadPieceRequest, result *DownloadPieceResult, err error)
ReportPieceResult mocks base method.
func (*MockTask) SetContentLength ¶ added in v2.0.4
SetContentLength mocks base method.
func (*MockTask) SetPieceMd5Sign ¶ added in v2.0.4
SetPieceMd5Sign mocks base method.
func (*MockTask) SetTotalPieces ¶ added in v2.0.4
SetTotalPieces mocks base method.
func (*MockTask) UpdateSourceErrorStatus ¶ added in v2.0.5
UpdateSourceErrorStatus mocks base method.
type MockTaskManager ¶ added in v2.0.4
type MockTaskManager struct {
// contains filtered or unexported fields
}
MockTaskManager is a mock of TaskManager interface.
func NewMockTaskManager ¶ added in v2.0.4
func NewMockTaskManager(ctrl *gomock.Controller) *MockTaskManager
NewMockTaskManager creates a new mock instance.
func (*MockTaskManager) AnnouncePeerTask ¶ added in v2.0.4
func (m *MockTaskManager) AnnouncePeerTask(ctx context.Context, meta storage.PeerTaskMetadata, url string, taskType common.TaskType, urlMeta *common.UrlMeta) error
AnnouncePeerTask mocks base method.
func (*MockTaskManager) EXPECT ¶ added in v2.0.4
func (m *MockTaskManager) EXPECT() *MockTaskManagerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockTaskManager) GetPieceManager ¶ added in v2.0.4
func (m *MockTaskManager) GetPieceManager() PieceManager
GetPieceManager mocks base method.
func (*MockTaskManager) IsPeerTaskRunning ¶ added in v2.0.4
func (m *MockTaskManager) IsPeerTaskRunning(taskID, peerID string) (Task, bool)
IsPeerTaskRunning mocks base method.
func (*MockTaskManager) StartFileTask ¶ added in v2.0.4
func (m *MockTaskManager) StartFileTask(ctx context.Context, req *FileTaskRequest) (chan *FileTaskProgress, error)
StartFileTask mocks base method.
func (*MockTaskManager) StartSeedTask ¶ added in v2.0.4
func (m *MockTaskManager) StartSeedTask(ctx context.Context, req *SeedTaskRequest) (*SeedTaskResponse, bool, error)
StartSeedTask mocks base method.
func (*MockTaskManager) StartStreamTask ¶ added in v2.0.4
func (m *MockTaskManager) StartStreamTask(ctx context.Context, req *StreamTaskRequest) (io.ReadCloser, map[string]string, error)
StartStreamTask mocks base method.
func (*MockTaskManager) Stop ¶ added in v2.0.4
func (m *MockTaskManager) Stop(ctx context.Context) error
Stop mocks base method.
func (*MockTaskManager) Subscribe ¶ added in v2.0.4
func (m *MockTaskManager) Subscribe(request *common.PieceTaskRequest) (*SubscribeResponse, bool)
Subscribe mocks base method.
type MockTaskManagerMockRecorder ¶ added in v2.0.4
type MockTaskManagerMockRecorder struct {
// contains filtered or unexported fields
}
MockTaskManagerMockRecorder is the mock recorder for MockTaskManager.
func (*MockTaskManagerMockRecorder) AnnouncePeerTask ¶ added in v2.0.4
func (mr *MockTaskManagerMockRecorder) AnnouncePeerTask(ctx, meta, url, taskType, urlMeta any) *gomock.Call
AnnouncePeerTask indicates an expected call of AnnouncePeerTask.
func (*MockTaskManagerMockRecorder) GetPieceManager ¶ added in v2.0.4
func (mr *MockTaskManagerMockRecorder) GetPieceManager() *gomock.Call
GetPieceManager indicates an expected call of GetPieceManager.
func (*MockTaskManagerMockRecorder) IsPeerTaskRunning ¶ added in v2.0.4
func (mr *MockTaskManagerMockRecorder) IsPeerTaskRunning(taskID, peerID any) *gomock.Call
IsPeerTaskRunning indicates an expected call of IsPeerTaskRunning.
func (*MockTaskManagerMockRecorder) StartFileTask ¶ added in v2.0.4
func (mr *MockTaskManagerMockRecorder) StartFileTask(ctx, req any) *gomock.Call
StartFileTask indicates an expected call of StartFileTask.
func (*MockTaskManagerMockRecorder) StartSeedTask ¶ added in v2.0.4
func (mr *MockTaskManagerMockRecorder) StartSeedTask(ctx, req any) *gomock.Call
StartSeedTask indicates an expected call of StartSeedTask.
func (*MockTaskManagerMockRecorder) StartStreamTask ¶ added in v2.0.4
func (mr *MockTaskManagerMockRecorder) StartStreamTask(ctx, req any) *gomock.Call
StartStreamTask indicates an expected call of StartStreamTask.
func (*MockTaskManagerMockRecorder) StatTask ¶ added in v2.0.4
func (mr *MockTaskManagerMockRecorder) StatTask(ctx, taskID any) *gomock.Call
StatTask indicates an expected call of StatTask.
type MockTaskMockRecorder ¶ added in v2.0.4
type MockTaskMockRecorder struct {
// contains filtered or unexported fields
}
MockTaskMockRecorder is the mock recorder for MockTask.
func (*MockTaskMockRecorder) AddTraffic ¶ added in v2.0.4
func (mr *MockTaskMockRecorder) AddTraffic(arg0 any) *gomock.Call
AddTraffic indicates an expected call of AddTraffic.
func (*MockTaskMockRecorder) Context ¶ added in v2.0.4
func (mr *MockTaskMockRecorder) Context() *gomock.Call
Context indicates an expected call of Context.
func (*MockTaskMockRecorder) GetContentLength ¶ added in v2.0.4
func (mr *MockTaskMockRecorder) GetContentLength() *gomock.Call
GetContentLength indicates an expected call of GetContentLength.
func (*MockTaskMockRecorder) GetPeerID ¶ added in v2.0.4
func (mr *MockTaskMockRecorder) GetPeerID() *gomock.Call
GetPeerID indicates an expected call of GetPeerID.
func (*MockTaskMockRecorder) GetPieceMd5Sign ¶ added in v2.0.4
func (mr *MockTaskMockRecorder) GetPieceMd5Sign() *gomock.Call
GetPieceMd5Sign indicates an expected call of GetPieceMd5Sign.
func (*MockTaskMockRecorder) GetStorage ¶ added in v2.0.4
func (mr *MockTaskMockRecorder) GetStorage() *gomock.Call
GetStorage indicates an expected call of GetStorage.
func (*MockTaskMockRecorder) GetTaskID ¶ added in v2.0.4
func (mr *MockTaskMockRecorder) GetTaskID() *gomock.Call
GetTaskID indicates an expected call of GetTaskID.
func (*MockTaskMockRecorder) GetTotalPieces ¶ added in v2.0.4
func (mr *MockTaskMockRecorder) GetTotalPieces() *gomock.Call
GetTotalPieces indicates an expected call of GetTotalPieces.
func (*MockTaskMockRecorder) GetTraffic ¶ added in v2.0.4
func (mr *MockTaskMockRecorder) GetTraffic() *gomock.Call
GetTraffic indicates an expected call of GetTraffic.
func (*MockTaskMockRecorder) Log ¶ added in v2.0.4
func (mr *MockTaskMockRecorder) Log() *gomock.Call
Log indicates an expected call of Log.
func (*MockTaskMockRecorder) PublishPieceInfo ¶ added in v2.0.4
func (mr *MockTaskMockRecorder) PublishPieceInfo(pieceNum, size any) *gomock.Call
PublishPieceInfo indicates an expected call of PublishPieceInfo.
func (*MockTaskMockRecorder) ReportPieceResult ¶ added in v2.0.4
func (mr *MockTaskMockRecorder) ReportPieceResult(request, result, err any) *gomock.Call
ReportPieceResult indicates an expected call of ReportPieceResult.
func (*MockTaskMockRecorder) SetContentLength ¶ added in v2.0.4
func (mr *MockTaskMockRecorder) SetContentLength(arg0 any) *gomock.Call
SetContentLength indicates an expected call of SetContentLength.
func (*MockTaskMockRecorder) SetPieceMd5Sign ¶ added in v2.0.4
func (mr *MockTaskMockRecorder) SetPieceMd5Sign(arg0 any) *gomock.Call
SetPieceMd5Sign indicates an expected call of SetPieceMd5Sign.
func (*MockTaskMockRecorder) SetTotalPieces ¶ added in v2.0.4
func (mr *MockTaskMockRecorder) SetTotalPieces(arg0 any) *gomock.Call
SetTotalPieces indicates an expected call of SetTotalPieces.
func (*MockTaskMockRecorder) UpdateSourceErrorStatus ¶ added in v2.0.5
func (mr *MockTaskMockRecorder) UpdateSourceErrorStatus(st any) *gomock.Call
UpdateSourceErrorStatus indicates an expected call of UpdateSourceErrorStatus.
type PieceDispatcher ¶ added in v2.0.9
type PieceDispatcher interface { // Put pieceSynchronizer put piece request into PieceDispatcher Put(req *DownloadPieceRequest) // Get downloader will get piece request from PieceDispatcher Get() (req *DownloadPieceRequest, err error) // Report downloader will report piece download result to PieceDispatcher, so PieceDispatcher can score peers Report(result *DownloadPieceResult) // Close related resources, and not accept Put and Get anymore Close() }
func NewPieceDispatcher ¶ added in v2.0.9
func NewPieceDispatcher(randomRatio float64, log *logger.SugaredLoggerOnWith) PieceDispatcher
type PieceDownloader ¶
type PieceDownloader interface {
DownloadPiece(context.Context, *DownloadPieceRequest) (io.Reader, io.Closer, error)
}
func NewPieceDownloader ¶
func NewPieceDownloader(timeout time.Duration, caCertPool *x509.CertPool) PieceDownloader
type PieceDownloaderOption ¶ added in v2.0.6
type PieceDownloaderOption func(*pieceDownloader) error
type PieceManager ¶
type PieceManager interface { DownloadSource(ctx context.Context, pt Task, request *schedulerv1.PeerTaskRequest, parsedRange *nethttp.Range) error DownloadPiece(ctx context.Context, request *DownloadPieceRequest) (*DownloadPieceResult, error) ImportFile(ctx context.Context, ptm storage.PeerTaskMetadata, tsd storage.TaskStorageDriver, req *dfdaemonv1.ImportTaskRequest) error Import(ctx context.Context, ptm storage.PeerTaskMetadata, tsd storage.TaskStorageDriver, contentLength int64, reader io.Reader) error }
func NewPieceManager ¶
func NewPieceManager(pieceDownloadTimeout time.Duration, opts ...PieceManagerOption) (PieceManager, error)
type PieceManagerOption ¶ added in v2.0.6
type PieceManagerOption func(*pieceManager)
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 { schedulerv1.PeerTaskRequest Limit float64 Range *http.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 SubscribeResponse ¶ added in v2.0.3
type SubscribeResponse struct { Storage storage.TaskStorageDriver PieceInfoChannel chan *PieceInfo Success chan struct{} Fail chan struct{} FailReason func() error }
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) UpdateSourceErrorStatus(st *status.Status) }
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, 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 *commonv1.PieceTaskRequest) (*SubscribeResponse, bool) IsPeerTaskRunning(taskID string, peerID string) (Task, bool) // StatTask checks whether the given task exists in P2P network StatTask(ctx context.Context, taskID string) (*schedulerv1.Task, error) // AnnouncePeerTask announces peer task info to P2P network AnnouncePeerTask(ctx context.Context, meta storage.PeerTaskMetadata, url string, taskType commonv1.TaskType, urlMeta *commonv1.UrlMeta) error GetPieceManager() PieceManager // Stop stops the PeerTaskManager Stop(ctx context.Context) error }
TaskManager processes all peer tasks request
func NewPeerTaskManager ¶
func NewPeerTaskManager(opt *TaskManagerOption) (TaskManager, error)
type TaskManagerOption ¶ added in v2.0.6
type TaskManagerOption struct { TaskOption SchedulerClient schedulerclient.V1 PerPeerRateLimit rate.Limit TotalRateLimit rate.Limit TrafficShaperType string // Multiplex indicates to reuse the data of completed peer tasks Multiplex bool // Prefetch indicates to prefetch the whole files of ranged requests Prefetch bool GetPiecesMaxRetry int SplitRunningTasks bool }
type TaskOption ¶ added in v2.0.6
type TaskOption struct { // PeerHost info about current PeerHost PeerHost *schedulerv1.PeerHost // PieceManager will be used for downloading piece PieceManager PieceManager StorageManager storage.Manager // schedule options SchedulerOption config.SchedulerOption CalculateDigest bool GRPCCredentials credentials.TransportCredentials GRPCDialTimeout time.Duration // WatchdogTimeout > 0 indicates to start watch dog for every single peer task WatchdogTimeout time.Duration }
type TrafficShaper ¶ added in v2.0.7
type TrafficShaper interface { // Start starts the TrafficShaper Start() // Stop stops the TrafficShaper Stop() // AddTask starts managing the new task AddTask(taskID string, ptc *peerTaskConductor) // RemoveTask removes completed task RemoveTask(taskID string) // Record records task's used bandwidth Record(taskID string, n int) // GetBandwidth gets the total download bandwidth in the past second GetBandwidth() int64 }
TrafficShaper allocates bandwidth for running tasks dynamically
func NewPlainTrafficShaper ¶ added in v2.0.7
func NewPlainTrafficShaper() TrafficShaper
func NewSamplingTrafficShaper ¶ added in v2.0.7
func NewSamplingTrafficShaper(totalRateLimit rate.Limit, computePieceSize func(int64) uint32) TrafficShaper
func NewTrafficShaper ¶ added in v2.0.7
Source Files ¶
- peerid_generator.go
- peertask_bitmap.go
- peertask_conductor.go
- peertask_dummy.go
- peertask_file.go
- peertask_manager.go
- peertask_manager_mock.go
- peertask_piecetask_synchronizer.go
- peertask_reuse.go
- peertask_seed.go
- peertask_stream.go
- piece_broker.go
- piece_dispatcher.go
- piece_downloader.go
- piece_downloader_mock.go
- piece_manager.go
- piece_manager_mock.go
- traffic_shaper.go