peer

package
v1.0.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 17, 2023 License: Apache-2.0 Imports: 51 Imported by: 0

Documentation

Overview

Package peer is a generated GoMock package.

Package peer is a generated GoMock package.

Package peer is a generated GoMock package.

Index

Constants

View Source
const (
	TypePlainTrafficShaper    = "plain"
	TypeSamplingTrafficShaper = "sampling"
)

Variables

View Source
var ErrNoValidPieceTemporarily = errors.New("no valid piece temporarily")

Functions

func WithCalculateDigest

func WithCalculateDigest(enable bool) func(*pieceManager)

func WithConcurrentOption

func WithConcurrentOption(opt *config.ConcurrentOption) func(*pieceManager)

func WithLimiter

func WithLimiter(limiter *rate.Limiter) func(*pieceManager)

WithLimiter sets upload rate limiter, the burst size must be bigger than piece size

func WithSyncPieceViaHTTPS

func WithSyncPieceViaHTTPS(caCertPEM string) func(*pieceManager)

func WithTransportOption

func WithTransportOption(opt *config.TransportOption) func(*pieceManager)

Types

type Bitmap

type Bitmap struct {
	// contains filtered or unexported fields
}

func NewBitmap

func NewBitmap() *Bitmap

func NewBitmapWithCap

func NewBitmapWithCap(c int32) *Bitmap

func (*Bitmap) Clean

func (b *Bitmap) Clean(i int32)

func (*Bitmap) IsSet

func (b *Bitmap) IsSet(i int32) bool

func (*Bitmap) Set

func (b *Bitmap) Set(i int32)

func (*Bitmap) Sets

func (b *Bitmap) Sets(xs ...int32)

func (*Bitmap) Settled

func (b *Bitmap) Settled() int32

type DownloadPieceRequest

type DownloadPieceRequest struct {
	TaskID     string
	PeerID     string
	DstPid     string
	DstAddr    string
	CalcDigest bool
	// contains filtered or unexported fields
}

type DownloadPieceResult

type DownloadPieceResult struct {
	// Size of piece
	Size int64
	// BeginTime nanosecond
	BeginTime int64
	// FinishTime nanosecond
	FinishTime int64
	DstPeerID  string
	Fail       bool
	// contains filtered or unexported fields
}

type FileTask

type FileTask interface {
	Start(ctx context.Context) (chan *FileTaskProgress, error)
}

FileTask represents a peer task to download a file

type FileTaskProgress

type FileTaskProgress struct {
	State           *ProgressState
	TaskID          string
	PeerID          string
	ContentLength   int64
	CompletedLength int64
	PeerTaskDone    bool
	DoneCallback    func()
}

type FileTaskRequest

type FileTaskRequest struct {
	schedulerv1.PeerTaskRequest
	Output             string
	Limit              float64
	DisableBackSource  bool
	Range              *http.Range
	KeepOriginalOffset bool
}

type IDGenerator

type IDGenerator interface {
	PeerID() string
}

func NewPeerIDGenerator

func NewPeerIDGenerator(ip string) IDGenerator

type Logger

type Logger interface {
	Log() *logger.SugaredLoggerOnWith
}

type MockLogger

type MockLogger struct {
	// contains filtered or unexported fields
}

MockLogger is a mock of Logger interface.

func NewMockLogger

func NewMockLogger(ctrl *gomock.Controller) *MockLogger

NewMockLogger creates a new mock instance.

func (*MockLogger) EXPECT

func (m *MockLogger) EXPECT() *MockLoggerMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockLogger) Log

Log mocks base method.

type MockLoggerMockRecorder

type MockLoggerMockRecorder struct {
	// contains filtered or unexported fields
}

MockLoggerMockRecorder is the mock recorder for MockLogger.

func (*MockLoggerMockRecorder) Log

func (mr *MockLoggerMockRecorder) Log() *gomock.Call

Log indicates an expected call of Log.

type MockPieceDownloader

