Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CheckServerRequest ¶
CheckServerRequest wraps the request which is sent to uploader for check the peer server on port whether is available.
type DownloadAPI ¶
type DownloadAPI interface { // Download downloads a piece and returns an HTTP response. Download(ip string, port int, req *DownloadRequest) (*http.Response, error) }
DownloadAPI defines the download method between dfget and peer server.
type DownloadRequest ¶
DownloadRequest wraps the request which is sent to peer for downloading one piece.
type FinishTaskRequest ¶
type FinishTaskRequest struct { TaskFileName string `request:"taskFileName"` TaskID string `request:"taskID"` ClientID string `request:"cid"` Node string `request:"superNode"` }
FinishTaskRequest wraps the request which is sent to uploader in order to report a finished task.
type ParseRateRequest ¶
ParseRateRequest wraps the request which is sent to uploader in order to calculate the rate limit dynamically.
type SupernodeAPI ¶
type SupernodeAPI interface { Register(ip string, req *types.RegisterRequest) (resp *types.RegisterResponse, e error) PullPieceTask(ip string, req *types.PullPieceTaskRequest) (resp *types.PullPieceTaskResponse, e error) ReportPiece(ip string, req *types.ReportPieceRequest) (resp *types.BaseResponse, e error) ServiceDown(ip string, taskID string, cid string) (resp *types.BaseResponse, e error) }
SupernodeAPI defines the communication methods between supernode and dfget.
func NewSupernodeAPI ¶
func NewSupernodeAPI() SupernodeAPI
NewSupernodeAPI creates a new instance of SupernodeAPI with default value.
type UploaderAPI ¶
type UploaderAPI interface { // ParseRate sends a request to uploader to calculate the rateLimit dynamically // for the speed limit of the whole host machine. ParseRate(ip string, port int, req *ParseRateRequest) (string, error) // CheckServer checks the peer server on port whether is available. CheckServer(ip string, port int, req *CheckServerRequest) (string, error) // FinishTask report a finished task to peer server. FinishTask(ip string, port int, req *FinishTaskRequest) error // PingServer send a request to determine whether the server has started. PingServer(ip string, port int) bool }
UploaderAPI defines the communication methods between dfget and uploader.
func NewUploaderAPI ¶
func NewUploaderAPI(timeout time.Duration) UploaderAPI
NewUploaderAPI returns a new UploaderAPI.