progress

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2020 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// PieceRunning means that the pieces is being downloaded.
	PieceRunning = "running"

	// PieceSuccess means that the piece has been downloaded successful.
	PieceSuccess = "success"

	// PieceAvailable means that the piece has neither been downloaded successfully
	// nor being downloaded and supernode has downloaded it successfully.
	PieceAvailable = "available"
)

PieceStatus which is used for GetPieceByCID.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager is an implementation of the interface of ProgressMgr.

func NewManager

func NewManager(cfg *config.Config) (*Manager, error)

NewManager returns a new Manager.

func (*Manager) DeleteCID added in v1.0.0

func (pm *Manager) DeleteCID(ctx context.Context, clientID string) (err error)

DeleteCID deletes the client progress with specified clientID.

func (*Manager) DeletePeerID added in v1.0.0

func (pm *Manager) DeletePeerID(ctx context.Context, peerID string) error

DeletePeerID deletes the related info with specified PeerID.

func (*Manager) DeletePeerIDByPieceNum

func (pm *Manager) DeletePeerIDByPieceNum(ctx context.Context, taskID string, pieceNum int, peerID string) error

DeletePeerIDByPieceNum deletes the peerID which means that the peer no longer provides the service for the pieceNum of taskID.

func (*Manager) DeleteTaskID added in v1.0.0

func (pm *Manager) DeleteTaskID(ctx context.Context, taskID string, pieceTotal int) (err error)

DeleteTaskID deletes the super progress with specified taskID.

func (*Manager) GetBlackInfoByPeerID

func (pm *Manager) GetBlackInfoByPeerID(ctx context.Context, peerID string) (dstPIDMap *syncmap.SyncMap, err error)

GetBlackInfoByPeerID gets black info with specified peerID.

func (*Manager) GetPeerIDsByPieceNum

func (pm *Manager) GetPeerIDsByPieceNum(ctx context.Context, taskID string, pieceNum int) (peerIDs []string, err error)

GetPeerIDsByPieceNum gets all peerIDs with specified taskID and pieceNum. It will return nil when no peers are available.

func (*Manager) GetPeerStateByPeerID

func (pm *Manager) GetPeerStateByPeerID(ctx context.Context, peerID string) (*mgr.PeerState, error)

GetPeerStateByPeerID gets peer state with specified peerID.

func (*Manager) GetPeersByTaskID

func (pm *Manager) GetPeersByTaskID(ctx context.Context, taskID string) (peersInfo []*types.PeerInfo, err error)

GetPeersByTaskID gets all peers info with specified taskID.

func (*Manager) GetPieceProgressByCID

func (pm *Manager) GetPieceProgressByCID(ctx context.Context, taskID, clientID, pieceStatus string) (pieceNums []int, err error)

GetPieceProgressByCID gets all pieces with specified clientID.

And the pieceStatus should be one of the `PieceRunning`,`PieceSuccess` and `PieceAvailable`. If not, the `PieceAvailable` will be as the default value.

func (*Manager) InitProgress

func (pm *Manager) InitProgress(ctx context.Context, taskID, peerID, clientID string) (err error)

InitProgress inits the correlation information between peers and pieces, etc.

func (*Manager) UpdateClientProgress

func (pm *Manager) UpdateClientProgress(ctx context.Context, taskID, srcCID, dstPID string, pieceNum, pieceStatus int) error

UpdateClientProgress updates the clientProgress and superProgress.

func (*Manager) UpdatePeerServiceDown added in v1.0.0

func (pm *Manager) UpdatePeerServiceDown(ctx context.Context, peerID string) (err error)

UpdatePeerServiceDown does update operation when a peer server offline.

func (*Manager) UpdateProgress

func (pm *Manager) UpdateProgress(ctx context.Context, taskID, srcCID, srcPID, dstPID string, pieceNum, pieceStatus int) error

UpdateProgress updates the correlation information between peers and pieces. NOTE: What if the update failed?

func (*Manager) UpdateSuperLoad added in v1.0.0

func (pm *Manager) UpdateSuperLoad(ctx context.Context, taskID string, delta, limit int32) (updated bool, err error)

UpdateSuperLoad updates the superload of taskID by adding the delta. The updated will be `false` if failed to do update operation.

It's considered as a failure when then superload is greater than limit after adding delta.

Jump to

Keyboard shortcuts

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