type MockPieceDownloader struct {
	// contains filtered or unexported fields
}

MockPieceDownloader is a mock of PieceDownloader interface.

func NewMockPieceDownloader

func NewMockPieceDownloader(ctrl *gomock.Controller) *MockPieceDownloader

NewMockPieceDownloader creates a new mock instance.

func (*MockPieceDownloader) DownloadPiece

func (m *MockPieceDownloader) DownloadPiece(arg0 context.Context, arg1 *DownloadPieceRequest) (io.Reader, io.Closer, error)

DownloadPiece mocks base method.

func (*MockPieceDownloader) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

type MockPieceDownloaderMockRecorder

type MockPieceDownloaderMockRecorder struct {
	// contains filtered or unexported fields
}

MockPieceDownloaderMockRecorder is the mock recorder for MockPieceDownloader.

func (*MockPieceDownloaderMockRecorder) DownloadPiece

func (mr *MockPieceDownloaderMockRecorder) DownloadPiece(arg0, arg1 interface{}) *gomock.Call

DownloadPiece indicates an expected call of DownloadPiece.

type MockPieceManager

type MockPieceManager struct {
	// contains filtered or unexported fields
}

MockPieceManager is a mock of PieceManager interface.

func NewMockPieceManager

func NewMockPieceManager(ctrl *gomock.Controller) *MockPieceManager

NewMockPieceManager creates a new mock instance.

func (*MockPieceManager) DownloadPiece

func (m *MockPieceManager) DownloadPiece(ctx context.Context, request *DownloadPieceRequest) (*DownloadPieceResult, error)

DownloadPiece mocks base method.

func (*MockPieceManager) DownloadSource

func (m *MockPieceManager) DownloadSource(ctx context.Context, pt Task, request *v10.PeerTaskRequest, parsedRange *http.Range) error

DownloadSource mocks base method.

func (*MockPieceManager) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockPieceManager) Import

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

ImportFile mocks base method.

type MockPieceManagerMockRecorder

type MockPieceManagerMockRecorder struct {
	// contains filtered or unexported fields
}

MockPieceManagerMockRecorder is the mock recorder for MockPieceManager.

func (*MockPieceManagerMockRecorder) DownloadPiece

func (mr *MockPieceManagerMockRecorder) DownloadPiece(ctx, request interface{}) *gomock.Call

DownloadPiece indicates an expected call of DownloadPiece.

func (*MockPieceManagerMockRecorder) DownloadSource

func (mr *MockPieceManagerMockRecorder) DownloadSource(ctx, pt, request, parsedRange interface{}) *gomock.Call

DownloadSource indicates an expected call of DownloadSource.

func (*MockPieceManagerMockRecorder) Import

func (mr *MockPieceManagerMockRecorder) Import(ctx, ptm, tsd, contentLength, reader interface{}) *gomock.Call

Import indicates an expected call of Import.

func (*MockPieceManagerMockRecorder) ImportFile

func (mr *MockPieceManagerMockRecorder) ImportFile(ctx, ptm, tsd, req interface{}) *gomock.Call

ImportFile indicates an expected call of ImportFile.

type MockTask

type MockTask struct {
	// contains filtered or unexported fields
}

MockTask is a mock of Task interface.

func NewMockTask

func NewMockTask(ctrl *gomock.Controller) *MockTask

NewMockTask creates a new mock instance.

func (*MockTask) AddTraffic

func (m *MockTask) AddTraffic(arg0 uint64)

AddTraffic mocks base method.

func (*MockTask) Context

func (m *MockTask) Context() context.Context

Context mocks base method.

func (*MockTask) EXPECT

func (m *MockTask) EXPECT() *MockTaskMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockTask) GetContentLength

func (m *MockTask) GetContentLength() int64

GetContentLength mocks base method.

func (*MockTask) GetPeerID

func (m *MockTask) GetPeerID() string

GetPeerID mocks base method.

func (*MockTask) GetPieceMd5Sign

