Documentation ¶
Index ¶
- Constants
- type Manager
- func (pm *Manager) DeleteCID(ctx context.Context, clientID string) (err error)
- func (pm *Manager) DeletePeerID(ctx context.Context, peerID string) error
- func (pm *Manager) DeletePeerIDByPieceNum(ctx context.Context, taskID string, pieceNum int, peerID string) error
- func (pm *Manager) DeleteTaskID(ctx context.Context, taskID string, pieceTotal int) (err error)
- func (pm *Manager) GetBlackInfoByPeerID(ctx context.Context, peerID string) (dstPIDMap *syncmap.SyncMap, err error)
- func (pm *Manager) GetPeerIDsByPieceNum(ctx context.Context, taskID string, pieceNum int) (peerIDs []string, err error)
- func (pm *Manager) GetPeerStateByPeerID(ctx context.Context, peerID string) (*mgr.PeerState, error)
- func (pm *Manager) GetPeersByTaskID(ctx context.Context, taskID string) (peersInfo []*types.PeerInfo, err error)
- func (pm *Manager) GetPieceProgressByCID(ctx context.Context, taskID, clientID, pieceStatus string) (pieceNums []int, err error)
- func (pm *Manager) InitProgress(ctx context.Context, taskID, peerID, clientID string) (err error)
- func (pm *Manager) UpdateClientProgress(ctx context.Context, taskID, srcCID, dstPID string, pieceNum, pieceStatus int) error
- func (pm *Manager) UpdatePeerServiceDown(ctx context.Context, peerID string) (err error)
- func (pm *Manager) UpdateProgress(ctx context.Context, taskID, srcCID, srcPID, dstPID string, ...) error
- func (pm *Manager) UpdateSuperLoad(ctx context.Context, taskID string, delta, limit int32) (updated bool, err error)
Constants ¶
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 ¶
NewManager returns a new Manager.
func (*Manager) DeleteCID ¶ added in v1.0.0
DeleteCID deletes the client progress with specified clientID.
func (*Manager) DeletePeerID ¶ added in v1.0.0
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
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 ¶
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 ¶
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
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.