api

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckServerRequest

type CheckServerRequest struct {
	TaskFileName string
	DataDir      string
	TotalLimit   int
}

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.

func NewDownloadAPI

func NewDownloadAPI() DownloadAPI

NewDownloadAPI returns a new DownloadAPI.

type DownloadRequest

type DownloadRequest struct {
	Path       string
	PieceRange string
	PieceNum   int
	PieceSize  int32
}

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

type ParseRateRequest struct {
	TaskFileName string
	RateLimit    int
}

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.

Jump to

Keyboard shortcuts

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