func (m *MockTask) GetPieceMd5Sign() string

GetPieceMd5Sign mocks base method.

func (*MockTask) GetStorage

func (m *MockTask) GetStorage() storage.TaskStorageDriver

GetStorage mocks base method.

func (*MockTask) GetTaskID

func (m *MockTask) GetTaskID() string

GetTaskID mocks base method.

func (*MockTask) GetTotalPieces

func (m *MockTask) GetTotalPieces() int32

GetTotalPieces mocks base method.

func (*MockTask) GetTraffic

func (m *MockTask) GetTraffic() uint64

GetTraffic mocks base method.

func (*MockTask) Log

Log mocks base method.

func (*MockTask) PublishPieceInfo

func (m *MockTask) PublishPieceInfo(pieceNum int32, size uint32)

PublishPieceInfo mocks base method.

func (*MockTask) ReportPieceResult

func (m *MockTask) ReportPieceResult(request *DownloadPieceRequest, result *DownloadPieceResult, err error)

ReportPieceResult mocks base method.

func (*MockTask) SetContentLength

func (m *MockTask) SetContentLength(arg0 int64)

SetContentLength mocks base method.

func (*MockTask) SetPieceMd5Sign

func (m *MockTask) SetPieceMd5Sign(arg0 string)

SetPieceMd5Sign mocks base method.

func (*MockTask) SetTotalPieces

func (m *MockTask) SetTotalPieces(arg0 int32)

SetTotalPieces mocks base method.

func (*MockTask) UpdateSourceErrorStatus

func (m *MockTask) UpdateSourceErrorStatus(st *status.Status)

UpdateSourceErrorStatus mocks base method.

type MockTaskManager

type MockTaskManager struct {
	// contains filtered or unexported fields
}

MockTaskManager is a mock of TaskManager interface.

func NewMockTaskManager

func NewMockTaskManager(ctrl *gomock.Controller) *MockTaskManager

NewMockTaskManager creates a new mock instance.

func (*MockTaskManager) AnnouncePeerTask

func (m *MockTaskManager) AnnouncePeerTask(ctx context.Context, meta storage.PeerTaskMetadata, url string, taskType v1.TaskType, urlMeta *v1.UrlMeta) error

AnnouncePeerTask mocks base method.

func (*MockTaskManager) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockTaskManager) GetPieceManager

func (m *MockTaskManager) GetPieceManager() PieceManager

GetPieceManager mocks base method.

func (*MockTaskManager) IsPeerTaskRunning

func (m *MockTaskManager) IsPeerTaskRunning(taskID, peerID string) (Task, bool)

IsPeerTaskRunning mocks base method.

func (*MockTaskManager) StartFileTask

func (m *MockTaskManager) StartFileTask(ctx context.Context, req *FileTaskRequest) (chan *FileTaskProgress, error)

StartFileTask mocks base method.

func (*MockTaskManager) StartSeedTask

func (m *MockTaskManager) StartSeedTask(ctx context.Context, req *SeedTaskRequest) (*SeedTaskResponse, bool, error)

StartSeedTask mocks base method.

func (*MockTaskManager) StartStreamTask

func (m *MockTaskManager) StartStreamTask(ctx context.Context, req *StreamTaskRequest) (io.ReadCloser, map[string]string, error)

StartStreamTask mocks base method.

func (*MockTaskManager) StatTask

func (m *MockTaskManager) StatTask(ctx context.Context, taskID string) (*v10.Task, error)

StatTask mocks base method.

func (*MockTaskManager) Stop

func (m *MockTaskManager) Stop(ctx context.Context) error

Stop mocks base method.

func (*MockTaskManager) Subscribe

func (m *MockTaskManager) Subscribe(request *v1.PieceTaskRequest) (*SubscribeResponse, bool)

Subscribe mocks base method.

type MockTaskManagerMockRecorder

type MockTaskManagerMockRecorder struct {
	// contains filtered or unexported fields
}

