api

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2019 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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(node string, req *types.RegisterRequest) (resp *types.RegisterResponse, e error)
	PullPieceTask(node string, req *types.PullPieceTaskRequest) (resp *types.PullPieceTaskResponse, e error)
	ReportPiece(node string, req *types.ReportPieceRequest) (resp *types.BaseResponse, e error)
	ServiceDown(node string, taskID string, cid string) (resp *types.BaseResponse, e error)
	ReportClientError(node string, req *types.ClientErrorRequest) (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