Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientWriter ¶
type ClientWriter struct {
// contains filtered or unexported fields
}
ClientWriter writes a file for uploading and a target file.
func NewClientWriter ¶
func NewClientWriter(clientFilePath, serviceFilePath string, clientQueue util.Queue, api api.SupernodeAPI, cfg *config.Config) (*ClientWriter, error)
NewClientWriter creates and initialize a ClientWriter instance.
type P2PDownloader ¶
type P2PDownloader struct { // API holds the instance of SupernodeAPI to interact with supernode. API api.SupernodeAPI // Register holds the instance of SupernodeRegister. Register regist.SupernodeRegister // RegisterResult indicates the result set of registering to supernode. RegisterResult *regist.RegisterResult // contains filtered or unexported fields }
P2PDownloader is one implementation of Downloader that uses p2p pattern to download files.
func NewP2PDownloader ¶
func NewP2PDownloader(cfg *config.Config, api api.SupernodeAPI, register regist.SupernodeRegister, result *regist.RegisterResult) *P2PDownloader
NewP2PDownloader create P2PDownloader
func (*P2PDownloader) Cleanup ¶
func (p2p *P2PDownloader) Cleanup()
Cleanup clean all temporary resources generated by executing Run.
func (*P2PDownloader) GetNode ¶
func (p2p *P2PDownloader) GetNode() string
GetNode returns supernode ip.
func (*P2PDownloader) GetTaskID ¶
func (p2p *P2PDownloader) GetTaskID() string
GetTaskID returns downloading taskID.
type Piece ¶
type Piece struct { // TaskID a string which represents a unique task. TaskID string `json:"taskID"` // SuperNode indicates the IP address of the currently registered supernode. SuperNode string `json:"superNode"` // DstCid means the clientID of the target peer node for downloading the piece. DstCid string `json:"dstCid"` // Range indicates the range of specific piece in the task, example "0-45565". Range string `json:"range"` // Result of the piece downloaded. Result int `json:"result"` // Status of the downloading task. Status int `json:"status"` // PieceSize the length of the piece. PieceSize int32 `json:"pieceSize"` // PieceNum represents the position of the piece in the pieces list by cutting files. PieceNum int `json:"pieceNum"` // Content uses a buffer to temporarily store the piece content. Content *bytes.Buffer `json:"-"` }
Piece contains all information of a piece.
func NewPieceContent ¶
func NewPieceContent(taskID, node, dstCid, pieceRange string, result, status int, contents *bytes.Buffer) *Piece
NewPieceContent creates a Piece with specified content.
func NewPieceSimple ¶
NewPieceSimple creates a Piece with default value.
func (*Piece) RawContent ¶
RawContent return raw contents.
type PowerClient ¶
type PowerClient struct {
// contains filtered or unexported fields
}
PowerClient downloads file from dragonfly.
func (*PowerClient) ClientError ¶ added in v0.3.1
func (pc *PowerClient) ClientError() *types.ClientErrorRequest
ClientError return the client error if occurred
type TargetWriter ¶
type TargetWriter struct {
// contains filtered or unexported fields
}
TargetWriter writes downloading file to disk.
func NewTargetWriter ¶
NewTargetWriter creates and initialize a TargetWriter instance.