MockTaskManagerMockRecorder is the mock recorder for MockTaskManager.

func (*MockTaskManagerMockRecorder) AnnouncePeerTask

func (mr *MockTaskManagerMockRecorder) AnnouncePeerTask(ctx, meta, url, taskType, urlMeta interface{}) *gomock.Call

AnnouncePeerTask indicates an expected call of AnnouncePeerTask.

func (*MockTaskManagerMockRecorder) GetPieceManager

func (mr *MockTaskManagerMockRecorder) GetPieceManager() *gomock.Call

GetPieceManager indicates an expected call of GetPieceManager.

func (*MockTaskManagerMockRecorder) IsPeerTaskRunning

func (mr *MockTaskManagerMockRecorder) IsPeerTaskRunning(taskID, peerID interface{}) *gomock.Call

IsPeerTaskRunning indicates an expected call of IsPeerTaskRunning.

func (*MockTaskManagerMockRecorder) StartFileTask

func (mr *MockTaskManagerMockRecorder) StartFileTask(ctx, req interface{}) *gomock.Call

StartFileTask indicates an expected call of StartFileTask.

func (*MockTaskManagerMockRecorder) StartSeedTask

func (mr *MockTaskManagerMockRecorder) StartSeedTask(ctx, req interface{}) *gomock.Call

StartSeedTask indicates an expected call of StartSeedTask.

func (*MockTaskManagerMockRecorder) StartStreamTask

func (mr *MockTaskManagerMockRecorder) StartStreamTask(ctx, req interface{}) *gomock.Call

StartStreamTask indicates an expected call of StartStreamTask.

func (*MockTaskManagerMockRecorder) StatTask

func (mr *MockTaskManagerMockRecorder) StatTask(ctx, taskID interface{}) *gomock.Call

StatTask indicates an expected call of StatTask.

func (*MockTaskManagerMockRecorder) Stop

func (mr *MockTaskManagerMockRecorder) Stop(ctx interface{}) *gomock.Call

Stop indicates an expected call of Stop.

func (*MockTaskManagerMockRecorder) Subscribe

func (mr *MockTaskManagerMockRecorder) Subscribe(request interface{}) *gomock.Call

Subscribe indicates an expected call of Subscribe.

type MockTaskMockRecorder

type MockTaskMockRecorder struct {
	// contains filtered or unexported fields
}

MockTaskMockRecorder is the mock recorder for MockTask.

func (*MockTaskMockRecorder) AddTraffic

func (mr *MockTaskMockRecorder) AddTraffic(arg0 interface{}) *gomock.Call

AddTraffic indicates an expected call of AddTraffic.

func (*MockTaskMockRecorder) Context

func (mr *MockTaskMockRecorder) Context() *gomock.Call

Context indicates an expected call of Context.

func (*MockTaskMockRecorder) GetContentLength

func (mr *MockTaskMockRecorder) GetContentLength() *gomock.Call

GetContentLength indicates an expected call of GetContentLength.

func (*MockTaskMockRecorder) GetPeerID

func (mr *MockTaskMockRecorder) GetPeerID() *gomock.Call

GetPeerID indicates an expected call of GetPeerID.

func (*MockTaskMockRecorder) GetPieceMd5Sign

func (mr *MockTaskMockRecorder) GetPieceMd5Sign() *gomock.Call

GetPieceMd5Sign indicates an expected call of GetPieceMd5Sign.

func (*MockTaskMockRecorder) GetStorage

func (mr *MockTaskMockRecorder) GetStorage() *gomock.Call

GetStorage indicates an expected call of GetStorage.

func (*MockTaskMockRecorder) GetTaskID

func (mr *MockTaskMockRecorder) GetTaskID() *gomock.Call

GetTaskID indicates an expected call of GetTaskID.

func (*MockTaskMockRecorder) GetTotalPieces

func (mr *MockTaskMockRecorder) GetTotalPieces() *gomock.Call

GetTotalPieces indicates an expected call of GetTotalPieces.

func (*MockTaskMockRecorder) GetTraffic

func (mr *MockTaskMockRecorder) GetTraffic() *gomock.Call

GetTraffic indicates an expected call of GetTraffic.

func (*MockTaskMockRecorder) Log

func (mr *MockTaskMockRecorder) Log() *gomock.Call

Log indicates an expected call of Log.

func (*MockTaskMockRecorder) PublishPieceInfo

func (mr *MockTaskMockRecorder) PublishPieceInfo(pieceNum, size interface{}) *gomock.Call

PublishPieceInfo indicates an expected call of PublishPieceInfo.

func (*MockTaskMockRecorder) ReportPieceResult

func (mr *MockTaskMockRecorder) ReportPieceResult(request, result, err interface{}) *gomock.Call

ReportPieceResult indicates an expected call of ReportPieceResult.

func (*MockTaskMockRecorder) SetContentLength

func (mr *MockTaskMockRecorder) SetContentLength(arg0 interface{}) *gomock.Call

SetContentLength indicates an expected call of SetContentLength.

func (*MockTaskMockRecorder) SetPieceMd5Sign

func (mr *MockTaskMockRecorder) SetPieceMd5Sign(arg0 interface{}) *gomock.Call

SetPieceMd5Sign indicates an expected call of SetPieceMd5Sign.

func (*MockTaskMockRecorder) SetTotalPieces

func (mr *MockTaskMockRecorder) SetTotalPieces(arg0 interface{}) *gomock.Call

SetTotalPieces indicates an expected call of SetTotalPieces.

func (*MockTaskMockRecorder) UpdateSourceErrorStatus

func (mr *MockTaskMockRecorder) UpdateSourceErrorStatus(st interface{}) *gomock.Call

UpdateSourceErrorStatus indicates an expected call of UpdateSourceErrorStatus.

type PieceDispatcher

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

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

type PieceDownloaderOption func(*pieceDownloader) error

type PieceInfo

type PieceInfo struct {
	// Num is the current piece num
	Num int32
	// OrderedNum is the max pieces num with ordered, eg: 0 1 2 3 5 7 8, the OrderedNum is 3
	OrderedNum int32
	Finished   bool
}

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

type PieceManagerOption func(*pieceManager)

type ProgressState

type ProgressState struct {
	Success bool
	Code    commonv1.Code
	Msg     string
}

type SeedTask

type SeedTask interface {
	Start(ctx context.Context) (chan *SeedTaskProgress, error)
}

SeedTask represents a seed peer task

type SeedTaskProgress

type SeedTaskProgress struct {
	State           *ProgressState
	TaskID          string
	PeerID          string
	ContentLength   int64
	CompletedLength int64
	PeerTaskDone    bool
}

type SeedTaskRequest

type SeedTaskRequest struct {
	schedulerv1.PeerTaskRequest
	Limit float64
	Range *http.Range
}

type SeedTaskResponse

type SeedTaskResponse struct {
	SubscribeResponse
	Context context.Context
	Span    trace.Span
	TaskID  string
	PeerID  string
}

type StreamTask

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

type StreamTaskRequest struct {
	// universal resource locator for different kind of storage
	URL string
	// url meta info
	URLMeta *commonv1.UrlMeta
	// http range
	Range *http.Range
	// peer's id and must be global uniqueness
	PeerID string
}

type SubscribeResponse

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

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

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 TinyData

type TinyData struct {
	TaskID  string
	PeerID  string
	Content []byte
}

type TrafficShaper

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

func NewPlainTrafficShaper() TrafficShaper

func NewSamplingTrafficShaper

func NewSamplingTrafficShaper(totalRateLimit rate.Limit, computePieceSize func(int64) uint32) TrafficShaper

func NewTrafficShaper

func NewTrafficShaper(trafficShaperType string, totalRateLimit rate.Limit, computePieceSize func(int64) uint32) TrafficShaper

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL